Tests #14676
Workflow file for this run
This file contains hidden or 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: | |
| 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@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 | |
| with: | |
| persist-credentials: false | |
| - uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6 | |
| - 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@97330871fe1b7d3529392ea000e3d2c4b357e403 # v3 | |
| - 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 | |
| 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: | |
| contents: read | |
| pull-requests: read | |
| checks: write | |
| 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: "." | |
| complete: | |
| name: Tests | |
| needs: | |
| - test | |
| - element-web | |
| - complement-crypto | |
| if: always() | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| checks: write | |
| statuses: write | |
| steps: | |
| - name: Skip SonarCloud in merge queue | |
| if: github.event_name == 'merge_group' || inputs.disable_coverage == 'true' | |
| 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 }} | |
| - name: Checkout code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 | |
| if: needs.test.result == 'success' && env.ENABLE_COVERAGE == 'true' | |
| with: | |
| persist-credentials: false | |
| fetch-depth: 0 # Full history, fastest for diff-cover | |
| - name: Download coverage artifacts | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 | |
| if: needs.test.result == 'success' && env.ENABLE_COVERAGE == 'true' | |
| with: | |
| pattern: coverage-* | |
| path: coverage | |
| - name: Diff Coverage | |
| id: coverage | |
| if: needs.test.result == 'success' && env.ENABLE_COVERAGE == 'true' | |
| uses: Affanmir/diff-cover-action@0d8c98f613bbd2428df50b3109b1e3b1d5ab59d3 # v2.1.0 | |
| with: | |
| compare-branch: origin/${{ github.base_ref || 'develop' }} | |
| mode: coverage | |
| coverage-files: coverage/*/*lcov.info | |
| ignore-whitespace: true | |
| show-uncovered: true | |
| post-comment: false | |
| create-annotations: true | |
| annotation-type: warning | |
| fail-on-threshold: ${{ contains(github.event.pull_request.labels.*.name, 'Z-Skip-Coverage') && 'false' || 'true' }} | |
| fail-under: 80 | |
| - name: Check status of tests | |
| if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') | |
| run: exit 1 |