Skip to content

Commit 1b07635

Browse files
Add zizmor GitHub workflow linter (#798)
* Add zizmor GitHub workflow linter and resolve audits * Fix missing permissions in CI workflow * Fix missing set pipefail & `needs` for CI job Suggested by GitHub copilot * Fix incorrect job name to wait for * Fix missing CI pr-auto-updater permissions
1 parent 0175a0f commit 1b07635

9 files changed

Lines changed: 164 additions & 60 deletions

.github/actionlint.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
paths:
2+
.github/workflows/**/*.{yml,yaml}:
3+
ignore:
4+
- missing input "app-id" which is required by action "actions/create-github-app-token@
5+
- input "client-id" is not defined in action "actions/create-github-app-token@

.github/workflows/autofix-pre-commit.yaml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ name: autofix.ci
1010
required: false
1111
type: boolean
1212

13+
concurrency: # yamllint disable-line rule:key-ordering
14+
cancel-in-progress: true
15+
group: autofix-pre-commit-${{github.event.pull_request.number||github.ref}}
16+
1317
permissions:
1418
contents: read
1519

@@ -19,19 +23,22 @@ jobs:
1923
UV_FROZEN: true
2024
UV_NO_SYNC: true
2125
UV_PYTHON_DOWNLOADS: never
26+
name: Run pre-commit hooks and commit any auto-fixes
2227
runs-on: ubuntu-latest
2328

2429
steps:
2530
- uses: actions/checkout@v7
31+
with:
32+
persist-credentials: false
2633

27-
- name: Add GB Locale
34+
- name: Add GB locale
2835
run: |
2936
sudo apt-get update
3037
sudo apt-get install -y locales
3138
sudo locale-gen en_GB.UTF-8
3239
shell: bash
3340

34-
- name: Set Up Python
41+
- name: Set up Python
3542
uses: actions/setup-python@v6
3643
with:
3744
python-version-file: .python-version
@@ -41,11 +48,11 @@ jobs:
4148
with:
4249
enable-cache: true
4350

44-
- name: Install prek From Locked Dependencies
51+
- name: Install prek from locked dependencies
4552
run: uv sync --only-group pre-commit
4653

4754
- id: store-hashed-python-version
48-
name: Store Hashed Python Version
55+
name: Store hashed Python version
4956
run: echo "hashed_python_version=$(uv run -- python -VV | sha256sum | cut -d' ' -f1)"
5057
>> "$GITHUB_OUTPUT"
5158

@@ -54,19 +61,25 @@ jobs:
5461
key: prek|${{steps.store-hashed-python-version.outputs.hashed_python_version}}|${{hashFiles('.pre-commit-config.yaml')}}
5562
path: ~/.cache/prek
5663

57-
- name: Setup pre-commit Environments
64+
- name: Setup pre-commit environments
5865
run: uv run -- prek install-hooks
5966

6067
- name: Run prek
61-
run: |
68+
env: # yamllint disable-line rule:key-ordering
69+
CURRENT_BRANCH_NAME: ${{github.ref_name}}
70+
DEFAULT_BRANCH_NAME: ${{github.event.repository.default_branch}}
71+
run: | # zizmor: ignore[template-injection]
6272
set -o pipefail
63-
if [[ "${{github.event_name}}" == "push" && "${{github.ref_name}}" == "${{github.event.repository.default_branch}}" ]]; then
64-
uv run -- prek run --all-files --hook-stage manual --color never --skip ruff-check --skip uv-lock --skip gitlint-ci | tee /tmp/prek.log
73+
74+
if [ "${{github.event_name}}" == "push" ] && [ "${CURRENT_BRANCH_NAME}" == "${DEFAULT_BRANCH_NAME}" ]; then
75+
ARGS=("--skip" "gitlint-ci")
6576
else
66-
uv run -- prek run --all-files --hook-stage manual --color never --skip ruff-check --skip uv-lock | tee /tmp/prek.log
77+
ARGS=()
6778
fi
6879
69-
- name: Ensure No Warnings
80+
uv run -- prek run --all-files --hook-stage manual --color never --skip ruff-check --skip uv-lock "${ARGS[@]}" | tee /tmp/prek.log
81+
82+
- name: Ensure no warnings
7083
run: "if grep -q '^warning: ' /tmp/prek.log; then exit 1; fi"
7184

7285
- if: "!cancelled() && inputs.skip-autofix != true"

0 commit comments

Comments
 (0)