Skip to content

Commit efed736

Browse files
authored
ci: add zizmor pre-commit hook and fix issues (#9895)
1 parent a3cae0c commit efed736

File tree

6 files changed

+36
-4
lines changed

6 files changed

+36
-4
lines changed

.github/workflows/.tests-matrix.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ jobs:
3232
if: inputs.run-mypy
3333
steps:
3434
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
35+
with:
36+
persist-credentials: false
3537

3638
- uses: ./.github/actions/bootstrap-poetry
3739
id: bootstrap-poetry
@@ -56,6 +58,8 @@ jobs:
5658
if: inputs.run-pytest
5759
steps:
5860
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
61+
with:
62+
persist-credentials: false
5963

6064
- uses: ./.github/actions/bootstrap-poetry
6165
with:
@@ -79,6 +83,7 @@ jobs:
7983
steps:
8084
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
8185
with:
86+
persist-credentials: false
8287
path: poetry
8388

8489
- uses: ./poetry/.github/actions/bootstrap-poetry
@@ -95,6 +100,7 @@ jobs:
95100
- name: Check out poetry-plugin-export
96101
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
97102
with:
103+
persist-credentials: false
98104
path: poetry-plugin-export
99105
repository: python-poetry/poetry-plugin-export
100106
ref: refs/tags/${{ steps.poetry-plugin-export-version.outputs.version }}
@@ -104,8 +110,10 @@ jobs:
104110
# Replace the python version to avoid conflicts
105111
# if the plugin still supports a wider range than Poetry itself.
106112
run: |
107-
perl -pi -e 's/^python =.*$/python = "~${{ inputs.python-version }}"/' pyproject.toml
113+
perl -pi -e 's/^python =.*$/python = "~'"${PYTHON_VERSION}"'"/' pyproject.toml
108114
poetry add --lock --group dev ../poetry
115+
env:
116+
PYTHON_VERSION: ${{ inputs.python-version }}
109117

110118
# This step can be removed after having released a poetry-plugin-export version
111119
# that has cffi>=1.17.0 in its lock file.

.github/workflows/backport.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Backport
22

33
on:
4-
pull_request_target:
4+
pull_request_target: # zizmor: ignore[dangerous-triggers]
55
types:
66
- closed
77
- labeled

.github/workflows/docs.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
# allow repository maintainers to modify and test workflow
66
paths:
77
- ".github/workflows/docs.yaml"
8-
pull_request_target:
8+
pull_request_target: # zizmor: ignore[dangerous-triggers]
99
# enable runs for this workflow when labeled as documentation only
1010
# prevent execution when the workflow itself is modified from a fork
1111
types:
@@ -27,19 +27,22 @@ jobs:
2727
steps:
2828
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
2929
with:
30+
persist-credentials: false
3031
repository: python-poetry/website
3132

3233
# use .github from pull request target instead of pull_request.head
3334
# for pull_request_target trigger to avoid arbitrary code execution
3435
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
3536
with:
37+
persist-credentials: false
3638
path: poetry-github
3739
sparse-checkout: .github
3840

3941
# only checkout docs from pull_request.head to not use something else by accident
4042
# for pull_request_target trigger (security)
4143
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
4244
with:
45+
persist-credentials: false
4346
path: poetry-docs
4447
ref: ${{ github.event.pull_request.head.sha }}
4548
sparse-checkout: docs

.github/workflows/release.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
13+
with:
14+
persist-credentials: false
1315

1416
- run: pipx run build
1517

@@ -28,15 +30,18 @@ jobs:
2830
steps:
2931
# We need to be in a git repo for gh to work.
3032
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
33+
with:
34+
persist-credentials: false
3135

3236
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
3337
with:
3438
name: distfiles
3539
path: dist/
3640

37-
- run: gh release upload ${{ github.event.release.tag_name }} dist/*.{tar.gz,whl}
41+
- run: gh release upload "${TAG_NAME}" dist/*.{tar.gz,whl}
3842
env:
3943
GH_TOKEN: ${{ github.token }}
44+
TAG_NAME: ${{ github.event.release.tag_name }}
4045

4146
upload-pypi:
4247
name: Upload (PyPI)

.github/workflows/tests.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
tests: ${{ steps.changes.outputs.tests }}
2525
steps:
2626
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
27+
with:
28+
persist-credentials: false
2729

2830
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
2931
id: changes
@@ -55,6 +57,8 @@ jobs:
5557
needs: changes
5658
steps:
5759
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
60+
with:
61+
persist-credentials: false
5862

5963
- uses: ./.github/actions/bootstrap-poetry
6064

@@ -67,6 +71,8 @@ jobs:
6771
needs: lockfile
6872
steps:
6973
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
74+
with:
75+
persist-credentials: false
7076

7177
- run: pipx run build
7278

@@ -86,6 +92,8 @@ jobs:
8692
needs: changes
8793
steps:
8894
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
95+
with:
96+
persist-credentials: false
8997

9098
- uses: ./.github/actions/bootstrap-poetry
9199

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,11 @@ repos:
3131
hooks:
3232
- id: ruff
3333
- id: ruff-format
34+
35+
- repo: https://github.com/woodruffw/zizmor-pre-commit
36+
rev: v0.8.0
37+
hooks:
38+
- id: zizmor
39+
# types and files can be removed with https://github.com/woodruffw/zizmor-pre-commit/pull/2
40+
types: [yaml]
41+
files: \.github/workflows/.*$

0 commit comments

Comments
 (0)