Skip to content

Commit f29a035

Browse files
Add zizmor and harden GitHub Actions workflows
1 parent 3cdd0a5 commit f29a035

9 files changed

Lines changed: 88 additions & 19 deletions

File tree

.github/workflows/docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
env:
1111
FORCE_COLOR: 1
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
1417
Docs:
1518
uses: tskit-dev/.github/.github/workflows/docs.yml@v17

.github/workflows/lint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
pull_request:
55
merge_group:
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
Lint:
912
uses: tskit-dev/.github/.github/workflows/lint.yml@v17

.github/workflows/release-c.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,24 @@ on:
88
env:
99
FORCE_COLOR: 1
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
build:
1316
runs-on: ubuntu-24.04
17+
permissions:
18+
contents: write
1419
steps:
1520
- name: Checkout
16-
uses: actions/checkout@v6.0.2
21+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
22+
with:
23+
persist-credentials: false
1724
- name: Install uv
18-
uses: astral-sh/setup-uv@v6
25+
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
1926
with:
2027
version: "0.10.0"
28+
enable-cache: false
2129
- name: Install system deps
2230
run: |
2331
sudo apt-get update
@@ -34,7 +42,7 @@ jobs:
3442
meson c build-gcc
3543
meson dist -C build-gcc
3644
- name: C Release
37-
uses: softprops/action-gh-release@v2.5.0
45+
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3.0.1 # zizmor: ignore[superfluous-actions] intentionally use the maintained release action rather than a bespoke gh release script
3846
if: startsWith(github.ref, 'refs/tags/') && contains(github.event.ref, 'C_')
3947
with:
4048
draft: True

.github/workflows/tests.yml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
env:
1010
FORCE_COLOR: 1
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316

1417
packaging:
@@ -23,15 +26,15 @@ jobs:
2326
uses: tskit-dev/.github/.github/workflows/c-tests.yml@v17
2427
with:
2528
library-directory: c
26-
secrets: inherit
29+
secrets: inherit # zizmor: ignore[secrets-inherit] trusted first-party tskit-dev reusable workflow; needs CODECOV_TOKEN
2730

2831
test-python-c:
2932
name: Python-C tests
3033
uses: tskit-dev/.github/.github/workflows/python-c-tests.yml@v17
3134
with:
3235
tests: python/tests/test_python_c.py python/tests/test_dict_encoding.py
3336
pyproject-directory: python
34-
secrets: inherit
37+
secrets: inherit # zizmor: ignore[secrets-inherit] trusted first-party tskit-dev reusable workflow; needs CODECOV_TOKEN
3538

3639

3740
test:
@@ -42,7 +45,7 @@ jobs:
4245
python-version: ${{ matrix.python }}
4346
pyproject-directory: python
4447
coverage-directory: python/tskit
45-
secrets: inherit
48+
secrets: inherit # zizmor: ignore[secrets-inherit] trusted first-party tskit-dev reusable workflow; needs CODECOV_TOKEN
4649
strategy:
4750
matrix:
4851
python: [ 3.11, 3.13 ]
@@ -62,15 +65,17 @@ jobs:
6265
shell: msys2 {0}
6366
steps:
6467
- name: Cancel Previous Runs
65-
uses: styfle/cancel-workflow-action@0.13.0
68+
uses: styfle/cancel-workflow-action@d07a454dad7609a92316b57b23c9ccfd4f59af66 # 0.13.1
6669
with:
6770
access_token: ${{ github.token }}
6871

6972
- name: 'Checkout'
70-
uses: actions/checkout@v6.0.2
73+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
74+
with:
75+
persist-credentials: false
7176

7277
- name: Setup MSYS2 ${{matrix.sys}}
73-
uses: msys2/setup-msys2@v2.27.0
78+
uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2.32.0
7479
with:
7580
msystem: ${{matrix.sys}}
7681
update: true
@@ -98,17 +103,18 @@ jobs:
98103

99104
steps:
100105
- name: Cancel Previous Runs
101-
uses: styfle/cancel-workflow-action@0.13.0
106+
uses: styfle/cancel-workflow-action@d07a454dad7609a92316b57b23c9ccfd4f59af66 # 0.13.1
102107
with:
103108
access_token: ${{ github.token }}
104109

105110
- name: Checkout
106-
uses: actions/checkout@v6.0.2
111+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
107112
with:
108113
submodules: true
114+
persist-credentials: false
109115

110116
- name: Install uv and set the python version
111-
uses: astral-sh/setup-uv@v6
117+
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
112118
with:
113119
python-version: 3.11
114120
version: "0.10.0"
@@ -132,7 +138,7 @@ jobs:
132138
python/tests/test_jit.py
133139
134140
- name: Upload coverage to Codecov
135-
uses: codecov/codecov-action@v7.0.0
141+
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
136142
with:
137143
token: ${{ secrets.CODECOV_TOKEN }}
138144
fail_ci_if_error: true
@@ -158,22 +164,23 @@ jobs:
158164

159165
steps:
160166
- name: Cancel Previous Runs
161-
uses: styfle/cancel-workflow-action@0.13.0
167+
uses: styfle/cancel-workflow-action@d07a454dad7609a92316b57b23c9ccfd4f59af66 # 0.13.1
162168
with:
163169
access_token: ${{ github.token }}
164170

165171
- name: Checkout
166-
uses: actions/checkout@v6.0.2
172+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
167173
with:
168174
submodules: true
175+
persist-credentials: false
169176

170177
- name: Install system deps
171178
run: |
172179
sudo apt-get update
173180
sudo apt-get install -y libcunit1-dev ninja-build clang
174181
175182
- name: Install uv
176-
uses: astral-sh/setup-uv@v6
183+
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
177184
with:
178185
version: "0.10.0"
179186

.github/workflows/wheels.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
release:
77
types: [published]
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
build-wheels:
1114
if: "!startsWith(github.ref, 'refs/tags/C_')"
@@ -21,7 +24,7 @@ jobs:
2124
id-token: write
2225
steps:
2326
- name: Download artifacts
24-
uses: actions/download-artifact@v7.0.0
27+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
2528
with:
2629
pattern: build-*
2730
path: dist
@@ -32,11 +35,11 @@ jobs:
3235

3336
- name: Publish distribution to Test PyPI
3437
if: github.event_name == 'push' && github.ref_name == 'test-publish'
35-
uses: pypa/gh-action-pypi-publish@v1.13.0
38+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
3639
with:
3740
repository-url: https://test.pypi.org/legacy/
3841
verbose: true
3942

4043
- name: Publish distribution to Production PyPI
4144
if: github.event_name == 'release'
42-
uses: pypa/gh-action-pypi-publish@v1.13.0
45+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0

.github/zizmor.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# zizmor configuration for tskit-dev repos.
2+
# Third-party actions must be hash-pinned; first-party tskit-dev reusable
3+
# workflows are trusted and may stay pinned to a version tag (e.g. @v17).
4+
rules:
5+
unpinned-uses:
6+
config:
7+
policies:
8+
tskit-dev/*: ref-pin
9+
"*": hash-pin

prek.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,16 @@ hooks = [
5353
verbose = true,
5454
},
5555
]
56+
57+
[[repos]]
58+
repo = "local"
59+
hooks = [
60+
{
61+
id = "zizmor",
62+
name = "zizmor",
63+
language = "system",
64+
entry = "uv run --project=python --only-group=lint zizmor",
65+
files = "^\\.github/workflows/.*\\.ya?ml$",
66+
pass_filenames = true,
67+
},
68+
]

python/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ lint = [
114114
"clang-format==21.1.8",
115115
"ruff==0.15.1",
116116
"prek==0.3.3",
117+
"zizmor==1.26.1",
117118
]
118119

119120
dev = [

python/uv.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)