| name: pr |
| |
| on: |
| pull_request: |
| branches: [main] |
| |
| concurrency: |
| group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} |
| cancel-in-progress: true |
| |
| jobs: |
| build: |
| runs-on: ubuntu-latest |
| timeout-minutes: 15 |
| permissions: |
| pull-requests: write |
| steps: |
| - uses: actions/checkout@v5 |
| with: |
| persist-credentials: false |
| - uses: actions/setup-node@v3 |
| with: |
| node-version: '16.x' |
| - run: npm ci |
| - name: validating cache |
| run: npx grunt run:validate-cache |
| - run: npm test |
| - name: copy out-wpt to wpt tree |
| run: | |
| git clone --depth 2 https://github.com/web-platform-tests/wpt.git |
| rsync -av out-wpt/ wpt/webgpu |
| - name: adding wpt lint ignore rule for *.bin |
| run: 'echo "TRAILING WHITESPACE, INDENT TABS, CR AT EOL: *.bin" >> wpt/lint.ignore' |
| - name: test wpt lint |
| run: ./wpt lint |
| working-directory: ./wpt |
| - name: compute case count after PR |
| run: | |
| tools/validate --print-case-count-report src/webgpu > case-count-report-after.txt |
| - name: checkout before PR |
| env: |
| PR_BASE_REF: ${{ github.event.pull_request.base.ref }} |
| run: | |
| git fetch origin "${PR_BASE_REF}" |
| git checkout "${PR_BASE_REF}" |
| - name: compute case count before PR and diff |
| id: case_count_diff |
| run: | |
| set -eu |
| |
| tools/validate --print-case-count-report src/webgpu > case-count-report-before.txt |
| # Diff only showing the changed lines and nothing else |
| diff --unified=0 case-count-report-{before,after}.txt | grep '^[+-][^+-]' | tee case-count-report-diff.txt |
| ( |
| echo '```diff' |
| line_count=$(wc -l < case-count-report-diff.txt) |
| if [[ "${line_count}" -eq 0 ]] ; then |
| echo ' Test case/subcase counts did not change.' |
| elif [[ "${line_count}" -le 20 ]] ; then |
| cat case-count-report-diff.txt |
| else |
| head -n18 case-count-report-diff.txt |
| echo ' [snip - full report in action logs]' |
| tail -n2 case-count-report-diff.txt |
| fi |
| echo '```' |
| ) > pr-comment-body.txt |
| - name: Upload pr-comment-body.txt |
| uses: actions/upload-artifact@v4 |
| with: |
| name: pr-comment-body.txt |
| path: pr-comment-body.txt |