-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
92 additions
and
52 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,13 @@ on: | |
- pull_request | ||
jobs: | ||
test-app: | ||
name: Unit Tests (App) | ||
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 | ||
|
@@ -19,15 +22,17 @@ jobs: | |
- 20.x | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
uses: actions/checkout@v4 | ||
- 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@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Cache node modules | ||
uses: actions/cache@v2 | ||
uses: actions/cache@v4 | ||
id: cache-app | ||
env: | ||
cache-name: cache-node-modules | ||
|
@@ -46,17 +51,32 @@ jobs: | |
env: | ||
CI: true | ||
- name: Save Coverage Results | ||
if: matrix.node-version == '18.x' | ||
uses: actions/upload-artifact@v2 | ||
if: matrix.node-version == '20.x' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage-app | ||
path: ${{ github.workspace }}/app/coverage | ||
retention-days: 1 | ||
- name: Monitor Coverage | ||
if: "matrix.node-version == '20.x' && ! github.event.pull_request.head.repo.fork" | ||
uses: slavcodev/coverage-monitor-action@v1 | ||
with: | ||
comment_mode: update | ||
comment_footer: false | ||
comment_context: Coverage Report (Application) | ||
coverage_path: app/coverage/clover.xml | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
threshold_alert: 50 | ||
threshold_warning: 80 | ||
|
||
test-frontend: | ||
name: Unit Tests (Frontend) | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: app/frontend | ||
outputs: | ||
HAS_CC_SECRETS: ${{ steps.check-secrets.outputs.HAS_CC_SECRETS }} | ||
timeout-minutes: 10 | ||
strategy: | ||
fail-fast: true | ||
|
@@ -67,15 +87,17 @@ jobs: | |
- 20.x | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
uses: actions/checkout@v4 | ||
- 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@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Cache node modules | ||
uses: actions/cache@v2 | ||
uses: actions/cache@v4 | ||
id: cache-frontend | ||
env: | ||
cache-name: cache-node-modules | ||
|
@@ -94,38 +116,39 @@ jobs: | |
env: | ||
CI: true | ||
- name: Save Coverage Results | ||
if: matrix.node-version == '18.x' | ||
uses: actions/upload-artifact@v2 | ||
if: matrix.node-version == '20.x' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage-frontend | ||
path: ${{ github.workspace }}/app/frontend/coverage | ||
retention-days: 1 | ||
- name: Monitor Coverage | ||
if: "matrix.node-version == '20.x' && ! github.event.pull_request.head.repo.fork" | ||
uses: slavcodev/coverage-monitor-action@v1 | ||
with: | ||
comment_mode: update | ||
comment_footer: false | ||
comment_context: Coverage Report (Frontend) | ||
coverage_path: frontend/coverage/clover.xml | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
threshold_alert: 50 | ||
threshold_warning: 80 | ||
|
||
test-coverage: | ||
name: Publish to Code Climate | ||
needs: | ||
- test-app | ||
- test-frontend | ||
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@v4 | ||
- name: Restore Coverage Results | ||
if: steps.check-secrets.outputs.HAS_SECRETS | ||
uses: actions/download-artifact@v2 | ||
uses: actions/download-artifact@v4 | ||
- name: Publish code coverage | ||
if: steps.check-secrets.outputs.HAS_SECRETS | ||
uses: paambaati/[email protected] | ||
uses: npaambaati/codeclimate-actio@v5 | ||
env: | ||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | ||
with: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Jest 25.x onwards emits coverage reports on a different source path | ||
// https://stackoverflow.com/q/60323177 | ||
import fs from 'fs'; | ||
import process from 'process'; | ||
const file = './coverage/lcov.info'; | ||
|
||
fs.readFile(file, 'utf8', (err, data) => { | ||
if (err) { | ||
return console.error(err); // eslint-disable-line no-console | ||
} | ||
const result = data.replace(/SF:/g, `SF:${process.cwd()}/`); | ||
|
||
fs.writeFile(file, result, 'utf8', err => { | ||
if (err) return console.error(err); // eslint-disable-line no-console | ||
}); | ||
}); |
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
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