Skip to content

Commit eda5c0e

Browse files
authored
feat: add zizmor (#6957)
Support linting GitHub Actions files with Zizmor Close #6740
1 parent 95bb9b6 commit eda5c0e

30 files changed

+181
-60
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ updates:
9797
# We can group all Docker dependencies because they are isolated from
9898
# each other
9999
patterns:
100+
- aquasecurity/trivy
100101
- alpine/helm
101102
- alpine/terragrunt
102103
- dotenvlinter/dotenv-linter
@@ -157,6 +158,7 @@ updates:
157158
- snakemake
158159
- sqlfluff
159160
- yamllint
161+
- zizmor
160162

161163
- package-ecosystem: "gradle"
162164
commit-message:

.github/linters/.jscpd.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"**/test/linters/dotnet_sln_format_analyzers",
1515
"**/test/linters/dotnet_sln_format_style",
1616
"**/test/linters/dotnet_sln_format_whitespace",
17+
"**/test/linters/github_actions",
18+
"**/test/linters/github_actions_zizmor",
1719
"**/test/linters/go_modules",
1820
"**/test/linters/html",
1921
"**/test/linters/javascript_es",

.github/linters/zizmor.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
rules:
3+
unpinned-uses:
4+
ignore:
5+
- ci.yml
6+
- cd.yml
7+
- dependabot-automation.yaml
8+
- lint-commit.yaml
9+
- stale.yaml
10+
- thank_contributors.yaml

.github/workflows/cd.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838
steps:
3939
- name: Checkout Code
4040
uses: actions/checkout@v5
41+
with:
42+
persist-credentials: false
4143

4244
- name: Set up Docker Buildx
4345
uses: docker/setup-buildx-action@v3
@@ -115,6 +117,7 @@ jobs:
115117
uses: actions/checkout@v5
116118
with:
117119
fetch-depth: 0
120+
persist-credentials: false
118121

119122
- name: Set build metadata
120123
run: |
@@ -276,7 +279,7 @@ jobs:
276279
if: steps.release.outputs.release_created
277280
# shellcheck disable=SC2062
278281
run: |
279-
RELEASE_VERSION="${{ steps.release.outputs.tag_name }}"
282+
RELEASE_VERSION="${STEPS_RELEASE_OUTPUTS_TAG_NAME}"
280283
281284
if [ -z "${RELEASE_VERSION}" ]; then
282285
echo "Error RELEASE_VERSION is empty. Exiting..."
@@ -288,12 +291,15 @@ jobs:
288291
exit 2
289292
fi
290293
291-
SEMVER_MAJOR_VERSION=v${{ steps.release.outputs.major }}
294+
SEMVER_MAJOR_VERSION=v${STEPS_RELEASE_OUTPUTS_MAJOR}
292295
293296
{
294297
echo "RELEASE_VERSION=${RELEASE_VERSION}"
295298
echo "SEMVER_MAJOR_VERSION=${SEMVER_MAJOR_VERSION}"
296299
} >> "${GITHUB_ENV}"
300+
env:
301+
STEPS_RELEASE_OUTPUTS_TAG_NAME: ${{ steps.release.outputs.tag_name }}
302+
STEPS_RELEASE_OUTPUTS_MAJOR: ${{ steps.release.outputs.major }}
297303

298304
- name: Login to GHCR
299305
if: steps.release.outputs.release_created
@@ -326,6 +332,8 @@ jobs:
326332
- uses: actions/checkout@v5
327333
with:
328334
fetch-depth: 0
335+
# Persist credentials because we update Git tags
336+
persist-credentials: true
329337

330338
# No need to tag major.minor.patch because that tag is automatically created when creating the release
331339
- name: Tag major, minor, and latest versions
@@ -334,10 +342,10 @@ jobs:
334342
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
335343
git config user.name "github-actions[bot]"
336344
337-
git tag --annotate --force ${{ env.SEMVER_MAJOR_VERSION }} -m "Release ${{ env.SEMVER_MAJOR_VERSION }}"
338-
git tag --annotate --force latest -m "Release latest (${{ env.RELEASE_VERSION }})"
345+
git tag --annotate --force "${SEMVER_MAJOR_VERSION}" -m "Release ${SEMVER_MAJOR_VERSION}"
346+
git tag --annotate --force latest -m "Release latest (${RELEASE_VERSION})"
339347
340-
git push --force origin ${{ env.SEMVER_MAJOR_VERSION }}
348+
git push --force origin "${SEMVER_MAJOR_VERSION}"
341349
git push --force origin latest
342350
343351
- name: Create Issue on Failure

.github/workflows/ci.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
uses: actions/checkout@v5
3030
with:
3131
fetch-depth: 0
32+
persist-credentials: false
3233

3334
- name: Set build metadata
3435
id: set-container-image-build-metadata
@@ -102,6 +103,8 @@ jobs:
102103
steps:
103104
- name: Checkout Code
104105
uses: actions/checkout@v5
106+
with:
107+
persist-credentials: false
105108

106109
- name: Set up Docker Buildx
107110
uses: docker/setup-buildx-action@v3
@@ -158,6 +161,7 @@ jobs:
158161
uses: actions/checkout@v5
159162
with:
160163
fetch-depth: 0
164+
persist-credentials: false
161165

162166
- name: Free Disk space
163167
shell: bash
@@ -202,7 +206,7 @@ jobs:
202206
# Ref: https://github.com/moby/buildkit/issues/1555
203207
- name: Load image
204208
run: |
205-
docker load <"/tmp/${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }}.tar"
209+
docker load <"/tmp/${CONTAINER_IMAGE_OUTPUT_IMAGE_NAME}.tar"
206210
207211
- name: Print environment info
208212
run: |
@@ -238,6 +242,7 @@ jobs:
238242
uses: actions/checkout@v5
239243
with:
240244
fetch-depth: 0
245+
persist-credentials: false
241246

242247
- name: Download ${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }} container image
243248
uses: actions/[email protected]
@@ -247,7 +252,7 @@ jobs:
247252

248253
- name: Load ${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }} container image
249254
run: |
250-
docker load --input /tmp/${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }}.tar
255+
docker load --input "/tmp/${CONTAINER_IMAGE_OUTPUT_IMAGE_NAME}.tar"
251256
docker image ls -a
252257
253258
- name: Update action.yml
@@ -293,6 +298,7 @@ jobs:
293298
uses: actions/checkout@v5
294299
with:
295300
fetch-depth: 0
301+
persist-credentials: false
296302
- name: Generate test cases matrix
297303
id: generate-matrix
298304
run: |
@@ -338,6 +344,7 @@ jobs:
338344
uses: actions/checkout@v5
339345
with:
340346
fetch-depth: 0
347+
persist-credentials: false
341348

342349
- name: Download ${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }} container image
343350
uses: actions/[email protected]
@@ -347,15 +354,16 @@ jobs:
347354

348355
- name: Load ${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }} container image
349356
run: |
350-
docker load --input /tmp/${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }}.tar
357+
docker load --input "/tmp/${CONTAINER_IMAGE_OUTPUT_IMAGE_NAME}.tar"
351358
docker image ls -a
352359
353360
- name: "Test case: ${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }} - ${{ matrix.test-case }}"
354361
run: |
355-
echo "Running: ${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }} - ${{ matrix.test-case }}"
356-
make ${{ matrix.test-case }}
362+
echo "Running: ${CONTAINER_IMAGE_OUTPUT_IMAGE_NAME} - ${MATRIX_TEST_CASE}"
363+
make "${MATRIX_TEST_CASE}"
357364
env:
358365
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
366+
MATRIX_TEST_CASE: ${{ matrix.test-case }}
359367

360368
# The purpose of this job is to run only when the run-test-suite job runs to completion.
361369
# We can use this job as a required status check in a branch protection rule without
@@ -386,6 +394,7 @@ jobs:
386394
- uses: actions/checkout@v5
387395
with:
388396
fetch-depth: 0
397+
persist-credentials: false
389398

390399
- name: Setup authentication token
391400
run: |

.github/workflows/dependabot-automation.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
PR_URL: ${{github.event.pull_request.html_url}}
1818
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
1919
runs-on: ubuntu-latest
20-
if: github.actor == 'dependabot[bot]'
20+
if: github.event.pull_request.user.login == 'dependabot[bot]'
2121
steps:
2222
- name: Fetch Dependabot metadata
2323
id: metadata

.github/workflows/lint-commit.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- uses: actions/checkout@v5
1919
with:
2020
fetch-depth: 0
21+
persist-credentials: false
2122

2223
- name: Check if the pull request contains a single commit
2324
if: github.event_name == 'pull_request'

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ ENV PATH="${PATH}:/venvs/snakemake/bin"
460460
ENV PATH="${PATH}:/venvs/sqlfluff/bin"
461461
ENV PATH="${PATH}:/venvs/yamllint/bin"
462462
ENV PATH="${PATH}:/venvs/yq/bin"
463+
ENV PATH="${PATH}:/venvs/zizmor/bin"
463464
ENV PATH="${PATH}:/node_modules/.bin"
464465
ENV PATH="${PATH}:/usr/lib/go/bin"
465466
ENV PATH="${PATH}:${DART_SDK}/bin:/root/.pub-cache/bin"

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ fix-codebase: ## Fix and format the entire codebase
296296
-e DEFAULT_BRANCH=main \
297297
-e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \
298298
-e FILTER_REGEX_EXCLUDE=".*(/test/linters/|CHANGELOG.md|/test/data/test-repository-contents/).*" \
299+
-e FIX_GITHUB_ACTIONS_ZIZMOR=true \
299300
-e FIX_ENV=true \
300301
-e FIX_JAVASCRIPT_ES=true \
301302
-e FIX_JAVASCRIPT_PRETTIER=true \

0 commit comments

Comments
 (0)