-
Notifications
You must be signed in to change notification settings - Fork 8
321 lines (283 loc) · 11 KB
/
build.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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
name: DeployTest
on:
push:
branches:
- main
- "[0-9]+.[0-9]+.x"
pull_request:
branches:
- main
- "[0-9]+.[0-9]+.x"
jobs:
versionning:
name: Versionning
runs-on: ubuntu-latest
outputs:
version: ${{ steps.genver.outputs.version }}
release: ${{ steps.genver.outputs.release }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Generate Version
id: genver
run: |
VERSION=$(docker run --rm -v $(pwd):/repo codacy/git-version /bin/git-version --folder=/repo --release-branch=${{ github.ref_name }}-pre --dev-branch=main)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "VERSION : $VERSION"
RELEASE=$(docker run --rm -v $(pwd):/repo codacy/git-version /bin/git-version --folder=/repo --release-branch=${{ github.ref_name }} --dev-branch=main)
echo "release=$RELEASE" >> $GITHUB_OUTPUT
echo "RELEASE : $RELEASE"
echo "Version :" >> $GITHUB_STEP_SUMMARY
echo "$VERSION" >> $GITHUB_STEP_SUMMARY
echo "Release :" >> $GITHUB_STEP_SUMMARY
echo "$RELEASE" >> $GITHUB_STEP_SUMMARY
buildProjects:
runs-on: ubuntu-latest
needs:
- versionning
env:
GENVERSION: ${{ needs.versionning.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
submodules: true
- name: Build the package
run: |
dotnet build ArmoniK.Extensions.Csharp.sln -c Release -p:Version=$GENVERSION
- name: Pack the package VERSION
run: |
dotnet pack ArmoniK.Extensions.Csharp.sln -c Release -o /tmp/packages -p:Version=$GENVERSION
- name: Push the package
run: |
find /tmp/packages -name 'ArmoniK*.nupkg' ! -name '*test*.nupkg' -exec dotnet nuget push {} -k ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols \;
buildWorkerEnd2End:
runs-on: ubuntu-latest
needs:
- versionning
env:
VERSION: ${{ needs.versionning.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
submodules: true
- name: login
run: |
echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_LOGIN }} --password-stdin
- name: build
run: |
docker build -t dockerhubaneo/armonik_worker_dll:$VERSION -f Worker/src/DLLWorker/Dockerfile .
- name: push
run: |
docker push dockerhubaneo/armonik_worker_dll:$VERSION
buildImagesCross:
runs-on: ubuntu-latest
needs:
- versionning
- buildWorkerEnd2End
env:
VERSION: ${{ needs.versionning.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_LOGIN }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Build and push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4
with:
file: Worker/src/DLLWorker/Dockerfile
context: .
platforms: linux/arm64
push: true
tags: |
dockerhubaneo/armonik_worker_dll:${{ needs.versionning.outputs.version }}-arm
- name: Create multi-arch manifest
run: docker buildx imagetools create dockerhubaneo/armonik_worker_dll:${VERSION} --tag dockerhubaneo/armonik_worker_dll:${VERSION} --append dockerhubaneo/armonik_worker_dll:${VERSION}-arm
testEndToEnd:
needs:
- versionning
- buildProjects
- buildWorkerEnd2End
strategy:
fail-fast: false
matrix:
tls: [true, false]
mtls: [true, false]
sslvalidation : [enable, disable]
useca : [true, false]
exclude:
- sslvalidation : enable
tls : false
- tls: false
mtls: true
- useca: true
sslvalidation : disable
name: "End2End tls:${{ matrix.tls }} mtls:${{ matrix.mtls }} val:${{ matrix.sslvalidation }} ca:${{ matrix.useca }}"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Install Dependencies
uses: aneoconsulting/ArmoniK.Action.Deploy/dependencies@main
with:
docker: true
terraform: true
k3s: true
aws: true
- name: Checkout Infra
uses: actions/checkout@v3
with:
repository: aneoconsulting/ArmoniK
path: infra
- id: deploy
name: Deploy
uses: aneoconsulting/ArmoniK.Action.Deploy/deploy@main
with:
working-directory: ${{ github.workspace }}/infra
type: localhost
tls: ${{ matrix.tls }}
mtls: ${{ matrix.mtls }}
ext-csharp-version: ${{ needs.versionning.outputs.version }}
core-version: 0.24.0
- name: Setup hosts file
run : echo -e "$(kubectl get svc ingress -n armonik -o jsonpath={.status.loadBalancer.ingress[0].ip})\tarmonik.local" | sudo tee -a /etc/hosts
- name: Add CA to store
if: ${{ (matrix.sslvalidation == 'enable') && (matrix.useca == false) }}
run: |
sudo apt install ca-certificates
sudo mkdir -p /usr/local/share/ca-certificates/
sudo cp ${{ steps.deploy.outputs.generated-folder }}/certificates/ingress/ca.crt /usr/local/share/ca-certificates/ca.crt
sudo update-ca-certificates
- name: Build and deploy EndToEnd.Tests
timeout-minutes: 15
run: |
cd Tests
mkdir -p ${HOME}/data
bash -x ./endToEndTests.sh -b -d
cd -
- name: Run tests
timeout-minutes: 18
run: |
set -ex
kubectl get svc -n armonik -o wide
export CPPort=$(kubectl get svc ingress -n armonik -o custom-columns="PORT:.spec.ports[1].port" --no-headers=true)
if [ "${{ matrix.tls }}" = "true" ]; then
export Grpc__Endpoint=https://armonik.local:$CPPort
else
export Grpc__Endpoint=http://armonik.local:$CPPort
fi
export Grpc__SSLValidation=${{ matrix.sslvalidation }}
if [ "${{ matrix.useca }}" = "true" ]; then
export Grpc__CaCert="${{ steps.deploy.outputs.generated-folder }}/certificates/ingress/ca.crt"
fi
if [ "${{ matrix.mtls }}" = "true" ]; then
export Grpc__ClientP12="${{ steps.deploy.outputs.generated-folder }}/certificates/ingress/client.submitter.p12"
fi
dotnet test --runtime linux-x64 -f net8.0 --logger "trx;LogFileName=test-results.trx"
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: "IntegrationTests tls:${{ matrix.tls }} mtls:${{ matrix.mtls }} val:${{ matrix.sslvalidation }} ca:${{ matrix.useca }}"
path: ./Tests/ArmoniK.EndToEndTests/ArmoniK.EndToEndTests.Client/TestResults/test-results.trx
reporter: dotnet-trx
- name: Show logs
if: always()
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
AWS_DEFAULT_OUTPUT: json
run: |
set -e
cd infra
mkdir -p end2end/infra/generated \
end2end/infra/tfstates \
end2end/app
if [ -e infrastructure/quick-deploy/localhost/all-in-one/generated/armonik-output.json ] ; then
cp infrastructure/quick-deploy/localhost/all-in-one/generated/armonik-output.json end2end/infra/generated
fi
cp infrastructure/quick-deploy/localhost/all-in-one/generated/terraform.tfstate end2end/infra/tfstates
sudo cp -rL /var/log/pods/armonik_* end2end/app
sudo chown $USER -R end2end
tar -czf end2end-${{ matrix.tls }}-${{ matrix.mtls }}-${{ matrix.sslvalidation }}-${{ matrix.useca }}.tar.gz end2end
aws s3 cp end2end-${{ matrix.tls }}-${{ matrix.mtls }}-${{ matrix.sslvalidation }}-${{ matrix.useca }}.tar.gz s3://${{ secrets.AWS_LOG_BUCKET_NAME }}/extcsharp-pipeline/${{ github.run_number }}/${{ github.run_attempt }}/end2end-${{ matrix.tls }}-${{ matrix.mtls }}-${{ matrix.sslvalidation }}-${{ matrix.useca }}.tar.gz
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: end2end-${{ matrix.tls }}-${{ matrix.mtls }}-${{ matrix.sslvalidation }}-${{ matrix.useca }}.tar.gz
path: end2end-${{ matrix.tls }}-${{ matrix.mtls }}-${{ matrix.sslvalidation }}-${{ matrix.useca }}.tar.gz
retention-days: 2
test-container:
runs-on: ubuntu-latest
needs:
- versionning
- buildWorkerEnd2End
env:
VERSION: ${{ needs.versionning.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Install Dependencies
uses: aneoconsulting/ArmoniK.Action.Deploy/dependencies@main
with:
docker: true
terraform: true
k3s: true
aws: true
- name: Checkout Infra
uses: actions/checkout@v3
with:
repository: aneoconsulting/ArmoniK
path: infra
- name: Build Docker image
run: |
docker build -t test_image:latest --build-arg WORKER_DLL_IMAGE=dockerhubaneo/armonik_worker_dll:$VERSION -f Tests/ArmoniK.EndToEndTests/ArmoniK.EndToEndTests.Worker/Dockerfile .
docker save "test_image:latest" | sudo k3s ctr images import /dev/stdin
- name: Change version
run: |
cp tools/parameters.tfvars ${{ github.workspace }}/infra/infrastructure/quick-deploy/localhost/all-in-one/parameters.tfvars
cat ${{ github.workspace }}/infra/versions.tfvars.json | jq --arg version "${{ needs.versionning.outputs.version }}" '.armonik_versions.extcsharp=$version | .armonik_images.extcsharp=["test_image"]' > .versions.tfvars.json
mv .versions.tfvars.json ${{ github.workspace }}/infra/versions.tfvars.json
- id: deploy
name: Deploy
uses: aneoconsulting/ArmoniK.Action.Deploy/deploy@main
with:
working-directory: ${{ github.workspace }}/infra
type: localhost
ext-csharp-version: ${{ needs.versionning.outputs.version }}
core-version: 0.24.0
- name: Run Test
timeout-minutes: 20
run: |
cd Tests
bash -x ./endToEndTests.sh
canMerge:
needs:
- testEndToEnd
runs-on: ubuntu-latest
steps:
- name: Echo OK
run: echo OK