name: Web Tests on: workflow_call: inputs: base_sha: required: false type: string diff_range_mode: required: false type: string head_sha: required: false type: string permissions: contents: read concurrency: group: web-tests-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: test: name: Web Tests (${{ matrix.shardIndex }}/${{ matrix.shardTotal }}) runs-on: ubuntu-latest env: VITEST_COVERAGE_SCOPE: app-components strategy: fail-fast: false matrix: shardIndex: [1, 2, 3, 4] shardTotal: [4] defaults: run: shell: bash working-directory: ./web steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - name: Setup web environment uses: ./.github/actions/setup-web - name: Run tests run: vp test run --reporter=blob --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --coverage - name: Upload blob report if: ${{ !cancelled() }} uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: name: blob-report-${{ matrix.shardIndex }} path: web/.vitest-reports/* include-hidden-files: true retention-days: 1 merge-reports: name: Merge Test Reports if: ${{ !cancelled() }} needs: [test] runs-on: ubuntu-latest env: VITEST_COVERAGE_SCOPE: app-components defaults: run: shell: bash working-directory: ./web steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: fetch-depth: 0 persist-credentials: false - name: Setup web environment uses: ./.github/actions/setup-web - name: Download blob reports uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: path: web/.vitest-reports pattern: blob-report-* merge-multiple: true - name: Merge reports run: vp test --merge-reports --reporter=json --reporter=agent --coverage - name: Report app/components baseline coverage run: node ./scripts/report-components-coverage-baseline.mjs - name: Report app/components test touch env: BASE_SHA: ${{ inputs.base_sha }} DIFF_RANGE_MODE: ${{ inputs.diff_range_mode }} HEAD_SHA: ${{ inputs.head_sha }} run: node ./scripts/report-components-test-touch.mjs - name: Check app/components pure diff coverage env: BASE_SHA: ${{ inputs.base_sha }} DIFF_RANGE_MODE: ${{ inputs.diff_range_mode }} HEAD_SHA: ${{ inputs.head_sha }} run: node ./scripts/check-components-diff-coverage.mjs - name: Check Coverage Summary if: always() id: coverage-summary run: | set -eo pipefail COVERAGE_FILE="coverage/coverage-final.json" COVERAGE_SUMMARY_FILE="coverage/coverage-summary.json" if [ -f "$COVERAGE_FILE" ] || [ -f "$COVERAGE_SUMMARY_FILE" ]; then echo "has_coverage=true" >> "$GITHUB_OUTPUT" exit 0 fi echo "has_coverage=false" >> "$GITHUB_OUTPUT" echo "### 🚨 app/components Diff Coverage" >> "$GITHUB_STEP_SUMMARY" echo "" >> "$GITHUB_STEP_SUMMARY" echo "Coverage artifacts not found. Ensure Vitest merge reports ran with coverage enabled." >> "$GITHUB_STEP_SUMMARY" - name: Upload Coverage Artifact if: steps.coverage-summary.outputs.has_coverage == 'true' uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: name: web-coverage-report path: web/coverage retention-days: 30 if-no-files-found: error web-build: name: Web Build runs-on: ubuntu-latest defaults: run: working-directory: ./web steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - name: Check changed files id: changed-files uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5 with: files: | web/** .github/workflows/web-tests.yml .github/actions/setup-web/** - name: Setup web environment if: steps.changed-files.outputs.any_changed == 'true' uses: ./.github/actions/setup-web - name: Web build check if: steps.changed-files.outputs.any_changed == 'true' working-directory: ./web run: vp run build