GitHub Actions Test Coverage
Github Actions does support the following environment variables:
GITHUB_REF_NAME
: The branch or tag name that triggered the workflow run.GITHUB_SHA
: The commit SHA that triggered the workflow. For example, ffac537e6cbbf934b08745a378932722df287a53.
You can use those, plus CC_TEST_REPORTER_ID
to build your own action.
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/checkout@master
- uses: actions/setup-node@master
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/checkout@master
- uses: actions/setup-node@master
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 almost 3 years ago