-
Notifications
You must be signed in to change notification settings - Fork 7
283 lines (232 loc) · 8.32 KB
/
ci.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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
name: CI
# Language/Tool dependency versions used in this workflow:
# Go: 1.20.2
# Helm: v3.10.1
# k6: v0.33.0
# Kind: v0.16.0
# Kubeconform: v0.4.10
# Kubernetes: 1.22.1
# Java: 21
on:
push:
branches: [ master ]
tags: '*'
pull_request:
branches: [ master ]
jobs:
# Run linters on various non-Java files (node and shell)
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install npm packages
run: npm --prefix scripts/ install
- name: Lint Node.js code
run: npm --prefix scripts/ run lint
- name: Shellcheck
run: shellcheck scripts/**/*.sh
# Run validations on the thunder Helm chart
helm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up helm
uses: azure/setup-helm@v4
with:
version: v3.5.3
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '^1.20.2'
cache-dependency-path: scripts/deploy/helm/test/go.sum
- name: Download kubeconform
uses: engineerd/[email protected]
with:
name: "kubeconform"
url: "https://github.com/yannh/kubeconform/releases/download/v0.4.10/kubeconform-linux-amd64.tar.gz"
pathInArchive: "kubeconform"
- name: Helm lint
run: helm lint scripts/deploy/helm/thunder
- name: Validate with kubeconform
run: helm template scripts/deploy/helm/thunder | kubeconform -kubernetes-version 1.22.1 -summary
- name: Run Terratests
run: (cd scripts/deploy/helm/test; go mod tidy && go test -v)
# Run the maven build
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
cache: 'maven'
- name: Install npm packages
run: npm --prefix scripts/ install
- name: Download k6
uses: engineerd/[email protected]
with:
name: "k6"
url: "https://github.com/grafana/k6/releases/download/v0.33.0/k6-v0.33.0-linux-amd64.tar.gz"
pathInArchive: "k6-v0.33.0-linux-amd64/k6"
- name: Build with Maven
run: mvn package jacoco:report
- name: Upload Codecov report
uses: codecov/codecov-action@v5
with:
directory: .
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: thunder-artifacts
path: application/target/application-*.jar
# Run Docker integration tests
integration-test:
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
testname:
- bad-request # Load test to ensure bad requests return 400 and latency is adequate
- dynamodb # Functional DynamoDB test
- mongodb # Functional MongoDB test
- inmemorydb # Functional In-Memory DB test
- update-existing-email # Functional test to user data is not deleted on email update
- argon # Functional test to ensure argon2 server-side hash works
- bcrypt # Functional test to ensure bcrypt server-side hash works
- sha256 # Functional test to ensure sha256 server-side hash works
- disabled-email-and-swagger # Functional test to ensure disabling endpoints returns 404
- disabled-password-header # Functional test to ensure passwords are not required on disable
- oauth # Functional test to ensure OAuth authentication works
steps:
- uses: actions/checkout@v4
- name: Download Thunder artifacts
uses: actions/download-artifact@v4
with:
name: thunder-artifacts
path: application/target
- name: Download k6
uses: engineerd/[email protected]
with:
name: "k6"
url: "https://github.com/grafana/k6/releases/download/v0.33.0/k6-v0.33.0-linux-amd64.tar.gz"
pathInArchive: "k6-v0.33.0-linux-amd64/k6"
- name: Run test
run: ./scripts/ci/docker-integration-tests.sh ${{ matrix.testname }}
# Release edge Docker image
release-edge:
runs-on: ubuntu-latest
if: github.event_name == 'push'
needs: [integration-test]
steps:
- uses: actions/checkout@v4
- name: Download Thunder artifacts
uses: actions/download-artifact@v4
with:
name: thunder-artifacts
path: application/target
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push edge image
uses: docker/[email protected]
with:
context: .
push: true
tags: |
rohannagar/thunder:edge
ghcr.io/rohannagar/thunder:edge
# Release tagged Docker image and create GH release
release-tag:
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: [ integration-test ]
steps:
- uses: actions/checkout@v4
- name: Download Thunder artifacts
uses: actions/download-artifact@v4
with:
name: thunder-artifacts
path: application/target
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set tag number
id: tag
run: echo "tag_name=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Build and push release image
uses: docker/[email protected]
with:
context: .
push: true
tags: |
rohannagar/thunder:${{ steps.tag.outputs.tag_name }}
ghcr.io/rohannagar/thunder:${{ steps.tag.outputs.tag_name }}
- name: Create release notes file
run: sed '/^# v${{ steps.tag.outputs.tag_name }}/,/^# v/!d;//d' CHANGELOG.md > release_body.md
- name: Create GitHub Release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body_path: release_body.md
- name: Upload JAR to Release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: application/target/application-${{ steps.tag.outputs.tag_name }}.jar
asset_name: application-${{ steps.tag.outputs.tag_name }}.jar
asset_content_type: application/java-archive
# Test that our Helm chart deploys as expected with the latest edge image
test-deploy:
runs-on: ubuntu-latest
if: github.event_name == 'push'
needs: [release-edge]
steps:
- uses: actions/checkout@v4
- name: Set up kubectl
uses: azure/setup-kubectl@v4
- name: Set up helm
uses: azure/setup-helm@v4
with:
version: v3.10.1
- name: Create kind cluster
uses: helm/[email protected]
with:
version: v0.16.0
- name: Print cluster info
run: kubectl cluster-info --context kind-chart-testing
- name: Install chart
run: helm install thunder scripts/deploy/helm/thunder --wait --timeout 2m
- name: Show running pods
run: kubectl get pods
env:
# Dummy keys to use the AWS SDK in tests
AWS_ACCESS_KEY_ID: 1234567890
AWS_SECRET_ACCESS_KEY: 1234567890