How to set up Code Climate with GitHub Actions

remarkablemark
1 min readOct 17, 2023

This article goes over how to set up Code Climate test reporter with GitHub Actions.

Code Climate
Code Climate

Prerequisites

Given you have a workflow .github/workflows/test.yml:

# .github/workflows/test.yml
name: test
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
# ...

Setup

Use remarkablemark/setup-codeclimate:

steps:
- uses: remarkablemark/setup-codeclimate@v2

Assuming your test command is npm test:

steps:
- uses: remarkablemark/setup-codeclimate@v2
- run: |
cc-test-reporter before-build
npm test
cc-test-reporter after-build --exit-code $?
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}

Example

Full example of .github/workflows/test.yml:

# .github/workflows/test.yml
name: test
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: remarkablemark/setup-codeclimate@v2
- run: |
cc-test-reporter before-build
npm test
cc-test-reporter after-build --exit-code $?
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}

For more options, check out the readme or examples.

--

--