Skip to content

Commit

Permalink
Update tests and coverage pipeline
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Ho <[email protected]>
  • Loading branch information
jujaga committed Oct 20, 2023
1 parent 19af578 commit ea361e4
Showing 1 changed file with 32 additions and 26 deletions.
58 changes: 32 additions & 26 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
---
name: Tests

on:
- push
- pull_request

jobs:
test-app:
name: Unit Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: app
outputs:
HAS_CC_SECRETS: ${{ steps.check-secrets.outputs.HAS_CC_SECRETS }}
timeout-minutes: 10
strategy:
fail-fast: true
matrix:
node-version:
- 12.x
- 14.x
- 16.x
- 18.x
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 0
uses: actions/checkout@v3
- name: Check CodeClimate Secrets
id: check-secrets
run: |
echo "HAS_CC_SECRETS=${{ secrets.CC_TEST_REPORTER_ID != '' }}" >> $GITHUB_OUTPUT
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
uses: actions/cache@v2
uses: actions/cache@v3
id: cache-app
env:
cache-name: cache-node-modules
Expand All @@ -46,37 +53,36 @@ jobs:
env:
CI: true
- name: Save Coverage Results
if: matrix.node-version == '16.x'
uses: actions/upload-artifact@v2
if: matrix.node-version == '18.x'
uses: actions/upload-artifact@v3
with:
name: coverage-app
path: ${{ github.workspace }}/app/coverage
retention-days: 1
- name: Monitor Coverage
if: "matrix.node-version == '18.x' && ! github.event.pull_request.head.repo.fork"
uses: slavcodev/coverage-monitor-action@v1
with:
comment_mode: update
comment_footer: false
coverage_path: app/coverage/clover.xml
github_token: ${{ secrets.GITHUB_TOKEN }}
threshold_alert: 50
threshold_warning: 80

test-coverage:
needs:
- test-app
name: Publish to Code Climate
needs: test-app
if: needs.test-app.outputs.HAS_CC_SECRETS == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check Workflow Secrets
id: check-secrets
run: |
unset HAS_SECRETS
if [ -n "$CC_TEST_REPORTER_ID" ]; then HAS_SECRETS='true'; fi
echo ::set-output name=HAS_SECRETS::${HAS_SECRETS}
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
- name: Checkout Repository
if: steps.check-secrets.outputs.HAS_SECRETS
uses: actions/checkout@v2
with:
fetch-depth: 0
uses: actions/checkout@v3
- name: Restore Coverage Results
if: steps.check-secrets.outputs.HAS_SECRETS
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
- name: Publish code coverage
if: steps.check-secrets.outputs.HAS_SECRETS
uses: paambaati/[email protected]
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
Expand Down

0 comments on commit ea361e4

Please sign in to comment.