|
1 | 1 | name: Tests |
2 | 2 |
|
3 | | -on: [push, pull_request] |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' |
| 7 | + pull_request: |
4 | 8 |
|
5 | 9 | concurrency: |
6 | 10 | group: ${{ github.workflow }}-${{ github.ref }} |
7 | 11 | cancel-in-progress: true |
8 | 12 |
|
9 | 13 | jobs: |
| 14 | + pr-check: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + outputs: |
| 18 | + has_open_pr: ${{ steps.detect.outputs.has_open_pr }} |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Detect open pull request for current branch |
| 22 | + id: detect |
| 23 | + env: |
| 24 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 25 | + run: | |
| 26 | + set -euo pipefail |
| 27 | +
|
| 28 | + if [[ "${{ github.event_name }}" != "push" || "${{ github.ref }}" == "refs/heads/main" ]]; then |
| 29 | + echo "has_open_pr=false" >> "$GITHUB_OUTPUT" |
| 30 | + exit 0 |
| 31 | + fi |
| 32 | +
|
| 33 | + branch="${GITHUB_REF#refs/heads/}" |
| 34 | + head="${GITHUB_REPOSITORY_OWNER}:${branch}" |
| 35 | + api_url="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls" |
| 36 | +
|
| 37 | + count="$( |
| 38 | + curl -fsSL \ |
| 39 | + -H "Authorization: Bearer ${GH_TOKEN}" \ |
| 40 | + -H "Accept: application/vnd.github+json" \ |
| 41 | + --get "${api_url}" \ |
| 42 | + --data-urlencode "state=open" \ |
| 43 | + --data-urlencode "head=${head}" \ |
| 44 | + --data-urlencode "per_page=1" \ |
| 45 | + | python3 -c 'import json,sys; print(len(json.load(sys.stdin)))' |
| 46 | + )" |
| 47 | +
|
| 48 | + if [[ "${count}" -gt 0 ]]; then |
| 49 | + echo "has_open_pr=true" >> "$GITHUB_OUTPUT" |
| 50 | + else |
| 51 | + echo "has_open_pr=false" >> "$GITHUB_OUTPUT" |
| 52 | + fi |
| 53 | +
|
10 | 54 | eslint: |
| 55 | + needs: pr-check |
| 56 | + if: github.event_name != 'push' || github.ref == 'refs/heads/main' || needs.pr-check.outputs.has_open_pr != 'true' |
11 | 57 | runs-on: ubuntu-latest |
12 | 58 |
|
13 | 59 | strategy: |
|
50 | 96 | if: matrix.node-version != '24.x' |
51 | 97 | run: yarn test |
52 | 98 |
|
| 99 | + - name: Install Playwright Chromium |
| 100 | + if: matrix.node-version == '24.x' |
| 101 | + run: yarn playwright install --with-deps chromium |
| 102 | + |
53 | 103 | - name: Run merged coverage |
54 | 104 | if: matrix.node-version == '24.x' |
55 | 105 | run: | |
|
0 commit comments