Debian Codegraph @

.github/workflows/ci.yaml

raw
1 name: CI
2
3 on:
4 workflow_dispatch:
5 pull_request:
6 push:
7 tags:
8 - 'v*'
9 branches:
10 - main
11
12 permissions: {}
13
14 jobs:
15 build:
16 runs-on: ubuntu-24.04
17 name: Build & Test
18 permissions:
19 contents: read
20 packages: read
21 env:
22 GOEXPERIMENT: 'cgocheck2'
23 steps:
24 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
25 with:
26 persist-credentials: 'false'
27
28 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
29 with:
30 go-version-file: 'go.mod'
31 cache: "${{ github.actor != 'renovate[bot]' }}"
32
33 - name: go build openvpn-auth-oauth2
34 run: go build ./cmd/openvpn-auth-oauth2
35
36 - name: go build openvpn-auth-oauth2.so
37 run: go build -buildvcs=false -buildmode=c-shared -o "${RUNNER_TEMP}/openvpn-auth-oauth2.so" ./lib/openvpn-auth-oauth2
38
39 - name: go test
40 run: go test ./... -short -shuffle=on -timeout 20s -race -covermode=atomic -coverprofile=coverage.out -coverpkg=./...
41
42 - name: docker pull integration test image
43 run: docker pull ghcr.io/jkroepke/openvpn-auth-oauth2/it:latest
44
45 - name: go test (Integration Tests)
46 run: go test -race -count=1 -timeout=15m -run '^TestIT(EnforceUniqueUser)?$' ./internal ./lib/openvpn-auth-oauth2
47 env:
48 OPENVPN_IT_TEST: '1'
49 PLUGIN_IT_TEST: '1'
50 PLUGIN_IT_PLUGIN_PATH: "${{ runner.temp }}/openvpn-auth-oauth2.so"
51
52 - uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
53 env:
54 CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
55 bench:
56 runs-on: ubuntu-24.04
57 name: go bench
58 permissions:
59 contents: read
60 steps:
61 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
62 with:
63 persist-credentials: 'false'
64
65 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
66 with:
67 go-version-file: 'go.mod'
68 cache: "${{ github.actor != 'renovate[bot]' }}"
69
70 - name: go test -bench
71 run: go test ./... -timeout 20s -run='^$' -bench=. -benchmem
72 goreleaser:
73 runs-on: ubuntu-24.04
74 name: Test goreleaser
75 permissions:
76 contents: read
77 steps:
78 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
79 with:
80 persist-credentials: 'false'
81 fetch-depth: 0
82
83 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
84 with:
85 go-version-file: 'go.mod'
86 cache: "${{ github.actor != 'renovate[bot]' }}"
87
88 - uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1
89 with:
90 version: 0.15.2
91
92 - uses: anchore/sbom-action/download-syft@3ad7283483fc7af8ff2b4ea19663c2d5ca935e26 # v0.24.2
93
94 - name: Write gpg sign key
95 if: env.GPG_KEY != null
96 run: echo "$GPG_KEY" > "$GPG_KEY_PATH"
97 env:
98 GPG_KEY_PATH: "${{ secrets.GPG_KEY_PATH }}"
99 GPG_KEY: ${{ secrets.GPG_KEY }}
100
101 - name: go build (with goreleaser)
102 uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3
103 with:
104 # renovate: github=goreleaser/goreleaser
105 version: v2.18.0
106 args: release --snapshot
107 env:
108 GITHUB_TOKEN: ""
109 GPG_KEY_PATH: ""
110
111 - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
112 with:
113 name: dists
114 path: dist/
115 lint:
116 name: lint
117 runs-on: ubuntu-24.04
118 permissions:
119 contents: read
120 steps:
121 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
122 with:
123 persist-credentials: 'false'
124
125 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
126 with:
127 go-version-file: 'go.mod'
128 cache: "${{ github.actor != 'renovate[bot]' }}"
129
130 - run: go mod tidy -diff
131
132 - name: golangci-lint
133 uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
134 with:
135 # renovate: github=golangci/golangci-lint
136 version: v2.13.2
137 args: "--max-same-issues=0"
138
139 super-lint:
140 name: super-lint
141 runs-on: ubuntu-24.04
142 permissions:
143 contents: read
144 steps:
145 - name: Checkout Code
146 uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
147 with:
148 persist-credentials: 'false'
149 fetch-depth: 0
150
151 - name: Lint Code Base
152 uses: super-linter/super-linter/slim@4ce20838b8ab83717e78138c5b3a1407148e0918 # v8.7.0
153 env:
154 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155 MULTI_STATUS: false
156 LINTER_RULES_PATH: .
157 GITHUB_ACTIONS_ZIZMOR_CONFIG_FILE: ./.github/zizmor.yml
158 ENABLE_GITHUB_ACTIONS_STEP_SUMMARY: true
159 ENABLE_GITHUB_PULL_REQUEST_SUMMARY_COMMENT: false
160 SAVE_SUPER_LINTER_SUMMARY: true
161 VALIDATE_ALL_CODEBASE: true
162 VALIDATE_BASH: true
163 VALIDATE_BASH_EXEC: true
164 VALIDATE_EDITORCONFIG: true
165 VALIDATE_ENV: true
166 VALIDATE_GIT_MERGE_CONFLICT_MARKERS: true
167 VALIDATE_GITHUB_ACTIONS: true
168 VALIDATE_GITHUB_ACTIONS_ZIZMOR: true
169 VALIDATE_GO_RELEASER: true
170 VALIDATE_HTML: true
171 VALIDATE_JSON: true
172 VALIDATE_NATURAL_LANGUAGE: true
173 # VALIDATE_MARKDOWN: false
174 VALIDATE_RENOVATE: true
175 VALIDATE_SHELL_SHFMT: true
176 VALIDATE_SPELL_CODESPELL: true
177 VALIDATE_XML: true
178 VALIDATE_YAML: true
179
180 publish:
181 name: Publish package
182 environment: Publish
183 if: >-
184 github.event_name == 'push'
185 && startsWith(github.ref, 'refs/tags/v')
186 needs:
187 - build
188 - lint
189 - goreleaser
190 - super-lint
191 runs-on: ubuntu-24.04
192 permissions:
193 contents: write
194 id-token: write
195 attestations: write
196 steps:
197 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
198 with:
199 persist-credentials: 'false'
200 fetch-depth: 0
201
202 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
203 with:
204 go-version-file: 'go.mod'
205 cache: true
206
207 - uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1
208 with:
209 version: 0.15.2
210
211 - uses: anchore/sbom-action/download-syft@3ad7283483fc7af8ff2b4ea19663c2d5ca935e26 # v0.24.2
212
213 - name: GPG configuration
214 run: |-
215 echo "$GPG_KEY" > "$GPG_KEY_PATH"
216 mkdir -p "$HOME/.gnupg"
217 chmod 0700 "$HOME/.gnupg"
218 echo "use-agent" > "$HOME/.gnupg/gpg.conf"
219 echo "pinentry-mode loopback" >> "$HOME/.gnupg/gpg.conf"
220 echo "allow-loopback-pinentry" > "$HOME/.gnupg/gpg-agent.conf"
221 echo "max-cache-ttl 86400" >> "$HOME/.gnupg/gpg-agent.conf"
222 echo "default-cache-ttl 86400" >> "$HOME/.gnupg/gpg-agent.conf"
223 gpgconf --kill gpg-agent
224 gpgconf --launch gpg-agent
225 echo "$GPG_PASSPHRASE" | gpg --batch --yes --passphrase-fd 0 --import "$GPG_KEY_PATH"
226 echo "1F34F95B4F30BC5B06E0D7CC3F619F17002790D8:6:" | gpg --import-ownertrust
227 env:
228 GPG_KEY_ID: ${{ vars.GPG_KEY_ID }}
229 GPG_KEY: ${{ secrets.GPG_KEY }}
230 GPG_PASSPHRASE: ${{ secrets.NFPM_PASSPHRASE }}
231 GPG_KEY_PATH: "${{ secrets.GPG_KEY_PATH }}"
232
233 - name: Run GoReleaser
234 uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3
235 with:
236 # renovate: github=goreleaser/goreleaser
237 version: v2.18.0
238 args: release --clean
239 env:
240 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
241 GORELEASER_CURRENT_TAG: ${{ github.ref_name }}
242 NFPM_OPENVPN-AUTH-OAUTH2_PASSPHRASE: ${{ secrets.NFPM_PASSPHRASE }}
243 GPG_KEY_PATH: ${{ secrets.GPG_KEY_PATH }}
244
245 - name: Release APT repository
246 run: |
247 set -x
248 gh release download "${GITHUB_REF_NAME}" -p "*.deb" -D tmp
249 pushd tmp
250 apt-ftparchive packages . | tee Packages | xz > Packages.xz
251 apt-ftparchive release . > Release
252 gpg --batch --yes --pinentry-mode loopback --passphrase "$GPG_PASSPHRASE" --clearsign -o InRelease Release
253 gpg --batch --yes --pinentry-mode loopback --passphrase "$GPG_PASSPHRASE" --armor --detach-sign --sign -o Release.gpg Release
254 gh release upload "${GITHUB_REF_NAME}" InRelease Packages Packages.xz Release Release.gpg --clobber
255 popd
256 env:
257 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
258 GPG_PASSPHRASE: ${{ secrets.NFPM_PASSPHRASE }}
259
260 - name: Publish Release
261 run: gh release edit "${GITHUB_REF_NAME}" --draft=false
262 env:
263 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
264
265 - uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
266 with:
267 subject-checksums: ./dist/checksums.txt