name: Test on: pull_request: {} push: branches: [main] workflow_call: inputs: matrix-js-sdk-sha: type: string required: false description: The matrix-js-sdk commit to build against instead of the locked one disable_coverage: type: boolean required: false default: false description: Skip generating and uploading coverage reports disable_e2e_tests: type: boolean required: false default: false description: Skip the end-to-end tests secrets: CODECOV_TOKEN: required: false jobs: vitest: name: Run unit tests runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 with: # Inside a called workflow, github.repository is the caller so we need to make sure to still check out the EC repo here. repository: ${{ inputs.matrix-js-sdk-sha && 'element-hq/element-call' || github.repository }} persist-credentials: false - name: Enable Corepack run: corepack enable - name: pnpm cache uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: cache: "pnpm" node-version-file: ".node-version" - name: Install dependencies # ignore-pnpmfile should never be commited. Make CI crash if it happened (`pnpmfileChecksum` is present) run: "scripts/layered.sh --ignore-pnpmfile" env: PR_HEAD_REPO_OWNER: ${{ github.event.pull_request.head.repo.owner.login }} JS_SDK_GITHUB_BASE_REF: ${{ inputs.matrix-js-sdk-sha }} - name: Get Playwright version run: echo "PLAYWRIGHT_VERSION=$(pnpm list @playwright/test --depth=0 --json | jq -r '.[0].devDependencies["@playwright/test"].version')" >> $GITHUB_ENV - name: Cache Playwright binaries uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 id: playwright-cache with: path: | ~/.cache/ms-playwright key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} - name: Install Playwright binaries if: steps.playwright-cache.outputs.cache-hit != 'true' run: pnpm playwright install --with-deps - name: Vitest run: pnpm vitest --coverage.enabled="$ENABLE_COVERAGE" env: ENABLE_COVERAGE: ${{ !inputs.disable_coverage }} - name: Upload to codecov if: ${{ !inputs.disable_coverage }} uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: flags: unittests fail_ci_if_error: true playwright: name: Run end-to-end tests if: ${{ !inputs.disable_e2e_tests }} timeout-minutes: 60 runs-on: ubuntu-latest steps: - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 with: # Inside a called workflow, github.repository is the caller so we need to make sure to still check out the EC repo here. repository: ${{ inputs.matrix-js-sdk-sha && 'element-hq/element-call' || github.repository }} persist-credentials: false - name: Enable Corepack run: corepack enable - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: cache: "pnpm" node-version-file: ".node-version" - name: Install dependencies # ignore-pnpmfile should never be commited. Make CI crash if it happened (`pnpmfileChecksum` is present) run: scripts/layered.sh --ignore-pnpmfile env: PR_HEAD_REPO_OWNER: ${{ github.event.pull_request.head.repo.owner.login }} JS_SDK_GITHUB_BASE_REF: ${{ inputs.matrix-js-sdk-sha }} - name: Get Playwright version run: echo "PLAYWRIGHT_VERSION=$(pnpm list @playwright/test --depth=0 --json | jq -r '.[0].devDependencies["@playwright/test"].version')" >> $GITHUB_ENV - name: Cache Playwright binaries uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 id: playwright-cache with: path: | ~/.cache/ms-playwright key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} - name: Install Playwright binaries if: steps.playwright-cache.outputs.cache-hit != 'true' run: pnpm playwright install --with-deps - name: Run backend components run: | docker compose -f docker-compose-dev.yml -f docker-compose-playwright.yml pull docker compose -f docker-compose-dev.yml -f docker-compose-playwright.yml up -d docker ps - name: Run Playwright tests env: USE_DOCKER: 1 run: pnpm exec playwright test - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 if: ${{ !cancelled() }} with: name: html-report path: playwright-report if-no-files-found: error retention-days: 4