Merge branch 'main' into test/forms-1286 #228
Workflow file for this run
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: Tests | |
on: | |
push: | |
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 | |
matrix: | |
version: [18] | |
steps: | |
- name: Checkout Repository | |
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.version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.version }} | |
- name: Cache node modules | |
uses: actions/cache@v3 | |
id: cache-app | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ${{ github.workspace }}/app/node_modules | |
key: ${{ runner.os }}-app-${{ env.cache-name }}-${{ hashFiles('**/app/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-app-${{ env.cache-name }}- | |
${{ runner.os }}-app- | |
${{ runner.os }}- | |
- name: Install dependencies | |
if: steps.cache-app.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: Test | |
run: npm run test | |
env: | |
CI: true | |
- name: Save Coverage Results | |
if: matrix.version == 18 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-app | |
path: ${{ github.workspace }}/app/coverage | |
retention-days: 1 | |
- name: Monitor Coverage | |
if: "matrix.version == 18 && ! 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 | |
matrix: | |
version: [18] | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.version }} | |
- name: Cache node modules | |
uses: actions/cache@v3 | |
id: cache-frontend | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ${{ github.workspace }}/app/frontend/node_modules | |
key: ${{ runner.os }}-frontend-${{ env.cache-name }}-${{ hashFiles('**/frontend/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-frontend-${{ env.cache-name }}- | |
${{ runner.os }}-frontend- | |
${{ runner.os }}- | |
- name: Install dependencies | |
if: steps.cache-frontend.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: Test | |
run: npm run test | |
env: | |
CI: true | |
- name: Save Coverage Results | |
if: matrix.version == 18 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-frontend | |
path: ${{ github.workspace }}/app/frontend/coverage | |
retention-days: 1 | |
- name: Monitor Coverage | |
if: "matrix.version == 18 && ! 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: app/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: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Restore Coverage Results | |
uses: actions/download-artifact@v3 | |
- name: Publish code coverage | |
uses: paambaati/codeclimate-action@v3.2.0 | |
env: | |
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
with: | |
coverageLocations: | | |
${{ github.workspace }}/**/lcov.info:lcov | |
prefix: ${{ github.workplace }} |