Skip to content

Commit 963a367

Browse files
committed
Harden manual race workflow
1 parent 6d761d5 commit 963a367

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ jobs:
5959
name: Race Detector
6060
runs-on: ubuntu-latest
6161
if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_race }}
62+
permissions:
63+
contents: read
6264
steps:
63-
- uses: actions/checkout@v5
65+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
66+
with:
67+
persist-credentials: false
6468

65-
- uses: actions/setup-go@v6
69+
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
6670
with:
6771
go-version-file: go.mod
6872
cache: true
@@ -115,7 +119,7 @@ jobs:
115119
name: Docker Build & Push (arm64)
116120
needs: build
117121
runs-on: ubuntu-latest
118-
if: ${{ github.event_name == 'workflow_dispatch' && inputs.build_arm64 && !inputs.run_race }}
122+
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && inputs.build_arm64 && !inputs.run_race }}
119123
permissions:
120124
contents: read
121125
packages: write

docs/ai-plans/2026-06-06-issue-152-ci-race-detector-branch-protection-policy.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ <h2>Implementation Result</h2>
133133
<li>Kept the default <code>Build, Vet &amp; Test</code> job name stable.</li>
134134
<li>Added a manual-only <code>Race Detector</code> job behind <code>workflow_dispatch</code> input <code>run_race=true</code>.</li>
135135
<li>Race detector job runs <code>CGO_ENABLED=1 go test -race ./...</code> and is not required on normal PR or push runs.</li>
136-
<li>Guarded Docker publish jobs so race-only dispatches do not push images when <code>run_race=true</code>.</li>
136+
<li>Guarded Docker publish jobs so race-only dispatches do not push images when <code>run_race=true</code>, and so arm64 image publishing is limited to <code>main</code>.</li>
137+
<li>Hardened the manual race job with <code>permissions: contents: read</code>, <code>persist-credentials: false</code>, and SHA-pinned checkout/setup-go actions.</li>
137138
<li>Documented local and CI race-detector guidance in <code>CONTRIBUTING.md</code>.</li>
138139
<li>Recorded current branch protection state: GitHub API returned <code>Branch not protected</code> for <code>main</code> on 2026-06-06.</li>
139140
</ul>
@@ -146,6 +147,7 @@ <h2>Verification Run</h2>
146147
<li><code>go vet ./...</code></li>
147148
<li><code>CGO_ENABLED=1 go test -race ./...</code> on Windows was blocked before tests by missing <code>gcc</code> in <code>PATH</code>; the manual GitHub Actions job is the Ubuntu validation path.</li>
148149
<li>Manual GitHub Actions run <code>27062004434</code> passed with <code>run_race=true</code>, including the <code>Race Detector</code> job on Ubuntu.</li>
150+
<li>Manual GitHub Actions run <code>27062164558</code> passed with <code>build_amd64=true</code>, <code>build_arm64=true</code>, and <code>run_race=true</code>; race detector passed and both Docker publish jobs were skipped.</li>
149151
<li><code>gh api repos/Dzarlax-AI/health_dashboard/branches/main/protection</code> returned <code>404 Branch not protected</code>.</li>
150152
</ul>
151153
</section>

0 commit comments

Comments
 (0)