-
Notifications
You must be signed in to change notification settings - Fork 157
408 lines (358 loc) · 14.3 KB
/
main.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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
name: build
on:
push:
branches:
- main
- release-v*
- release-next
pull_request:
workflow_dispatch:
# cancel older, redundant runs of same workflow on same branch
concurrency:
group: ${{ github.workflow }}-${{github.event_name}}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
env:
GOFLAGS: "-trimpath"
GOX_OUTPUT: "release/{{.Arch}}/{{.OS}}/{{.Dir}}"
GOX_TEST_OUTPUT: "test/{{.Arch}}/{{.OS}}/bin/{{.Dir}}"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: "us-east-2"
gh_ci_key: ${{ secrets.GH_CI_KEY }}
CONSUL_ENCRYPTION_KEY: ${{ secrets.CONSUL_ENCRYPTION_KEY }}
ELASTIC_ENDPOINT: ${{ secrets.ELASTIC_ENDPOINT }}
ELASTIC_USERNAME: ${{ secrets.ELASTIC_USERNAME }}
ELASTIC_PASSWORD: ${{ secrets.ELASTIC_PASSWORD }}
CONSUL_ENDPOINT: ${{ secrets.CONSUL_ENDPOINT }}
CONSUL_AGENT_CERT: ${{ secrets.CONSUL_AGENT_CERT }}
BUILD_NUMBER: ${{ format('{0}-{1}-{2}', github.run_id, github.run_number, github.run_attempt) }}
jobs:
mac-os-build:
name: Build Mac OS binaries
# allow fors to opt-out of time-consuming macOS builds
if: vars.ZITI_SKIP_MACOS_BUILD != 'true'
runs-on: macos-11
steps:
- name: Git Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
- name: Install Ziti CI
uses: openziti/ziti-ci@v1
- name: Build and Test
run: |
go install github.com/mitchellh/gox@latest
$(go env GOPATH)/bin/ziti-ci generate-build-info common/version/info_generated.go version
$(go env GOPATH)/bin/gox -cgo -os=darwin -arch=amd64 -output=$GOX_OUTPUT ./...
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: darwin-release-${{ github.run_id }}
path: release/
retention-days: 5
windows-build:
name: Build Windows binaries
# allow fors to opt-out of time-consuming Windows builds
if: vars.ZITI_SKIP_WINDOWS_BUILD != 'true'
runs-on: windows-2019
steps:
- name: Git Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
- name: Install Ziti CI
uses: openziti/ziti-ci@v1
- name: Build and Test
shell: bash
run: |
go install github.com/mitchellh/gox@latest
$(go env GOPATH)/bin/ziti-ci generate-build-info common/version/info_generated.go version
$(go env GOPATH)/bin/gox -cgo -os=windows -arch=amd64 -output=$GOX_OUTPUT ./...
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: windows-release-${{ github.run_id }}
path: release/
retention-days: 5
linux-build:
name: Build Linux binaries
runs-on: ubuntu-20.04
steps:
- name: Git Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
- name: Install Ziti CI
uses: openziti/ziti-ci@v1
- name: Build and Test
shell: bash
run: |
sudo apt-get update
sudo apt-get -yq install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf gcc-aarch64-linux-gnu
$(go env GOPATH)/bin/ziti-ci configure-git
$(go env GOPATH)/bin/ziti-ci generate-build-info common/version/info_generated.go version
go install github.com/mitchellh/gox@latest
$(go env GOPATH)/bin/gox -cgo -os=linux -arch=amd64 -output=$GOX_OUTPUT ./...
CC=arm-linux-gnueabihf-gcc $(go env GOPATH)/bin/gox -cgo -os=linux -arch=arm -output=$GOX_OUTPUT ./...
CC=aarch64-linux-gnu-gcc $(go env GOPATH)/bin/gox -cgo -os=linux -arch=arm64 -output=$GOX_OUTPUT ./...
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: linux-release-${{ github.run_id }}
path: release/
retention-days: 5
fablab-smoketest:
name: Fablab Smoketest
# not applicable to forks. shouldn't run on release build
if: github.repository_owner == 'openziti' && github.ref != 'refs/heads/main'
needs: [ quickstart ]
runs-on: ubuntu-20.04
steps:
- name: Git Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
- name: Install Ziti CI
uses: openziti/ziti-ci@v1
- name: Build and Test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ziti_ci_gpg_key: ${{ secrets.ZITI_CI_GPG_KEY }}
ziti_ci_gpg_key_id: ${{ secrets.ZITI_CI_GPG_KEY_ID }}
run: |
$(go env GOPATH)/bin/ziti-ci configure-git
$(go env GOPATH)/bin/ziti-ci generate-build-info common/version/info_generated.go version
pushd zititest && go install ./... && popd
go install -tags=all,tests ./...
- name: Create Test Environment
run: |
echo "ZITI_ROOT=$(go env GOPATH)/bin" >> "$GITHUB_ENV"
$(go env GOPATH)/bin/simple-transfer create -d simple-transfer-${GITHUB_RUN_NUMBER} -n simple-transfer-${GITHUB_RUN_NUMBER} -l environment=gh,ziti_version=$($(go env GOPATH)/bin/ziti-ci -q get-current-version)
$(go env GOPATH)/bin/simple-transfer up
- name: Test Ziti Command
run: |
echo "ZITI_ROOT=$(go env GOPATH)/bin" >> "$GITHUB_ENV"
pushd zititest && go test -timeout 30m -v ./tests/... 2>&1 | tee test.out && popd
- name: Create fablab instance archive
if: always()
env:
FABLAB_PASSPHRASE: ${{ secrets.FABLAB_PASSPHRASE }}
run: |
cp $(go env GOPATH)/bin/simple-transfer simple-transfer-${GITHUB_RUN_NUMBER}
cp ~/.fablab/config.yml simple-transfer-${GITHUB_RUN_NUMBER}/
tar --exclude *terraform-provider-aws* -czvf - simple-transfer-${GITHUB_RUN_NUMBER}/ | gpg --symmetric --cipher-algo aes256 --batch --quiet --passphrase ${FABLAB_PASSPHRASE} -o simple-transfer-${GITHUB_RUN_NUMBER}.tar.gz.gpg
aws s3 cp ./simple-transfer-${GITHUB_RUN_NUMBER}.tar.gz.gpg s3://ziti-smoketest-fablab-instances/
- name: Test Report Generation
if: always()
run: |
go install github.com/jstemmer/go-junit-report/v2@latest
$(go env GOPATH)/bin/go-junit-report -in zititest/test.out -out test-report.xml
- name: Test Summary
uses: test-summary/action@v2
with:
paths: |
test-report.xml
show: "fail, skip"
if: always()
# END linux-build-steps
fablab-smoketest-teardown:
name: Teardown SmokeTest
if: always()
runs-on: ubuntu-20.04
needs: [ fablab-smoketest ]
steps:
- name: Sleep If Failed
if: needs.fablab-smoketest.result != 'success' && needs.fablab-smoketest.result != 'skipped'
run: |
sleep 30m
- name: Teardown Test Environment
if: always() && needs.fablab-smoketest.result != 'skipped'
env:
FABLAB_PASSPHRASE: ${{ secrets.FABLAB_PASSPHRASE }}
run: |
aws s3 cp s3://ziti-smoketest-fablab-instances/simple-transfer-${GITHUB_RUN_NUMBER}.tar.gz.gpg .
gpg --quiet --batch --yes --decrypt --passphrase=${FABLAB_PASSPHRASE} --output simple-transfer-${GITHUB_RUN_NUMBER}.tar.gz simple-transfer-${GITHUB_RUN_NUMBER}.tar.gz.gpg
tar -xzf simple-transfer-${GITHUB_RUN_NUMBER}.tar.gz
./simple-transfer-${GITHUB_RUN_NUMBER}/simple-transfer import simple-transfer-${GITHUB_RUN_NUMBER}
./simple-transfer-${GITHUB_RUN_NUMBER}/simple-transfer dispose
aws s3 rm s3://ziti-smoketest-fablab-instances/simple-transfer-${GITHUB_RUN_NUMBER}.tar.gz.gpg
quickstart:
name: Run the Go Quickstart
# - always() allows evaluating further conditional expressions even if
# needed jobs were skipped
if: |
always()
runs-on: ubuntu-20.04
needs: [ linux-build ]
steps:
- name: Git Shallow Checkout
uses: actions/checkout@v3
- name: Download linux release artifact
uses: actions/download-artifact@v3
with:
name: linux-release-${{ github.run_id }}
path: release/
- name: Run Go Quickstart Test
timeout-minutes: 5
run: |
go clean -testcache;
go test -v -tags "quickstart automated" ./ziti/cmd/edge/...;
publish:
name: Publish Binaries
# - always() allows evaluating further conditional expressions even if
# needed jobs were skipped
if: |
always()
&& (needs.mac-os-build.result == 'success' || needs.mac-os-build.result == 'skipped')
&& (needs.windows-build.result == 'success' || needs.windows-build.result == 'skipped')
&& (needs.fablab-smoketest.result == 'success' || needs.fablab-smoketest.result == 'skipped')
runs-on: ubuntu-20.04
needs: [ linux-build, mac-os-build, windows-build, fablab-smoketest ]
outputs:
ZITI_VERSION: ${{ steps.get_version.outputs.ZITI_VERSION }}
steps:
- name: Git Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
- name: Install Ziti CI
uses: openziti/ziti-ci@v1
- name: Download linux release artifact
uses: actions/download-artifact@v3
with:
name: linux-release-${{ github.run_id }}
path: release/
- name: Download darwin release artifact
if: needs.mac-os-build.result == 'success'
uses: actions/download-artifact@v3
with:
name: darwin-release-${{ github.run_id }}
path: release/
- name: Download windows release artifact
if: needs.windows-build.result == 'success'
uses: actions/download-artifact@v3
with:
name: windows-release-${{ github.run_id }}
path: release/
- name: List downloaded release artifacts
run: |
ls -lAhR release/
- name: Restore execute filemode on macOS and Linux release artifacts before publishing
run: |
find ./release \
-type f \
-print0 \
-path "./release/*/darwin/ziti" \
-o \
-path "./release/*/linux/ziti" \
| xargs -0 chmod -c +x
- name: Install Jfrog CLI
uses: jfrog/setup-jfrog-cli@v3
with:
version: 1.51.1
- name: Publish GitHub Release
# forks need to run this step with their own GPG key because ziti-ci creates the GH release
if: env.ziti_ci_gpg_key_id != null && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release-v'))
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ziti_ci_gpg_key: ${{ secrets.ZITI_CI_GPG_KEY }}
ziti_ci_gpg_key_id: ${{ secrets.ZITI_CI_GPG_KEY_ID }}
run: |
$(go env GOPATH)/bin/ziti-ci configure-git
$(go env GOPATH)/bin/ziti-ci tag -v -f version
$(go env GOPATH)/bin/ziti-ci publish-to-github --archive-base ""
# only ziti-ci computed version for release branches and {version}-{run_id} for non-release branches
- name: Compute the Ziti Version String for CI Jobs
id: get_version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REF: ${{ github.ref }}
GITHUB_RUN_ID: ${{ github.run_id }}
run: |
ZITI_VERSION="$($(go env GOPATH)/bin/ziti-ci -q get-current-version)"
# drop the leading 'v', if any
ZITI_VERSION=${ZITI_VERSION#v}
if ! [[ "${ZITI_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# fail the job because we could not obtain the current version from ziti-ci
echo "ERROR: ZITI_VERSION=${ZITI_VERSION} is not a semver"
exit 1
elif [[ "${GITHUB_REF}" =~ ^refs/heads/(release-v|main$) ]]; then
# Set output parameters for release branches
echo "DEBUG: ZITI_VERSION=${ZITI_VERSION}"
echo ZITI_VERSION="${ZITI_VERSION}" >> $GITHUB_OUTPUT
else
# Append build / run number for non-release refs
ZITI_VERSION="${ZITI_VERSION}-${GITHUB_RUN_ID}"
echo "DEBUG: ZITI_VERSION=${ZITI_VERSION}"
echo ZITI_VERSION="${ZITI_VERSION}" >> $GITHUB_OUTPUT
fi
- name: Publish to Artifactory
if: ${{ env.JFROG_API_KEY != null && github.repository == 'openziti/ziti' }}
run: |
$(go env GOPATH)/bin/ziti-ci publish-to-artifactory
env:
JFROG_API_KEY: ${{ secrets.JFROG_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jenkins-smoketest:
# BEGIN smoketest-job
#
# Any event that triggers this main workflow also triggers the smoketest
#
needs: publish
name: Call the On-Demand Smoketest Workflow
# not applicable to forks
if: github.repository_owner == 'openziti'
uses: ./.github/workflows/jenkins-smoketest.yml
secrets: inherit
with:
ziti-version: ${{ needs.publish.outputs.ZITI_VERSION }}
call-publish-prerelease-docker-images:
# always() re-enables evaluating conditionals in forks even if Windows or
# macOS builds were skipped
if: |
always()
&& needs.publish.result == 'success'
&& github.ref == 'refs/heads/release-next'
name: Publish Pre-Release Docker Images
needs: publish
uses: ./.github/workflows/publish-docker-images.yml
secrets: inherit
with:
ziti-version: release-next
call-publish-release-docker-images:
# always() re-enables evaluating conditionals in forks even if Windows or
# macOS builds were skipped
if: |
always()
&& needs.publish.result == 'success'
&& github.ref == 'refs/heads/main'
name: Publish Release Docker Images
needs: publish
uses: ./.github/workflows/publish-docker-images.yml
secrets: inherit
with:
ziti-version: ${{ needs.publish.outputs.ZITI_VERSION }}