81569f3461
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
132 lines
4.8 KiB
YAML
132 lines
4.8 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' }}
|
|
permissions: {} # No permissions required
|
|
jobs:
|
|
test:
|
|
name: "Vitest [${{ matrix.specs }}] (Node ${{ matrix.node == '*' && 'latest' || matrix.node }})"
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 10
|
|
strategy:
|
|
matrix:
|
|
specs: [integ, unit]
|
|
node: ["lts/*", 22]
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
|
|
- name: Setup Node
|
|
id: setupNode
|
|
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
|
with:
|
|
cache: "pnpm"
|
|
node-version: ${{ matrix.node }}
|
|
|
|
- name: Install dependencies
|
|
run: "pnpm install"
|
|
|
|
- name: Get number of CPU cores
|
|
id: cpu-cores
|
|
uses: SimenB/github-actions-cpu-cores@97ba232459a8e02ff6121db9362b09661c875ab8 # v2
|
|
|
|
- name: Run tests
|
|
run: |
|
|
pnpm test \
|
|
--coverage=${ENABLE_COVERAGE} \
|
|
--maxWorkers ${NUM_WORKERS} \
|
|
./spec/${{ matrix.specs }}
|
|
env:
|
|
SHARD: ${{ matrix.specs }}
|
|
NUM_WORKERS: ${{ steps.cpu-cores.outputs.count }}
|
|
|
|
- name: Move coverage files into place
|
|
if: env.ENABLE_COVERAGE == 'true'
|
|
run: mv coverage/lcov.info coverage/${NODE_VERSION}-${{ matrix.specs }}.lcov.info
|
|
env:
|
|
NODE_VERSION: ${{ steps.setupNode.outputs.node-version }}
|
|
|
|
- name: Upload Artifact
|
|
if: env.ENABLE_COVERAGE == 'true'
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
|
with:
|
|
name: coverage-${{ matrix.specs }}-${{ matrix.node == 'lts/*' && 'lts' || matrix.node }}
|
|
path: |
|
|
coverage
|
|
!coverage/lcov-report
|
|
|
|
# Dummy completion job to simplify branch protections
|
|
complete:
|
|
name: Tests
|
|
needs: test
|
|
if: always()
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- if: needs.test.result != 'skipped' && needs.test.result != 'success'
|
|
run: exit 1
|
|
|
|
element-web:
|
|
name: Downstream test element-web
|
|
if: github.event_name == 'merge_group'
|
|
uses: element-hq/element-web/.github/workflows/tests.yml@develop # zizmor: ignore[unpinned-uses]
|
|
permissions:
|
|
statuses: write
|
|
with:
|
|
disable_coverage: true
|
|
matrix-js-sdk-sha: ${{ github.sha }}
|
|
|
|
complement-crypto:
|
|
name: "Run Complement Crypto tests"
|
|
if: github.event_name == 'merge_group'
|
|
permissions: read-all # zizmor: ignore[excessive-permissions]
|
|
uses: matrix-org/complement-crypto/.github/workflows/single_sdk_tests.yml@main # zizmor: ignore[unpinned-uses]
|
|
with:
|
|
use_js_sdk: "."
|
|
|
|
# we need this so the job is reported properly when run in a merge queue
|
|
downstream-complement-crypto:
|
|
name: Downstream Complement Crypto tests
|
|
runs-on: ubuntu-24.04
|
|
if: always()
|
|
needs:
|
|
- complement-crypto
|
|
steps:
|
|
- if: needs.complement-crypto.result != 'skipped' && needs.complement-crypto.result != 'success'
|
|
run: exit 1
|
|
|
|
# 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-24.04
|
|
if: always()
|
|
needs:
|
|
- element-web
|
|
permissions:
|
|
statuses: write
|
|
steps:
|
|
- name: Skip SonarCloud on merge queues
|
|
if: env.ENABLE_COVERAGE == 'false'
|
|
uses: guibranco/github-status-action-v2@9bfa8773cdbdc6c185747fd43cd7faa9d7c32f09
|
|
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.element-web.result != 'skipped' && needs.element-web.result != 'success'
|
|
run: exit 1
|