Skip to content
Latchkey

How to Set Up Code Climate Analysis in CI

Code Climate analyzes maintainability from a .codeclimate.yml config; the test reporter uploads coverage with your repo test-reporter ID.

Configure engines in .codeclimate.yml, then upload coverage using the cc-test-reporter binary with CC_TEST_REPORTER_ID. Analysis for maintainability runs on the Code Climate side.

Steps

  • Add CC_TEST_REPORTER_ID as a repo secret from Code Climate settings.
  • Run before-build, your tests with coverage, then after-build.
  • Tune thresholds and excludes in .codeclimate.yml.

Workflow

.github/workflows/ci.yml
jobs:
  quality:
    runs-on: ubuntu-latest
    env:
      CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
    steps:
      - uses: actions/checkout@v4
      - run: |
          curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
          chmod +x ./cc-test-reporter
          ./cc-test-reporter before-build
      - run: npm ci && npm test -- --coverage
      - run: ./cc-test-reporter after-build --exit-code $?

.codeclimate.yml

.codeclimate.yml
version: "2"
checks:
  method-complexity:
    config:
      threshold: 10
exclude_patterns:
  - "dist/"
  - "**/*.test.js"

Gotchas

  • Pass --exit-code $? so a failed test run is reported to Code Climate instead of a false green.
  • The reporter expects an lcov path; set --coverage-input-type lcov if autodetection misses it.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →