Skip to content

Commit eb8f925

Browse files
authored
Add workflow linting with Zizmor (#582)
* lint fixes from zizmor Signed-off-by: Jussi Kukkonen <[email protected]> * Add zizmor linter This uses the zizmor docker image because otherwise we have to start depending on python tools which is a little awkward in a golang project. * Define version using Dockerfile * Run zizmor in "make lint" and in the lint action, using the version in Dockerfile Signed-off-by: Jussi Kukkonen <[email protected]> --------- Signed-off-by: Jussi Kukkonen <[email protected]>
1 parent 5aff459 commit eb8f925

File tree

6 files changed

+32
-1
lines changed

6 files changed

+32
-1
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ updates:
2222
go-patch-updates:
2323
update-types:
2424
- "patch"
25+
cooldown:
26+
default-days: 7
2527
- package-ecosystem: "github-actions"
2628
directory: "/"
2729
schedule:
@@ -30,6 +32,8 @@ updates:
3032
actions-patch-updates:
3133
update-types:
3234
- "patch"
35+
cooldown:
36+
default-days: 7
3337
- package-ecosystem: "docker"
3438
directories:
3539
- "/"
@@ -39,6 +43,8 @@ updates:
3943
docker-patch-updates:
4044
update-types:
4145
- "patch"
46+
cooldown:
47+
default-days: 7
4248
- package-ecosystem: "docker-compose"
4349
directories:
4450
- "/"
@@ -49,3 +55,5 @@ updates:
4955
docker-compose-patch-updates:
5056
update-types:
5157
- "patch"
58+
cooldown:
59+
default-days: 7

.github/workflows/build_container.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ on:
2121
branches:
2222
- main
2323
workflow_call:
24+
secrets:
25+
GITHUB_TOKEN:
26+
required: true
2427

2528
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
2629
env:

.github/workflows/lint.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,24 @@ jobs:
4848
runs-on: ubuntu-latest
4949
steps:
5050
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
51+
with:
52+
persist-credentials: false
5153

5254
- name: Run ShellCheck
5355
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # v2.0.0
5456
with:
5557
scandir: ./tests/sharding
5658
severity: warning
59+
60+
zizmor:
61+
name: zizmor
62+
runs-on: ubuntu-latest
63+
steps:
64+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
65+
with:
66+
persist-credentials: false
67+
68+
- name: Run Zizmor
69+
run: |
70+
ZIZMOR=$(grep FROM Dockerfile.zizmor | cut -d' ' -f 2)
71+
docker run --rm -v $PWD:/source $ZIZMOR /source

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ jobs:
8181
build-container:
8282
name: Build and push container image
8383
uses: ./.github/workflows/build_container.yml
84-
secrets: inherit
84+
secrets:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8586
needs: approval
8687
permissions:
8788
contents: read

Dockerfile.zizmor

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Not built, only used to get dependabot to update the version
2+
FROM ghcr.io/zizmorcore/zizmor:1.16.2@sha256:f49ba23d190f90cb837e7e117803cbf96f5632bc65417d7e2fdb04f606e19c17 AS zizmor

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ SRC = $(shell find . -iname "*.go" | grep -v -e $(subst $() $(), -e ,$(strip $(P
3737
PROTO_SRC = $(shell find $(PROTO_DIRS))
3838

3939
SIGSTORE_PROTO_BUILDER = $(shell grep FROM Dockerfile.protobuf-specs | cut -d' ' -f 2)
40+
ZIZMOR = $(shell grep FROM Dockerfile.zizmor | cut -d' ' -f 2)
4041

4142
# for docker protobuf build
4243
GO_MODULE = github.com/sigstore/rekor-tiles/v2
@@ -67,6 +68,7 @@ lint:
6768
-v $(shell go env GOMODCACHE):/.cache/mod -e GOMODCACHE=/.cache/mod \
6869
-v ~/.cache/golangci-lint:/.cache/golangci-lint -e GOLANGCI_LINT_CACHE=/.cache/golangci-lint \
6970
$(shell awk -F '[ @]' '/FROM golangci\/golangci-lint/{print $$2; exit}' Dockerfile.golangci-lint) golangci-lint run -v ./...
71+
docker run -t --rm -v $(PWD):/source $(ZIZMOR) /source
7072

7173
gosec: ## Run gosec security scanner
7274
$(GOBIN)/gosec ./...

0 commit comments

Comments
 (0)