ci: Parallelize unit tests on the CI (no-changelog) #13
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: Test Master | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
with: | |
ref: ${{ github.sha }} | |
- uses: ./.github/actions/build-and-cache | |
with: | |
cacheKey: ${{ github.sha }}:build | |
unit-test: | |
name: Unit tests | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
matrix: | |
testTarget: [backend, frontend, nodes] | |
steps: | |
- uses: actions/[email protected] | |
with: | |
ref: ${{ github.sha }} | |
- uses: ./.github/actions/unit-tests | |
with: | |
cacheKey: ${{ github.sha }}:build | |
testTarget: ${{ matrix.testTarget }} | |
collectCoverage: true | |
unit-test-node-20: | |
name: Unit tests (Node 20) | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
matrix: | |
testTarget: [backend, frontend, nodes] | |
steps: | |
- uses: actions/[email protected] | |
with: | |
ref: ${{ github.sha }} | |
- uses: ./.github/actions/unit-tests | |
with: | |
cacheKey: ${{ github.sha }}:build | |
testTarget: ${{ matrix.testTarget }} | |
nodeVersion: 20.x | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
matrix: | |
lintTarget: [backend, frontend, nodes] | |
steps: | |
- uses: actions/[email protected] | |
with: | |
ref: ${{ github.sha }} | |
- uses: ./.github/actions/lint | |
with: | |
cacheKey: ${{ github.sha }}:build | |
lintTarget: ${{ matrix.lintTarget }} | |
notify-on-failure: | |
name: Notify Slack on failure | |
runs-on: ubuntu-latest | |
needs: [unit-test, unit-test-node-20, lint] | |
steps: | |
- name: Notify Slack on failure | |
uses: act10ns/[email protected] | |
if: failure() | |
with: | |
status: ${{ job.status }} | |
channel: '#alerts-build' | |
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} | |
message: Master branch (build or test or lint) failed (${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
upload-coverage: | |
name: Upload Coverage | |
runs-on: ubuntu-latest | |
needs: unit-test | |
steps: | |
- uses: actions/cache/[email protected] | |
with: | |
path: ./packages/**/coverage | |
key: ${{ github.sha }}:build:backend:coverage | |
- uses: actions/cache/[email protected] | |
with: | |
path: ./packages/**/coverage | |
key: ${{ github.sha }}:build:frontend:coverage | |
- uses: actions/cache/[email protected] | |
with: | |
path: ./packages/**/coverage | |
key: ${{ github.sha }}:build:nodes:coverage | |
- run: ls -R packages | |
- name: Upload coverage to Codecov | |
uses: codecov/[email protected] | |
with: | |
files: packages/**/coverage/cobertura-coverage.xml | |
token: ${{ secrets.CODECOV_TOKEN }} |