Skip to content

Commit

Permalink
ci: add zizmor pre-commit hook and fix issues (#9895)
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering authored Dec 9, 2024
1 parent a3cae0c commit efed736
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 4 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/.tests-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
if: inputs.run-mypy
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
persist-credentials: false

- uses: ./.github/actions/bootstrap-poetry
id: bootstrap-poetry
Expand All @@ -56,6 +58,8 @@ jobs:
if: inputs.run-pytest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
persist-credentials: false

- uses: ./.github/actions/bootstrap-poetry
with:
Expand All @@ -79,6 +83,7 @@ jobs:
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
persist-credentials: false
path: poetry

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

# This step can be removed after having released a poetry-plugin-export version
# that has cffi>=1.17.0 in its lock file.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/backport.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Backport

on:
pull_request_target:
pull_request_target: # zizmor: ignore[dangerous-triggers]
types:
- closed
- labeled
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
# allow repository maintainers to modify and test workflow
paths:
- ".github/workflows/docs.yaml"
pull_request_target:
pull_request_target: # zizmor: ignore[dangerous-triggers]
# enable runs for this workflow when labeled as documentation only
# prevent execution when the workflow itself is modified from a fork
types:
Expand All @@ -27,19 +27,22 @@ jobs:
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
persist-credentials: false
repository: python-poetry/website

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

# only checkout docs from pull_request.head to not use something else by accident
# for pull_request_target trigger (security)
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
persist-credentials: false
path: poetry-docs
ref: ${{ github.event.pull_request.head.sha }}
sparse-checkout: docs
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
persist-credentials: false

- run: pipx run build

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

- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: distfiles
path: dist/

- run: gh release upload ${{ github.event.release.tag_name }} dist/*.{tar.gz,whl}
- run: gh release upload "${TAG_NAME}" dist/*.{tar.gz,whl}
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.event.release.tag_name }}

upload-pypi:
name: Upload (PyPI)
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
tests: ${{ steps.changes.outputs.tests }}
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
persist-credentials: false

- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changes
Expand Down Expand Up @@ -55,6 +57,8 @@ jobs:
needs: changes
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
persist-credentials: false

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

Expand All @@ -67,6 +71,8 @@ jobs:
needs: lockfile
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
persist-credentials: false

- run: pipx run build

Expand All @@ -86,6 +92,8 @@ jobs:
needs: changes
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
persist-credentials: false

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

Expand Down
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ repos:
hooks:
- id: ruff
- id: ruff-format

- repo: https://github.com/woodruffw/zizmor-pre-commit
rev: v0.8.0
hooks:
- id: zizmor
# types and files can be removed with https://github.com/woodruffw/zizmor-pre-commit/pull/2
types: [yaml]
files: \.github/workflows/.*$

0 comments on commit efed736

Please sign in to comment.