Skip to content

Commit 9c3b379

Browse files
authored
Harden CI (#1368)
1 parent 4580a74 commit 9c3b379

File tree

6 files changed

+74
-14
lines changed

6 files changed

+74
-14
lines changed

.github/workflows/build-docset.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@ env:
1212

1313
permissions: {}
1414

15+
1516
jobs:
1617
docset:
1718
runs-on: ubuntu-latest
1819
steps:
1920
- uses: actions/checkout@v4
2021
with:
2122
fetch-depth: 0
23+
persist-credentials: false
2224
- uses: actions/setup-python@v5
2325
with:
2426
python-version: "3.x"
27+
- uses: hynek/setup-cached-uv@v2
2528

26-
- run: python -Im pip install tox
27-
28-
- run: python -Im tox run -e docset
29+
- run: uvx --with=tox-uv tox run -e docset
2930

3031
- uses: actions/upload-artifact@v4
3132
with:

.github/workflows/ci.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ env:
1616

1717
permissions: {}
1818

19+
1920
jobs:
2021
build-package:
2122
name: Build & verify package
@@ -25,6 +26,7 @@ jobs:
2526
- uses: actions/checkout@v4
2627
with:
2728
fetch-depth: 0
29+
persist-credentials: false
2830

2931
- uses: hynek/build-and-inspect-python-package@v2
3032
id: baipp
@@ -59,8 +61,9 @@ jobs:
5961
- uses: hynek/setup-cached-uv@v2
6062

6163
- name: Prepare tox
64+
env:
65+
V: ${{ matrix.python-version }}
6266
run: |
63-
V=${{ matrix.python-version }}
6467
DO_MYPY=1
6568
6669
if [[ "$V" == "3.8" ]]; then
@@ -73,7 +76,7 @@ jobs:
7376
- run: >
7477
uvx --with=tox-uv
7578
tox run
76-
-e ${{ env.TOX_PYTHON }}-mypy
79+
-e $TOX_PYTHON-mypy
7780
if: env.DO_MYPY == '1'
7881
7982
- name: Remove src to ensure tests run against wheel
@@ -83,7 +86,7 @@ jobs:
8386
uvx --with=tox-uv
8487
tox run
8588
--installpkg dist/*.whl
86-
-e ${{ env.TOX_PYTHON }}-tests
89+
-e $TOX_PYTHON-tests
8790
8891
- name: Upload coverage data
8992
uses: actions/upload-artifact@v4
@@ -192,6 +195,8 @@ jobs:
192195
runs-on: ubuntu-latest
193196
steps:
194197
- uses: actions/checkout@v4
198+
with:
199+
persist-credentials: false
195200
- uses: actions/setup-python@v5
196201
with:
197202
python-version-file: .python-version-default
@@ -205,6 +210,8 @@ jobs:
205210

206211
steps:
207212
- uses: actions/checkout@v4
213+
with:
214+
persist-credentials: false
208215
- uses: actions/setup-python@v5
209216
with:
210217
python-version-file: .python-version-default

.github/workflows/codeql-analysis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ jobs:
2525
steps:
2626
- name: Checkout repository
2727
uses: actions/checkout@v4
28+
with:
29+
persist-credentials: false
2830

2931
- name: Initialize CodeQL
3032
uses: github/codeql-action/init@v3
3133
with:
3234
languages: ${{ matrix.language }}
3335

36+
- name: Autobuild
37+
uses: github/codeql-action/autobuild@v3
38+
3439
- name: Perform CodeQL Analysis
3540
uses: github/codeql-action/analyze@v3

.github/workflows/codspeed.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ jobs:
3131

3232
steps:
3333
- uses: actions/checkout@v4
34+
with:
35+
persist-credentials: false
3436
- uses: actions/setup-python@v5
3537
with:
3638
python-version-file: .python-version-default
37-
cache: pip
38-
- run: python -Im pip install tox-uv
39+
- uses: hynek/setup-cached-uv@v2
3940

4041
- name: Run CodSpeed benchmarks
4142
uses: CodSpeedHQ/action@v3
4243
with:
4344
token: ${{ secrets.CODSPEED_TOKEN }}
44-
run: tox run -e codspeed
45+
run: uvx --with tox-uv tox run -e codspeed

.github/workflows/pypi-package.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: Build & maybe upload PyPI package
2+
name: Build & upload PyPI package
33

44
on:
55
push:
@@ -10,26 +10,27 @@ on:
1010
- published
1111
workflow_dispatch:
1212

13-
permissions:
14-
attestations: write
15-
contents: read
16-
id-token: write
1713

1814
jobs:
1915
# Always build & lint package.
2016
build-package:
2117
name: Build & verify package
2218
runs-on: ubuntu-latest
19+
permissions:
20+
attestations: write
21+
id-token: write
2322

2423
steps:
2524
- uses: actions/checkout@v4
2625
with:
2726
fetch-depth: 0
27+
persist-credentials: false
2828

2929
- uses: hynek/build-and-inspect-python-package@v2
3030
with:
3131
attest-build-provenance-github: 'true'
3232

33+
3334
# Upload to Test PyPI on every commit on main.
3435
release-test-pypi:
3536
name: Publish in-dev package to test.pypi.org
@@ -38,6 +39,9 @@ jobs:
3839
runs-on: ubuntu-latest
3940
needs: build-package
4041

42+
permissions:
43+
id-token: write
44+
4145
steps:
4246
- name: Download packages built by build-and-inspect-python-package
4347
uses: actions/download-artifact@v4
@@ -51,6 +55,7 @@ jobs:
5155
attestations: true
5256
repository-url: https://test.pypi.org/legacy/
5357

58+
5459
# Upload to real PyPI on GitHub Releases.
5560
release-pypi:
5661
name: Publish released package to pypi.org
@@ -59,6 +64,9 @@ jobs:
5964
runs-on: ubuntu-latest
6065
needs: build-package
6166

67+
permissions:
68+
id-token: write
69+
6270
steps:
6371
- name: Download packages built by build-and-inspect-python-package
6472
uses: actions/download-artifact@v4

.github/workflows/zizmor.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# https://github.com/woodruffw/zizmor
2+
name: Zizmor
3+
4+
on:
5+
push:
6+
branches: ["main"]
7+
pull_request:
8+
branches: ["*"]
9+
10+
permissions:
11+
contents: read
12+
13+
14+
jobs:
15+
zizmor:
16+
name: Zizmor latest via Cargo
17+
runs-on: ubuntu-latest
18+
permissions:
19+
security-events: write
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
persist-credentials: false
25+
- name: Setup Rust
26+
uses: actions-rust-lang/setup-rust-toolchain@v1
27+
- name: Get zizmor
28+
run: cargo install zizmor
29+
- name: Run zizmor
30+
run: zizmor --format sarif . > results.sarif
31+
- name: Upload SARIF file
32+
uses: github/codeql-action/upload-sarif@v3
33+
with:
34+
# Path to SARIF file relative to the root of the repository
35+
sarif_file: results.sarif
36+
# Optional category for the results
37+
# Used to differentiate multiple results for one commit
38+
category: zizmor

0 commit comments

Comments
 (0)