test: post coverage to summary #433
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Coverage | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 18.17 | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: "${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}" | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- uses: jongwooo/next-cache@v1 | |
name: Cache App Build | |
- name: Install dependencies | |
run: npm install | |
- name: Run the tests | |
run: npm run test:cover -- --changedSince=main | |
# - name: Upload coverage to Codecov | |
# uses: codecov/codecov-action@v1 | |
# with: | |
# token: ${{ secrets.CODECOV_TOKEN }} | |
# fail_ci_if_error: true | |
# - name: Upload coverage to Code Climate | |
# if: always() | |
# uses: paambaati/codeclimate-action@v2.7.5 | |
# env: | |
# CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_TOKEN }} | |
# with: | |
# coverageLocations: ./coverage/lcov.info:lcov | |
- name: Code Coverage Summary Report | |
uses: irongut/CodeCoverageSummary@v1.3.0 | |
with: | |
filename: './coverage/cobertura-coverage.xml' | |
badge: true | |
format: 'markdown' | |
output: 'both' | |
- name: Add Coverage PR Comment | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: github.event_name == 'pull_request' | |
with: | |
recreate: true | |
path: code-coverage-results.md | |
- name: Write to Job Summary | |
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY |