-
Notifications
You must be signed in to change notification settings - Fork 7
217 lines (212 loc) · 7.81 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: Test and build
on:
pull_request:
types:
- opened
push:
jobs:
tests:
name: Test
strategy:
matrix:
go_version:
- "1.22"
- "1.23"
- "1.24"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
show-progress: false
- name: Use golang ${{ matrix.go_version }}
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
with:
go-version: ${{ matrix.go_version }}
check-latest: true
- name: Go get dependencies
run: go get -v -t -d ./...
- name: Run tests
run: make coverage
- name: Send the coverage output
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
with:
flag-name: go-${{ join(matrix.*, '-') }}
parallel: true
file: coverage.out
post-tests:
needs: tests
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
with:
parallel-finished: true
test-latest:
name: Test latest
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
show-progress: false
- name: Use golang stable
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
with:
go-version: stable
check-latest: true
- name: Go get dependencies
run: go get -v -t -d ./...
- name: Run tests
run: make coverage
bench:
name: Benchmark
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
show-progress: false
- name: Setup golang
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
with:
go-version-file: go.mod
check-latest: true
- name: Run benchmark
run: make bench | tee output.txt; exit ${PIPESTATUS[0]}
- name: Download previous benchmark data
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ./cache
key: ${{ runner.os }}-benchmark
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@d48d326b4ca9ba73ca0cd0d59f108f9e02a381c7 # v1.20.4
with:
tool: go
output-file-path: ./output.txt
external-data-json-path: ./cache/benchmark-data.json
comment-on-alert: false
fail-on-alert: true
# only execute this step when cache was restored
# do not fail hard here, as the key might not exist
- name: Clear cache
shell: bash
if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
env:
GH_TOKEN: ${{ github.token }}
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete '${{ runner.os }}-benchmark' --confirm
continue-on-error: true
- name: Update benchmark data
if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ./cache
key: ${{ runner.os }}-benchmark
build:
name: Build Docker Images
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
permissions:
actions: read
contents: write
packages: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
show-progress: false
- name: Docker Login to GitHub Repository
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Login to DockerHub
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
username: ${{ secrets.BOT_DOCKER_USERNAME }}
password: ${{ secrets.BOT_DOCKER_TOKEN }}
- name: Login to Mia registry
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
registry: nexus.mia-platform.eu
username: ${{ secrets.MIA_PLATFORM_DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.MIA_PLATFORM_DOCKER_REGISTRY_PASSWORD }}
- name: Install Cosign
uses: sigstore/cosign-installer@d7d6bc7722e3daa8354c50bcb52f4837da5e9b6a # v3.8.1
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
with:
platforms: amd64,arm64
- name: Configure docker metadata
id: meta
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
with:
images: |
ghcr.io/rond-authz/rond
docker.io/rondauthz/rond
nexus.mia-platform.eu/rond-authz/rond
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
labels: |
org.opencontainers.image.documentation=https://rond-authz.io
org.opencontainers.image.vendor=rond authz
annotations: |
org.opencontainers.image.documentation=https://rond-authz.io
org.opencontainers.image.vendor=rond authz
- name: Setup Buildx Context
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
id: buildx
with:
platforms: linux/amd64,linux/arm64
- name: Build and push
id: docker-build
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.output.annotations }}
platforms: ${{ steps.buildx.outputs.platforms }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Generate SBOM
uses: anchore/sbom-action@f325610c9f50a54015d37c8d16cb3b0e2c8f4de0 # v0.18.0
if: github.ref_type == 'tag'
with:
artifact-name: rond-authz-sbom.spdx.json
output-file: ./rond-authz-sbom.spdx.json
image: nexus.mia-platform.eu/rond-authz/rond:${{ steps.meta.output.version.main }}
upload-release-assets: true
- name: GCP Auth
uses: google-github-actions/auth@71f986410dfbc7added4569d411d040a91dc6935 # v2.1.8
if: github.ref_type == 'tag'
with:
project_id: ${{ secrets.MIA_PLATFORM_KMS_PROJECT }}
workload_identity_provider: ${{ secrets.MIA_PLATFORM_GCP_WIF }}
create_credentials_file: true
- name: Sign public images with Mia-Platform key
if: github.ref_type == 'tag'
run: |
for tag in ${TAGS}; do
image="${tag}@${DIGEST}"
cosign sign --recursive --yes --key "${COSIGN_PRIVATE_KEY}" "${image}"
cosign attest --recursive --yes --key "${COSIGN_PRIVATE_KEY}" --predicate "rond-authz-sbom.spdx.json" --type="spdxjson" "${image}"
done
env:
TAGS: |
ghcr.io/rond-authz/rond:${{ steps.meta.output.version.main }}
docker.io/rondauthz/rond:${{ steps.meta.output.version.main }}
nexus.mia-platform.eu/rond-authz/rond:${{ steps.meta.output.version.main }}
DIGEST: ${{ steps.docker-build.outputs.digest }}
COSIGN_PRIVATE_KEY: ${{ secrets.MIA_PLATFORM_COSIGN_KEY }}