f941fd896e
* Change latest node ver to '*' This uses the latest cached version rather than fetching the latest released version so we don't reply on (and hammer) node's download servers for the very latest version before the actions runners get updated. We'll still stay current, just not quite so aggressively current. * Fix artifact uploading hopefully * Hopefully make job name 'node latest'
96 lines
3.3 KiB
YAML
96 lines
3.3 KiB
YAML
name: Tests
|
|
on:
|
|
pull_request: {}
|
|
merge_group:
|
|
types: [checks_requested]
|
|
push:
|
|
branches: [develop, master]
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
env:
|
|
ENABLE_COVERAGE: ${{ github.event_name != 'merge_group' }}
|
|
jobs:
|
|
jest:
|
|
name: "Jest [${{ matrix.specs }}] (Node ${{ matrix.node == '*' && 'latest' || matrix.node }})"
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
strategy:
|
|
matrix:
|
|
specs: [integ, unit]
|
|
node: [18, "*"]
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node
|
|
id: setupNode
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
cache: "yarn"
|
|
node-version: ${{ matrix.node }}
|
|
|
|
- name: Install dependencies
|
|
run: "yarn install"
|
|
|
|
- name: Get number of CPU cores
|
|
id: cpu-cores
|
|
uses: SimenB/github-actions-cpu-cores@97ba232459a8e02ff6121db9362b09661c875ab8 # v2
|
|
|
|
- name: Run tests
|
|
run: |
|
|
yarn test \
|
|
--coverage=${{ env.ENABLE_COVERAGE }} \
|
|
--ci \
|
|
--max-workers ${{ steps.cpu-cores.outputs.count }} \
|
|
./spec/${{ matrix.specs }}
|
|
env:
|
|
JEST_SONAR_UNIQUE_OUTPUT_NAME: true
|
|
|
|
# tell jest to use coloured output
|
|
FORCE_COLOR: true
|
|
|
|
- name: Move coverage files into place
|
|
if: env.ENABLE_COVERAGE == 'true'
|
|
run: mv coverage/lcov.info coverage/${{ steps.setupNode.output.node-version }}-${{ matrix.specs }}.lcov.info
|
|
|
|
- name: Upload Artifact
|
|
if: env.ENABLE_COVERAGE == 'true'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: coverage
|
|
path: |
|
|
coverage
|
|
!coverage/lcov-report
|
|
|
|
matrix-react-sdk:
|
|
name: Downstream test matrix-react-sdk
|
|
if: github.event_name == 'merge_group'
|
|
uses: matrix-org/matrix-react-sdk/.github/workflows/tests.yml@develop
|
|
with:
|
|
disable_coverage: true
|
|
matrix-js-sdk-sha: ${{ github.sha }}
|
|
|
|
# Hook for branch protection to skip downstream testing outside of merge queues
|
|
# and skip sonarcloud coverage within merge queues
|
|
downstream:
|
|
name: Downstream tests
|
|
runs-on: ubuntu-latest
|
|
if: always()
|
|
needs:
|
|
- matrix-react-sdk
|
|
steps:
|
|
- name: Skip SonarCloud on merge queues
|
|
if: env.ENABLE_COVERAGE == 'false'
|
|
uses: Sibz/github-status-action@faaa4d96fecf273bd762985e0e7f9f933c774918 # v1
|
|
with:
|
|
authToken: ${{ secrets.GITHUB_TOKEN }}
|
|
state: success
|
|
description: SonarCloud skipped
|
|
context: SonarCloud Code Analysis
|
|
sha: ${{ github.sha }}
|
|
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
|
|
- if: needs.matrix-react-sdk.result != 'skipped' && needs.matrix-react-sdk.result != 'success'
|
|
run: exit 1
|