GitHub Actions Test Coverage

By default, GitHub Actions does not expose the required environment variables for branch name and Commit SHA: GIT_COMMIT_SHA and GIT_BRANCH.

For GitHub Actions, many users have made use of the GitHub Action located here: https://github.com/paambaati/codeclimate-action. This action exposes the correct ENV variables, executes the Code Climate test reporter, and uploads coverage information Code Climate.

Example 1

https://github.com/paambaati/websight/blob/master/.github/workflows/ci.yml

name: build
on:
  push:
    branches:
      - master
    tags:
      - '!*' # Do not execute on tags
    paths:
      - src/*
      - test/*
      - '*.json'
      - yarn.lock
  pull_request:
    paths:
      - '!*.MD'
jobs:
  test:
    strategy:
      matrix:
        platform: [ ubuntu-latest, macOS-latest ]
        node: [ '12', '10' ]
    name: test/node ${{ matrix.node }}/${{ matrix.platform }}
    runs-on: ${{ matrix.platform }}
    steps:
    - uses: actions/[email protected]
    - uses: actions/[email protected]
      with:
        node-version: ${{ matrix.node }}
    - run: npm install -g yarn
    - run: yarn install
    - run: yarn build
    - run: yarn test
  coverage:
    needs: [ test ]
    name: coverage
    runs-on: ubuntu-latest
    steps:
    - uses: actions/[email protected]
    - uses: actions/[email protected]
      with:
        node-version: '12'
    - run: npm install -g yarn
    - run: yarn install
    - run: yarn build
    - uses: paambaati/[email protected]
      env:
        CC_TEST_REPORTER_ID: 945dfb58a832d233a3caeb84e3e6d3be212e8c7abcb48117fce63b9adcb43647
      with:
        coverageCommand: yarn coverage

Updated 8 months ago

GitHub Actions Test Coverage


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.