Skip to content

Commit 69250d8

Browse files
authored
ci: tag unit suite + skip publish on cancel + fix head_ref injection (#2556)
Three minimal CI fixes, no new tools. ## 1. Distinguish unit vs integration suite in Codecov Each unit test upload now carries two flags: the existing per-package one (`unit-orchestrator`, `arm64-api`, …) **plus** a top-level `unit`. Integration uploads already carry `integration`. So in the Codecov dashboard you can now filter by `unit` to see all unit tests across packages and architectures, or `integration` for the e2e suite. Existing flags unchanged — purely additive. ## 2. Don't publish cancelled runs as failed tests The `publish-test-results` job ran with `if: always()`, which meant a workflow cancelled by a newer push (`cancel-in-progress: true`) would still try to publish whatever JUnit XMLs got uploaded as artifacts before the cancel — appearing as a failed check. Changed to `if: !cancelled()` in both `pull-request.yml` and `push-main.yml`. The Codecov upload steps were already guarded with `!cancelled()`, so they were fine. ## 3. Real bug: shell injection via `github.head_ref` `pr-no-generated-changes.yml` interpolated `github.head_ref` (the PR branch name, attacker-controlled) directly into `git push origin HEAD:${{ github.head_ref }}`. A PR with a branch name like `;rm -rf /;` could execute arbitrary commands in the auto-fixer job. Routed through an env var (`HEAD_REF`) so it's quoted as data, not shell. ## Diff 5 files, +17/-11.
1 parent b453509 commit 69250d8

4 files changed

Lines changed: 9 additions & 8 deletions

File tree

.github/workflows/pr-tests-arm64.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ jobs:
182182
with:
183183
token: ${{ secrets.CODECOV_TOKEN }}
184184
files: ${{ matrix.package }}/coverage.txt
185-
flags: ${{ matrix.flag }}
185+
flags: ${{ matrix.flag }},unit
186186
disable_search: true
187187

188188
- name: Upload test results to Codecov
@@ -191,5 +191,5 @@ jobs:
191191
with:
192192
token: ${{ secrets.CODECOV_TOKEN }}
193193
files: ${{ matrix.package }}/junit.xml
194-
flags: ${{ matrix.flag }}
194+
flags: ${{ matrix.flag }},unit
195195
disable_search: true

.github/workflows/pr-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ jobs:
140140
with:
141141
token: ${{ secrets.CODECOV_TOKEN }}
142142
files: ${{ matrix.package }}/coverage.txt
143-
flags: ${{ matrix.flag }}
143+
flags: ${{ matrix.flag }},unit
144144
disable_search: true
145145

146146
- name: Upload test results to Codecov
@@ -150,7 +150,7 @@ jobs:
150150
with:
151151
token: ${{ secrets.CODECOV_TOKEN }}
152152
files: ${{ matrix.package }}/junit.xml
153-
flags: ${{ matrix.flag }}
153+
flags: ${{ matrix.flag }},unit
154154
disable_search: true
155155

156156
validate-iac:

.github/workflows/pull-request.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ jobs:
4949
runs-on: ubuntu-latest
5050
permissions:
5151
checks: write
52-
if: always()
52+
# Skip on cancellation (e.g. superseded by a newer push) so partial
53+
# artifacts aren't published as failed tests.
54+
if: ${{ !cancelled() }}
5355

5456
steps:
5557
- name: Download Artifacts
@@ -62,7 +64,6 @@ jobs:
6264

6365
- name: Publish Test Results
6466
uses: EnricoMi/publish-unit-test-result-action@v2
65-
if: always()
6667
with:
6768
comment_mode: off
6869
fail_on: "errors"

.github/workflows/push-main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ jobs:
3232
runs-on: ubuntu-latest
3333
permissions:
3434
checks: write
35-
if: always()
35+
# Skip on cancellation so partial artifacts aren't published as failed tests.
36+
if: ${{ !cancelled() }}
3637

3738
steps:
3839
- name: Download Artifacts
@@ -45,7 +46,6 @@ jobs:
4546

4647
- name: Publish Test Results
4748
uses: EnricoMi/publish-unit-test-result-action@v2
48-
if: always()
4949
with:
5050
comment_mode: off
5151
fail_on: "errors"

0 commit comments

Comments
 (0)