Skip to content

Commit 75c7d1e

Browse files
authored
ci: add zizmor checks to lint github actions workflows (#215)
1 parent 4477151 commit 75c7d1e

9 files changed

Lines changed: 100 additions & 7 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ updates:
99
semver-patch-days: 7
1010
semver-minor-days: 14
1111
semver-major-days: 30
12+
default-days: 7
1213
commit-message:
1314
prefix: "chore"
1415
include: "scope"

‎.github/workflows/codeql.yml‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: "CodeQL Advanced"
22

3+
permissions:
4+
contents: read
5+
36
on:
47
push:
58
branches: [ "master" ]
@@ -9,13 +12,16 @@ on:
912
- cron: '36 16 * * 6'
1013
workflow_dispatch:
1114

15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
1219
jobs:
1320
analyze:
1421
name: Analyze (${{ matrix.language }})
1522
runs-on: ubuntu-26.04
1623
permissions:
17-
# required for all workflows
18-
security-events: write
24+
security-events: write # Required for CodeQL to upload results to GitHub Security and Quality tab
1925

2026
strategy:
2127
fail-fast: false
@@ -29,6 +35,8 @@ jobs:
2935
steps:
3036
- name: Checkout repository
3137
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # 7.0.0
38+
with:
39+
persist-credentials: false
3240

3341
# Initializes the CodeQL tools for scanning.
3442
- name: Initialize CodeQL

‎.github/workflows/test.yml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
branches: [ master ]
1111
workflow_dispatch:
1212

13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
1317
jobs:
1418
tests:
1519
timeout-minutes: 20
@@ -54,11 +58,13 @@ jobs:
5458
- name: Clone repository
5559
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # 7.0.0
5660
with:
57-
persist-credentials: true # Required for Codecov OIDC authentication
61+
persist-credentials: false
5862

5963
- name: Test with pytest
64+
env:
65+
PYTHON_VERSION: ${{ matrix.python-version }}
6066
run: |
61-
uv run --python ${{ matrix.python-version }} --group tests --locked pytest
67+
uv run --python "$PYTHON_VERSION" --group tests --locked pytest
6268
6369
- name: Upload coverage to Codecov
6470
if: matrix.os == 'ubuntu-26.04' && matrix.python-version == '3.14'

‎.github/workflows/zizmor.yml‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Zizmor
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
paths: [ '.github/workflows/**' ]
10+
pull_request:
11+
branches: [ master ]
12+
paths: [ '.github/workflows/**' ]
13+
workflow_dispatch:
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
zizmor:
21+
timeout-minutes: 10
22+
name: Lint GitHub Actions with zizmor
23+
runs-on: ubuntu-26.04
24+
steps:
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # 8.2.0
27+
28+
- name: Clone repository
29+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # 7.0.0
30+
with:
31+
persist-credentials: false
32+
33+
- name: Run zizmor
34+
run: |
35+
make zizmor-check

‎.pre-commit-config.yaml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ repos:
1616
- id: mypy
1717
args: [--config-file=pyproject.toml]
1818

19+
# zizmor for github actions linting
20+
- repo: https://github.com/zizmorcore/zizmor-pre-commit
21+
rev: v1.26.1 # Keep in sync zizmor version with pyproject.toml
22+
hooks:
23+
- id: zizmor
24+
args: [--no-progress, --fix, --persona=auditor]
25+
1926
# Standard pre-commit hooks
2027
- repo: https://github.com/pre-commit/pre-commit-hooks
2128
rev: v6.0.0

‎Makefile‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
.PHONY: default install format fix ruff-check mypy-check check benchmark-test integration-test property-test unit-test test doc publish clean
1+
.PHONY: default install format fix ruff-check mypy-check zizmor-check check benchmark-test integration-test property-test unit-test test doc publish clean
22

33
UV := $(shell command -v uv 2>/dev/null || true)
44
ifeq ($(UV),)
55
$(warning uv not found. Install uv (curl -LsSf https://astral.sh/uv/install.sh | sh) to use Makefile targets)
66
endif
77

88
default:
9-
@echo "Usage: make [install|format|fix|ruff-check|mypy-check|check|benchmark-test|integration-test|property-test|unit-test|test|doc|publish|clean]"
9+
@echo "Usage: make [install|format|fix|ruff-check|mypy-check|zizmor-check|check|benchmark-test|integration-test|property-test|unit-test|test|doc|publish|clean]"
1010
@exit 1
1111

1212
install:
@@ -17,6 +17,7 @@ format:
1717

1818
fix:
1919
uv run --group quality --locked ruff check --fix
20+
uv run --group quality --locked zizmor --collect=all --no-progress --fix --persona=auditor .
2021

2122
ruff-check:
2223
uv run --group quality --locked ruff check
@@ -25,9 +26,13 @@ ruff-check:
2526
mypy-check:
2627
uv run --group tests --group types --group quality --locked mypy
2728

29+
zizmor-check:
30+
uv run --group quality --locked zizmor --collect=all --no-progress --persona=auditor .
31+
2832
check:
2933
make ruff-check
3034
make mypy-check
35+
make zizmor-check
3136

3237
benchmark-test:
3338
uv run --group tests --locked pytest -m perf

‎make.bat‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ if "%1"=="format" goto format
1212
if "%1"=="fix" goto fix
1313
if "%1"=="ruff-check" goto ruff-check
1414
if "%1"=="mypy-check" goto mypy-check
15+
if "%1"=="zizmor-check" goto zizmor-check
1516
if "%1"=="check" goto check
1617
if "%1"=="benchmark-test" goto benchmark-test
1718
if "%1"=="integration-test" goto integration-test
@@ -22,7 +23,7 @@ if "%1"=="doc" goto doc
2223
if "%1"=="publish" goto publish
2324
if "%1"=="clean" goto clean
2425

25-
echo Usage: make.bat [install^|format^|fix^|ruff-check^|mypy-check^|check^|benchmark-test^|integration-test^|property-test^|unit-test^|test^|doc^|publish^|clean]
26+
echo Usage: make.bat [install^|format^|fix^|ruff-check^|mypy-check^|zizmor-check^|check^|benchmark-test^|integration-test^|property-test^|unit-test^|test^|doc^|publish^|clean]
2627
exit /b 1
2728

2829
:install
@@ -35,6 +36,8 @@ exit /b %errorlevel%
3536

3637
:fix
3738
uv run --group quality --locked ruff check --fix
39+
if errorlevel 1 exit /b %errorlevel%
40+
uv run --group quality --locked zizmor --collect=all --no-progress --fix --persona=auditor .
3841
exit /b %errorlevel%
3942

4043
:ruff-check
@@ -48,10 +51,16 @@ exit /b %errorlevel%
4851
uv run --group tests --group types --group quality --locked mypy
4952
exit /b %errorlevel%
5053

54+
:zizmor-check
55+
uv run --group quality --locked zizmor --collect=all --no-progress --persona=auditor .
56+
exit /b %errorlevel%
57+
5158
:check
5259
call :ruff-check
5360
if errorlevel 1 exit /b %errorlevel%
5461
call :mypy-check
62+
if errorlevel 1 exit /b %errorlevel%
63+
call :zizmor-check
5564
exit /b %errorlevel%
5665

5766
:benchmark-test

‎pyproject.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ quality = [
6464
"mypy==2.1.0",
6565
# Keep in sync ruff version with .pre-commit-config.yaml
6666
"ruff==0.15.16",
67+
# Keep in sync zizmor version with .pre-commit-config.yaml
68+
"zizmor==1.26.1"
6769
]
6870

6971

‎uv.lock‎

Lines changed: 20 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)