Skip to content

Commit de5d23c

Browse files
authored
ci: Add zizmor pre-commit hook (#311)
* ci: Add zizmor pre-commit hook Even though it's pretty new, zizmor has already established itself as a very potent static analysis tool for GitHub Actions. Let's give it a go to see what it has to say on our current CI. * Address zizmor findings No persisting credentials, and the test and docs jobs in the test workflow each get job-scoped content writing permissions. mike creates an automated commit on release/main push, so it does need credentials - those are then explicitly set. Fixes the mike action by putting inputs as environment variables. The alias is explicitly not quoted, since otherwise mike would pick it up, and it cannot deal with an empty string alias.
1 parent b00c33e commit de5d23c

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

.github/actions/mike-docs/action.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ runs:
2626
shell: bash
2727
- env:
2828
DOCS_PRERELEASE: ${{ inputs.pre_release }}
29+
INPUTS_PUSH: ${{ inputs.push }}
30+
INPUTS_VERSION: ${{ inputs.version }}
31+
INPUTS_ALIAS: ${{ inputs.alias }}
2932
run: |
3033
MIKE_OPTIONS=( "--update-aliases" )
31-
if [ "true" = "${{ inputs.push }}" ]; then
34+
if [ "true" = "${INPUTS_PUSH}" ]; then
3235
MIKE_OPTIONS+=( "--push" )
3336
fi
34-
uv run mike deploy ${{ inputs.version }} ${{ inputs.alias }} "${MIKE_OPTIONS[@]}"
37+
uv run mike deploy "${INPUTS_VERSION}" ${INPUTS_ALIAS} "${MIKE_OPTIONS[@]}"
3538
shell: bash

.github/workflows/python.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,23 @@ on:
88
branches:
99
- main
1010

11-
permissions:
12-
contents: write
13-
1411
jobs:
1512
lint:
1613
name: Run code checks and formatting hooks
1714
runs-on: ubuntu-latest
1815
steps:
1916
- uses: actions/checkout@v4
17+
with:
18+
persist-credentials: false
2019
- name: Set up Python 3.10 and dependencies
2120
uses: ./.github/actions/python-deps
2221
with:
2322
pythonVersion: "3.10"
2423
- name: Run pre-commit checks
2524
run: uv run pre-commit run --all-files --verbose --show-diff-on-failure
2625
test:
26+
permissions:
27+
contents: write
2728
strategy:
2829
fail-fast: false
2930
matrix:
@@ -52,6 +53,8 @@ jobs:
5253
LAKEFS_BLOCKSTORE_TYPE: "local"
5354
steps:
5455
- uses: actions/checkout@v4
56+
with:
57+
persist-credentials: false
5558
- name: Install uv
5659
uses: astral-sh/setup-uv@v5
5760
with:
@@ -73,6 +76,8 @@ jobs:
7376
docs:
7477
name: Build documentation for lakefs-spec
7578
runs-on: ubuntu-latest
79+
permissions:
80+
contents: write
7681
services:
7782
lakefs:
7883
image: treeverse/lakefs:latest
@@ -89,6 +94,7 @@ jobs:
8994
- uses: actions/checkout@v4
9095
with:
9196
fetch-depth: 0
97+
persist-credentials: true
9298
- name: Set up Python 3.11 and dependencies
9399
uses: ./.github/actions/python-deps
94100
with:

.github/workflows/release.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
uses: actions/checkout@v4
2828
with:
2929
fetch-depth: 0 # for documentation builds
30+
persist-credentials: true
3031
- name: Set up Python and dependencies
3132
uses: ./.github/actions/python-deps
3233
with:

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
types_or: [python, pyi]
1818
args: [--ignore-missing-imports, --scripts-are-modules]
1919
- repo: https://github.com/astral-sh/ruff-pre-commit
20-
rev: v0.8.6
20+
rev: v0.9.0
2121
hooks:
2222
- id: ruff
2323
args: [--fix, --exit-non-zero-on-fix]
@@ -35,3 +35,8 @@ repos:
3535
hooks:
3636
- id: uv-lock
3737
name: Lock project dependencies
38+
- repo: https://github.com/woodruffw/zizmor-pre-commit
39+
rev: v1.0.1
40+
hooks:
41+
- id: zizmor
42+
args: [--min-severity=medium]

0 commit comments

Comments
 (0)