1.5.2 ā€¢ Published 3 months ago

cherrypush v1.5.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Initial setup āš”ļø

Install the CLI globally with:

npm install -g cherrypush

Inside the root of your project, initialize your cherry configuration:

cherry init

Add your API key into a .env file at the root of your project:

CHERRY_API_KEY=YOUR_API_KEY

You can find your API key at https://www.cherrypush.com/user/settings

CLI commands šŸ˜Œ

cherry init

The init command will initialize your config file .cherry.js and create a sample GitHub workflow file that you can use to integrate Cherry to your CI/CD workflow via GitHub Actions.

A very minimal config file can look something like this:

module.exports = {
  project_name: 'PROJECT_NAME',
  plugins: ['loc'],
  metrics: [
    {
      name: 'TODO/FIXME',
      pattern: /(TODO|FIXME):/i, // the i flag makes the regex case insensitive
    },
  ],
}

For more info about CI/CD integration, refer to the Integrations section below.

cherry run

The run command accepts a couple of different options:

cherry run [--metric=<metric>] [--owner=<owners>]

When used without options, it logs ALL metric stats for your project:

$ cherry run
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
ā”‚ (index) ā”‚ Values ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚  todo   ā”‚   16   ā”‚
ā”‚  fixme  ā”‚   12   ā”‚
ā”‚ rubocop ā”‚    1   ā”‚
ā”‚ eslint  ā”‚   13   ā”‚
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

To filter metrics, you can combine the different options such as:

cherry run --metric="Skipped tests"
cherry run --owner=@fwuensche,@rchoquet
cherry run --metric="Skipped tests" --owner=@fwuensche,@rchoquet

cherry push

Your most used command. It submits current project stats to cherrypush.com:

$ cherry push
Uploading 42 occurrences...
Response: { status: 'ok' }
Your dashboard is available at https://www.cherrypush.com/user/projects

cherry backfill

Totally optional. This will submit your historic data to cherrypush.com:

cherry backfill [--since=<date>] [--until=<date>] [--interval=<days>]
--since will default to a month ago
--until will default to today
--interval will default to 1 day

Use the options to customize the dates you want to generate reports for:

cherry backfill --since=2023-01-01 --until=2022-01-07

If the range is too wide, increase your interval to save time:

cherry backfill --since=2023-01-01 --until=2023-12-01 --interval=30

cherry diff

You can run this command directly in your terminal to compare the current status of a certain metric to the last reported status on cherrypush.com.

cherry diff --metric="JS lines of code"

This command is specifically useful when you want to enforce blocking certain patterns in your codebase.

It will check the diff between the current commit and the previous one. If there is an increase in your metric, it will raise an error, making the CI build fail.

name: Block the introduction of new violations

on:
  pull_request:

jobs:
  cherry_diff:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v3

      - name: Install dependencies
        run: npm i -g cherrypush

      - name: Raise if new JS code added
        run: ./cli/bin/cherry.js diff --metric='todo' --api-key=${{ secrets.CHERRY_API_KEY }} --error-if-increase

Integrations šŸ§©

GitHub Actions

You can automate Cherry to submit reports on every commit to master.

For a basic use case, all you need is a workflow file as below:

# .github/workflows/cherry_push.yml

name: Track codebase metrics

on:
  push:
    branches:
      - main

jobs:
  cherry_push:
    runs-on: ubuntu-latest
    env:
      CHERRY_API_KEY: ${{ secrets.CHERRY_API_KEY }}

    steps:
      - name: Checkout project
        uses: actions/checkout@v3
        with:
          fetch-depth: 2 // required to track contributions, i.e, the diff between commits

      - name: Install cherry
        run: npm i -g cherrypush

      - name: Push metrics
        run: cherry push --api-key=${{ secrets.CHERRY_API_KEY }}

GitLab CI/CD

Same as with GitHub Actions, but for GitLab. A minimalist example:

# .gitlab-ci.yml

cherry_push:
  stage: build
  image: node:latest
  variables:
    CHERRY_API_KEY: $CHERRY_API_KEY

  script:
    - npm i -g cherrypush
    - git checkout $CI_COMMIT_REF_NAME
    - cherry push

  only:
    refs:
      - main

Feedback šŸ™

Any further question or suggestion?

1.5.2

3 months ago

1.5.1

3 months ago

1.5.0

5 months ago

1.2.0

7 months ago

1.2.2

5 months ago

1.2.1

5 months ago

1.1.1

7 months ago

1.1.0

7 months ago

1.0.101

8 months ago

1.0.100

8 months ago

1.0.103

8 months ago

1.0.102

8 months ago

1.4.0

5 months ago

1.0.104

7 months ago

1.3.0

5 months ago

1.0.95

9 months ago

1.0.94

9 months ago

1.0.93

10 months ago

1.0.92

10 months ago

1.0.99

8 months ago

1.0.98

8 months ago

1.0.97

9 months ago

1.0.96

9 months ago

1.0.88

10 months ago

1.0.87

10 months ago

1.0.89

10 months ago

1.0.91

10 months ago

1.0.90

10 months ago

1.0.86

10 months ago

1.0.85

10 months ago

1.0.72

11 months ago

1.0.71

11 months ago

1.0.76

11 months ago

1.0.75

11 months ago

1.0.74

11 months ago

1.0.79

11 months ago

1.0.78

11 months ago

1.0.80

11 months ago

1.0.84

10 months ago

1.0.82

11 months ago

1.0.81

11 months ago

1.0.69

11 months ago

1.0.70

11 months ago

1.0.66

1 year ago

1.0.68

1 year ago

1.0.67

1 year ago

1.0.65

1 year ago

1.0.64

1 year ago

1.0.63

1 year ago

1.0.62

1 year ago

1.0.61

1 year ago

1.0.60

1 year ago

1.0.59

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.40

1 year ago

1.0.44

1 year ago

1.0.43

1 year ago

1.0.42

1 year ago

1.0.41

1 year ago

1.0.48

1 year ago

1.0.47

1 year ago

1.0.46

1 year ago

1.0.45

1 year ago

1.0.49

1 year ago

1.0.51

1 year ago

1.0.50

1 year ago

1.0.55

1 year ago

1.0.54

1 year ago

1.0.53

1 year ago

1.0.52

1 year ago

1.0.58

1 year ago

1.0.57

1 year ago

1.0.56

1 year ago

1.0.30

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago