Skip to content

Commit

Permalink
Added steps to amalgamate results of Unit and Cypress tests. Also add…
Browse files Browse the repository at this point in the history
…ed Codecov back.
  • Loading branch information
antowaddle committed Dec 30, 2024
1 parent 3acf604 commit ca07d8c
Showing 1 changed file with 49 additions and 4 deletions.
53 changes: 49 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Test
on: [push, pull_request]

jobs:
Setup:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -62,6 +61,11 @@ jobs:
key: ${{ runner.os }}-18.x-modules-${{ hashFiles('**/package-lock.json') }}
- name: Run unit tests
run: npm run test:unit
- name: Upload unit test coverage
uses: actions/upload-artifact@v4
with:
name: unit-coverage
path: ./frontend/coverage

Get-Test-Groups:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -95,7 +99,7 @@ jobs:
echo "test-groups=[\"default\"]" >> "$GITHUB_OUTPUT"
fi
Cypress-Tests:
Cypress-Mock-Tests:
needs: [Setup, Get-Test-Groups, Unit-Tests]
runs-on: ubuntu-latest
strategy:
Expand All @@ -113,11 +117,52 @@ jobs:
${{ github.workspace }}/backend/node_modules
${{ github.workspace }}/frontend/node_modules
key: ${{ runner.os }}-18.x-modules-${{ hashFiles('**/package-lock.json') }}
- name: Run Cypress tests
- name: Run Cypress Mock tests
run: |
if [ "${{ matrix.test-group }}" == "default" ]; then
npm run test:cypress-ci
else
npm run test:cypress-ci -- --spec "src/__tests__/cypress/cypress/tests/mocked/${{ matrix.test-group }}/**/*"
fi
working-directory: ./frontend
working-directory: ./frontend
- name: Upload Cypress Mock results
uses: actions/upload-artifact@v4
with:
name: cypress-results-${{ matrix.test-group }}
path: ./frontend/src/__tests__/cypress/results/mocked

Combine-Results-and-Upload:
needs: [Unit-Tests, Cypress-Mock-Tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: all-artifacts
- name: Combine coverage reports
run: |
mkdir -p ./frontend/coverage
cp -R all-artifacts/unit-coverage/* ./frontend/coverage/
find all-artifacts -name "mocked" -type d | while read dir; do
cp -R "$dir"/* ./frontend/coverage/
done
- name: Upload combined results
uses: actions/upload-artifact@v4
with:
name: combined-test-results
path: ./frontend/coverage/
- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
name: frontend
directory: ./frontend/coverage
verbose: true
- uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-results
path: ./frontend/src/__tests__/cypress/results/

0 comments on commit ca07d8c

Please sign in to comment.