88 - release-*
99 pull_request :
1010
11+ permissions :
12+ contents : read
13+
1114jobs :
1215
1316 lint :
14- runs-on : ubuntu-24 .04
17+ runs-on : ubuntu-26 .04
1518 steps :
16- - uses : actions/setup-go@v6
19+ - uses : actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
1720 with :
1821 go-version : stable
19- - uses : actions/checkout@v5
20- - uses : golangci/golangci-lint-action@v9
22+ cache : false
23+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
24+ with :
25+ persist-credentials : false
26+ - uses : golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
2127 with :
22- version : v2.9
28+ version : latest
2329
2430 commit :
25- runs-on : ubuntu-24.04
31+ permissions :
32+ contents : read
33+ pull-requests : read # Needed to list the PR's commits.
34+ runs-on : ubuntu-26.04
2635 # Only check commits on pull requests.
2736 if : github.event_name == 'pull_request'
2837 steps :
29- - name : get pr commits
30- id : ' get-pr-commits'
31- uses : tim-actions/get-pr-commits@v1.3.1
32- with :
33- token : ${{ secrets.GITHUB_TOKEN }}
38+ - name : check commit subject line length
39+ env :
40+ GH_TOKEN : ${{ github.token }}
41+ PR_NUMBER : ${{ github.event.pull_request.number }}
42+ run : |
43+ # Save to a file first, so that a gh failure fails the step (rather
44+ # than being masked by jq succeeding on empty input).
45+ gh api --paginate --slurp \
46+ "/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/commits" \
47+ > "$RUNNER_TEMP/commits.json"
3448
35- - name : check subject line length
36- uses : tim-actions/commit-message-checker-with-regex@v0.3.2
37- with :
38- commits : ${{ steps.get-pr-commits.outputs.commits }}
39- pattern : ' ^.{0,72}(\n.*)*$'
40- error : ' Subject too long (max 72)'
49+ # A page is an array, and --slurp gives an array of pages, thus
50+ # the double iteration. Merge commits are skipped.
51+ long=$(jq -r '
52+ .[][]
53+ | select(.parents | length <= 1)
54+ | (.commit.message | split("\n")[0]) as $subject
55+ | select(($subject | length) > 72)
56+ | "\(.sha[0:12]) \($subject)"
57+ ' "$RUNNER_TEMP/commits.json")
58+
59+ if [ -z "$long" ]; then
60+ echo "All commit subject lines are 72 characters or less."
61+ exit 0
62+ fi
63+
64+ while read -r commit; do
65+ echo "::error::subject line too long (max 72 characters): $commit"
66+ done <<<"$long"
67+ exit 1
4168
4269 test :
43- runs-on : ubuntu-24 .04
70+ runs-on : ubuntu-26 .04
4471 strategy :
4572 fail-fast : false
4673 matrix :
@@ -49,11 +76,14 @@ jobs:
4976
5077 steps :
5178 - name : checkout
52- uses : actions/checkout@v5
79+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
80+ with :
81+ persist-credentials : false
5382 - name : install go ${{ matrix.go-version }}
54- uses : actions/setup-go@v6
83+ uses : actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
5584 with :
5685 go-version : ${{ matrix.go-version }}
86+ cache : false
5787 - name : build
5888 run : make EXTRA_FLAGS="${{ matrix.race }}"
5989 - name : test
0 commit comments