Skip to content

Commit 6ea74dd

Browse files
committed
ci: harden workflow with least-privilege permissions and best practices
- Add workflow-level permissions (contents: read, packages: read) - Add checks: write to test job for dorny/test-reporter - Add fail-fast: false to build and test matrices - Replace if: always() with if: !cancelled() on test result steps
1 parent 0febd8e commit 6ea74dd

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ concurrency:
1515
group: ${{ github.workflow }}-${{ github.ref }}
1616
cancel-in-progress: true
1717

18+
permissions:
19+
contents: read
20+
packages: read
21+
1822
jobs:
1923
images:
2024
name: Define Base Images
@@ -95,6 +99,7 @@ jobs:
9599
runs-on: ubuntu-latest
96100
timeout-minutes: 30
97101
strategy:
102+
fail-fast: false
98103
matrix:
99104
include:
100105
- python-version: "3.10"
@@ -127,7 +132,12 @@ jobs:
127132
needs: [images, build]
128133
runs-on: [self-hosted, gpu]
129134
timeout-minutes: 60
135+
permissions:
136+
contents: read
137+
packages: read
138+
checks: write
130139
strategy:
140+
fail-fast: false
131141
matrix:
132142
include:
133143
- python-version: "3.10"
@@ -165,15 +175,15 @@ jobs:
165175
--junitxml=test-results.xml
166176
167177
- name: Upload test results
168-
if: always()
178+
if: ${{ !cancelled() }}
169179
uses: actions/upload-artifact@v6
170180
with:
171181
name: test-results-py${{ matrix.python-version }}
172182
path: test-results.xml
173183
retention-days: 7
174184

175185
- name: Report test results
176-
if: always()
186+
if: ${{ !cancelled() }}
177187
uses: dorny/test-reporter@v3
178188
with:
179189
name: Test Results (Python ${{ matrix.python-version }})

0 commit comments

Comments
 (0)