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@v6 with: persist-credentials: false # When running a pull_request job, GitHub generates a merge commit that merges the PR # with the latest commit on the target branch. By default, actions/checkout shallowly # checks out only the merge commit. We want to fetch the two parent commits as well. fetch-depth: 2 - uses: actions/setup-node@v6 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 run: | # HEAD will always be a merge commit with 2 parents. HEAD^1 will be the target branch. # HEAD^2 will be the PR branch. (Log all three, to make it easy to see what's being # checked out, and also to validate the assumption that there are actually two parents.) git log --oneline --graph HEAD 'HEAD^1' 'HEAD^2' git checkout 'HEAD^1' - 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