Skip to content

Commit 8f75de4

Browse files
authored
add Zizmor (#1337)
Signed-off-by: Gregor Zeitlinger <[email protected]>
1 parent 2625cb1 commit 8f75de4

File tree

9 files changed

+103
-44
lines changed

9 files changed

+103
-44
lines changed

.github/workflows/acceptance-tests.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ on:
66
pull_request:
77
branches: [ "main" ]
88

9+
permissions: {}
10+
911
jobs:
1012
acceptance-tests:
1113
runs-on: ubuntu-24.04
1214
steps:
1315
- name: Check out
16+
with:
17+
persist-credentials: false
1418
uses: actions/checkout@v4
15-
- uses: jdx/mise-action@v2
19+
- uses: jdx/mise-action@7a111ead46986ccad89a74ad013ba2a7c08c9e67 # v2.1.1
1620
- name: Run acceptance tests
1721
run: mise run acceptance-test

.github/workflows/build.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ on:
66
pull_request:
77
branches: [ "main" ]
88

9+
permissions: {}
10+
911
jobs:
1012
build:
1113
runs-on: ubuntu-24.04
1214
steps:
1315
- uses: actions/checkout@v4
14-
- uses: jdx/mise-action@v2
16+
with:
17+
persist-credentials: false
18+
- uses: jdx/mise-action@7a111ead46986ccad89a74ad013ba2a7c08c9e67 # v2.1.1
1519
- name: Cache local Maven repository
1620
uses: actions/cache@v4
1721
with:

.github/workflows/github-pages.yaml

+17-38
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ on:
1111
# Allows you to run this workflow manually from the Actions tab
1212
workflow_dispatch:
1313

14-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
15-
permissions:
16-
contents: read
17-
pages: write
18-
id-token: write
14+
permissions: {}
1915

2016
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
2117
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
@@ -32,55 +28,38 @@ jobs:
3228
# Build job
3329
build:
3430
runs-on: ubuntu-24.04
35-
env:
36-
HUGO_VERSION: 0.115.4
3731
steps:
3832
- uses: actions/checkout@v4
3933
with:
34+
persist-credentials: false
4035
fetch-tags: 'true'
4136
fetch-depth: 0
42-
- name: Set up JDK
43-
uses: actions/setup-java@v4
37+
- uses: jdx/mise-action@7a111ead46986ccad89a74ad013ba2a7c08c9e67 # v2.1.1
4438
with:
45-
java-version: 17
46-
distribution: temurin
47-
cache: 'maven'
48-
- name: Set release version
49-
run: ./scripts/set-release-version-github-pages.sh
50-
- name: Install Hugo CLI
51-
run: |
52-
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
53-
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
54-
- name: Make Javadoc
55-
run: ./mvnw -B clean compile javadoc:javadoc javadoc:aggregate -P javadoc
56-
- name: Move the Javadoc to docs/static/api/
57-
run: mv ./target/reports/apidocs ./docs/static/api && echo && echo 'ls ./docs/static/api' && ls ./docs/static/api
39+
cache: 'false'
40+
- name: Prepare GitHub Pages
41+
run: mise run prepare-gh-pages
42+
with:
43+
permissions: block
5844
- name: Setup Pages
5945
id: pages
6046
uses: actions/configure-pages@v5
61-
- name: Install Node.js dependencies
62-
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
63-
working-directory: ./docs
64-
- name: Build with Hugo
65-
env:
66-
# For maximum backward compatibility with Hugo modules
67-
HUGO_ENVIRONMENT: production
68-
HUGO_ENV: production
69-
run: |
70-
hugo \
71-
--gc \
72-
--minify \
73-
--baseURL "${{ steps.pages.outputs.base_url }}/"
74-
working-directory: ./docs
75-
- name: ls ./docs/public/api
76-
run: echo 'ls ./docs/public/api' && ls ./docs/public/api
47+
- name: Build GitHub Pages
48+
run: mise run build-gh-pages
49+
with:
50+
permissions: block
7751
- name: Upload artifact
7852
uses: actions/upload-pages-artifact@v3
7953
with:
8054
path: ./docs/public
55+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
8156

8257
# Deployment job
8358
deploy:
59+
permissions:
60+
contents: read
61+
pages: write
62+
id-token: write
8463
environment:
8564
name: github-pages
8665
url: ${{ steps.deployment.outputs.page_url }}

.github/workflows/lint.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Acceptance Tests
3+
4+
on: [pull_request]
5+
6+
permissions: {}
7+
8+
jobs:
9+
acceptance-tests:
10+
permissions: {}
11+
runs-on: ubuntu-24.04
12+
steps:
13+
- name: Check out
14+
with:
15+
persist-credentials: false
16+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
- uses: jdx/mise-action@7a111ead46986ccad89a74ad013ba2a7c08c9e67 # v2.1.1
18+
- name: Lint
19+
run: mise run lint-all
20+

.github/workflows/native-tests.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ on:
66
pull_request:
77
branches: [ "main" ]
88

9+
permissions: {}
10+
911
jobs:
1012
native-tests:
1113
runs-on: ubuntu-24.04
1214
steps:
1315
- name: Check out
16+
with:
17+
persist-credentials: false
1418
uses: actions/checkout@v4
15-
- uses: jdx/mise-action@v2
19+
- uses: jdx/mise-action@7a111ead46986ccad89a74ad013ba2a7c08c9e67 # v2.1.1
1620
- name: Run native tests
1721
run: mise run native-test

.github/workflows/release.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
deploy:
1010
if: ${{ github.repository == 'prometheus/client_java' }}
1111
runs-on: ubuntu-24.04
12+
permissions: {}
1213

1314
steps:
1415
- name: Debug gpg key - remove after debugging
@@ -19,16 +20,19 @@ jobs:
1920
echo "$GPG_SIGNING_KEY" | gpg --batch --import-options import-show --import
2021
- name: Checkout Plugin Repository
2122
uses: actions/checkout@v4
23+
with:
24+
persist-credentials: false
2225

2326
- name: Set Up JDK
2427
uses: actions/setup-java@v4
2528
with:
2629
java-version: 17
2730
distribution: temurin
28-
cache: 'maven'
2931

3032
- name: Build with Maven
31-
run: ./scripts/build-release.sh ${{ github.ref_name }}
33+
run: ./scripts/build-release.sh
34+
env:
35+
TAG: ${{ github.ref_name }}
3236

3337
- name: Set up Apache Maven Central
3438
uses: actions/setup-java@v4

mise.lock

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
[tools."cargo:zizmor"]
2+
version = "1.6.0"
3+
backend = "cargo:zizmor"
4+
5+
[tools."go:github.com/gohugoio/hugo"]
6+
version = "v0.147.0"
7+
backend = "go:github.com/gohugoio/hugo"
8+
19
[tools."go:github.com/grafana/oats"]
210
version = "0.3.0"
311
backend = "go:github.com/grafana/oats"
@@ -6,6 +14,10 @@ backend = "go:github.com/grafana/oats"
614
version = "temurin-17.0.13+11"
715
backend = "core:java"
816

17+
[tools.node]
18+
version = "23.10.0"
19+
backend = "core:node"
20+
921
[tools.protoc]
1022
version = "30.2"
1123
backend = "aqua:protocolbuffers/protobuf/protoc"

mise.toml

+33
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
PROTO_GENERATION = "true"
33

44
[tools]
5+
"cargo:zizmor" = "latest"
6+
"go:github.com/gohugoio/hugo" = "latest"
57
"go:github.com/grafana/oats" = "latest"
68
java = "temurin-17.0.13+11"
9+
node = "latest"
710
protoc = "latest"
811

912
[tasks.ci]
@@ -35,6 +38,12 @@ run = "./mvnw verify"
3538
description = "build all modules wihthout tests"
3639
run = "./mvnw install -DskipTests"
3740

41+
[tasks.lint-gh-actions]
42+
run = "zizmor .github/"
43+
44+
[tasks.lint-all]
45+
depends = ["lint-gh-actions"]
46+
3847
[tasks.acceptance-test]
3948
description = "Run OATs acceptance tests"
4049
depends = "build"
@@ -49,6 +58,30 @@ dir = "integration-tests/it-spring-boot-smoke-test"
4958
[tasks.set-version]
5059
run = 'mvn versions:set -DnewVersion={{arg(name="version")}}'
5160

61+
[tasks.javadoc]
62+
run = [
63+
"./mvnw -B clean compile javadoc:javadoc javadoc:aggregate -P javadoc",
64+
"mv ./target/reports/apidocs ./docs/static/api && echo && echo 'ls ./docs/static/api' && ls ./docs/static/api"
65+
]
66+
67+
[tasks.set-gh-pages-version]
68+
run = "./scripts/set-release-version-github-pages.sh"
69+
70+
[tasks.prepare-gh-pages]
71+
description = "Prepare GitHub pages"
72+
depends = ["javadoc", "set-gh-pages-version"]
73+
74+
[tasks.build-gh-pages]
75+
description = "Build GitHub pages"
76+
# For maximum backward compatibility with Hugo modules
77+
env = { HUGO_ENVIRONMENT = "production", HUGO_ENV = "production" }
78+
dir = "docs"
79+
run = [
80+
"npm ci",
81+
"hugo --gc --minify --baseURL ${BASE_URL}/",
82+
"echo 'ls ./docs/public/api' && ls ./docs/public/api"
83+
]
84+
5285
[settings]
5386
# to get lock file support and for go backend
5487
experimental = true

scripts/build-release.sh

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
set -euo pipefail
44

5-
TAG=$1
65
VERSION=${TAG#v}
76

87
mvn versions:set -DnewVersion=$VERSION

0 commit comments

Comments
 (0)