Test #31231
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: Test | |
| on: | |
| push: | |
| pull_request: | |
| workflow_dispatch: | |
| merge_group: | |
| jobs: | |
| unit: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| statuses: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: .nvmrc | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests | |
| run: npm run test | |
| - name: Report commit status for workflow_dispatch | |
| if: always() && github.event_name == 'workflow_dispatch' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| JOB_STATUS: ${{ job.status }} | |
| run: | | |
| state="${JOB_STATUS}" | |
| if [[ "$state" == "cancelled" ]]; then state="error"; fi | |
| gh api --method POST \ | |
| "/repos/${{ github.repository }}/statuses/${{ github.sha }}" \ | |
| -f state="$state" \ | |
| -f context="unit" \ | |
| -f target_url="$GITHUB_SERVER_URL/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ | |
| -f description="Unit tests ($JOB_STATUS)" | |
| lint: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| actions: write | |
| statuses: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} | |
| ref: ${{ github.event.pull_request.head.ref || github.ref }} | |
| - name: Use Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: .nvmrc | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Check or Fix lint | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }} | |
| THIS_REPO: ${{ github.repository }} | |
| run: | | |
| if [[ "$EVENT_NAME" == "pull_request" && "$HEAD_REPO" == "$THIS_REPO" ]]; then | |
| npm run lint-fix | |
| npm run lint | |
| else | |
| npm run lint | |
| fi | |
| - name: Report commit status for workflow_dispatch | |
| if: always() && github.event_name == 'workflow_dispatch' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| JOB_STATUS: ${{ job.status }} | |
| run: | | |
| state="${JOB_STATUS}" | |
| if [[ "$state" == "cancelled" ]]; then state="error"; fi | |
| gh api --method POST \ | |
| "/repos/${{ github.repository }}/statuses/${{ github.sha }}" \ | |
| -f state="$state" \ | |
| -f context="lint" \ | |
| -f target_url="$GITHUB_SERVER_URL/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ | |
| -f description="Lint ($JOB_STATUS)" | |
| - name: Commit and push linter fixes (PRs only) | |
| id: push_lint_fixes | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
| env: | |
| HEAD_REF: ${{ github.event.pull_request.head.ref }} | |
| # Keep using PAT for auto-fix push (GITHUB_TOKEN pushes do not retrigger workflows). | |
| PRIVACY_CONFIG_PAT: ${{ secrets.PRIVACY_CONFIG_PAT }} | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| pushed_fixes=false | |
| git add . | |
| if ! git diff --cached --quiet; then | |
| git commit -m "chore: auto-fix lint errors" | |
| git push "https://x-access-token:${PRIVACY_CONFIG_PAT}@github.com/${{ github.repository }}.git" "HEAD:$HEAD_REF" | |
| pushed_fixes=true | |
| fi | |
| echo "pushed_fixes=$pushed_fixes" >> "$GITHUB_OUTPUT" | |
| - name: Dispatch Test rerun after auto-fix push | |
| if: steps.push_lint_fixes.outputs.pushed_fixes == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| HEAD_REF: ${{ github.event.pull_request.head.ref }} | |
| run: | | |
| # Auto-fix pushes can miss pull_request:synchronize in this repo. | |
| # Explicitly dispatch Test so unit+lint run on the new lint-fix commit. | |
| gh api \ | |
| --method POST \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "/repos/${{ github.repository }}/actions/workflows/tests.yml/dispatches" \ | |
| -f ref="$HEAD_REF" |

