-
Notifications
You must be signed in to change notification settings - Fork 15
544 lines (520 loc) · 19.7 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
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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
#
# Copyright Avast Software. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
name: "wallet-sdk ci"
env:
GO_VERSION: '1.21'
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
SemanticPullRequest:
name: Semantic Pull Request Check
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v4
with:
requireScope: true
scopes: |
sdk
app
deps
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Checks:
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Run checks
run: |
echo $PATH
go env
echo ${{ github.workspace }}
make checks
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
UnitTest:
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Run unit test
run: make unit-test
- name: Upload coverage to Codecov
run: |
bash <(curl https://codecov.io/bash)
env:
CODECOV_UPLOAD_TOKEN: ${{ secrets.CODECOV_UPLOAD_TOKEN }}
SDKIntegrationTest:
runs-on: ubuntu-20.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Run Integration tests
run: |
echo '127.0.0.1 testnet.orb.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 file-server.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 did-resolver.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 vc-rest-echo.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 api-gateway.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 cognito-mock.trustbloc.local' | sudo tee -a /etc/hosts
make integration-test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Temporarily disabled due to compatibility issues with Go 1.21.
#
# WASMIntegrationTest:
# runs-on: ubuntu-20.04
# timeout-minutes: 30
# steps:
# - uses: actions/checkout@v3
# - name: Set up Go
# uses: actions/setup-go@v3
# with:
# go-version: ${{ env.GO_VERSION }}
# - name: Setup Node.js
# uses: actions/setup-node@v3
# - name: Run Integration tests
# uses: GabrielBB/xvfb-action@v1
# with:
# run: |
# echo '127.0.0.1 testnet.orb.local' | sudo tee -a /etc/hosts
# echo '127.0.0.1 file-server.trustbloc.local' | sudo tee -a /etc/hosts
# echo '127.0.0.1 did-resolver.trustbloc.local' | sudo tee -a /etc/hosts
# echo '127.0.0.1 vc-rest-echo.trustbloc.local' | sudo tee -a /etc/hosts
# echo '127.0.0.1 api-gateway.trustbloc.local' | sudo tee -a /etc/hosts
# echo '127.0.0.1 cognito-mock.trustbloc.local' | sudo tee -a /etc/hosts
# make integration-test-wasm
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
iOSFlutterIntegrationTest:
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Generate and copy iOS Binding
run: |
echo $PATH
echo ${{ github.workspace }}
echo ${GOPATH}
echo ${GOROOT}
export PATH=$PATH:$GOPATH/bin
echo $PATH
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
NEW_VERSION=testVer GIT_REV=testRev BUILD_TIME=testTime make generate-ios-bindings copy-ios-bindings
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOPATH: /Users/runner/work/wallet-sdk/go
- name: Setup env for integration test
run: |
echo '127.0.0.1 testnet.orb.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 file-server.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 did-resolver.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 vc-rest-echo.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 api-gateway.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 cognito-mock.trustbloc.local' | sudo tee -a /etc/hosts
brew install docker docker-compose
brew remove --ignore-dependencies qemu
curl -o ./qemu.rb https://raw.githubusercontent.com/Homebrew/homebrew-core/dc0669eca9479e9eeb495397ba3a7480aaa45c2e/Formula/qemu.rb
brew install ./qemu.rb
colima start
export PATH=$PATH:$GOPATH/bin
echo $PATH
make prepare-integration-test-flutter
- name: Setup Flutter SDK
uses: flutter-actions/setup-flutter@v2
with:
channel: stable
version: 3.10.6
- name: Install flutter app dependencies
run: make install-flutter-dependencies
- name: Run iOS Simulator
uses: futureware-tech/simulator-action@v2
with:
model: 'iPhone 14'
- name: Remove AppIcon contents file (Simulator build fails with this file)
run: |
rm -rf demo/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
rm -rf demo/app/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
- name: Run tests on Simulator
run: make integration-test-flutter integration-test-ios
AndroidFlutterIntegrationTest:
runs-on: macOS-12
steps:
- name: checkout
uses: actions/checkout@v3
- name: Gradle cache
uses: gradle/[email protected]
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-29
- name: Cache Android build files
uses: actions/cache@v3
with:
key: android-build-files
path: |
demo/app/build
demo/app/android/.gradle
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Generate and copy Android Binding
run: |
echo $PATH
echo ${{ github.workspace }}
echo ${GOPATH}
echo ${GOROOT}
export PATH=$PATH:$GOPATH/bin
echo $PATH
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
NEW_VERSION=testVer GIT_REV=testRev BUILD_TIME=testTime make generate-android-bindings copy-android-bindings
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOPATH: /Users/runner/work/wallet-sdk/go
- name: Setup env for integration test
run: |
echo '127.0.0.1 testnet.orb.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 file-server.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 did-resolver.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 vc-rest-echo.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 api-gateway.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 cognito-mock.trustbloc.local' | sudo tee -a /etc/hosts
brew install docker docker-compose
brew remove --ignore-dependencies qemu
curl -o ./qemu.rb https://raw.githubusercontent.com/Homebrew/homebrew-core/dc0669eca9479e9eeb495397ba3a7480aaa45c2e/Formula/qemu.rb
brew install ./qemu.rb
colima start
export PATH=$PATH:$GOPATH/bin
echo $PATH
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
make prepare-integration-test-flutter
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Flutter SDK
uses: flutter-actions/setup-flutter@v2
with:
channel: stable
version: 3.10.6
- name: Install flutter app dependencies
run: make install-flutter-dependencies
- name: Build APK in Debug mode
run: |
cd demo/app
flutter build apk --debug
- name: Run tests on Emulator
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: adb reverse tcp:8075 tcp:8075 && adb reverse tcp:8072 tcp:8072 && adb reverse tcp:9229 tcp:9229 && make integration-test-flutter integration-test-android
GenerateVersion:
if: github.event_name == 'push' && (github.repository == 'trustbloc/wallet-sdk' && github.ref == 'refs/heads/main')
needs: [ Checks, UnitTest, SDKIntegrationTest]
runs-on: ubuntu-22.04
timeout-minutes: 10
outputs:
version: ${{ steps.store.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true
- name: Get current published version
run: |
TAG=$(git describe --tags --always `git rev-list --tags --max-count=1`)
VERSION=$(git rev-parse --short=7 HEAD)
echo "repoTag=${TAG} repoVersion=${VERSION}"
if [[ $TAG == $VERSION ]]; then
TAG=0.0.0
fi
echo "CURRENT_SEMVER=${TAG:0:5}" >> $GITHUB_ENV
echo "repoTag=${TAG} repoVersion=${VERSION} currentSemVer=${TAG:0:5}"
- name: Bump published version
id: bump_version
uses: christian-draeger/[email protected]
with:
current-version: '${{ env.CURRENT_SEMVER }}'
# TODO: needs to be configurable https://github.com/christian-draeger/increment-semantic-version#input--output-examples
version-fragment: 'bug'
- id: store
run: echo "version=${{ steps.bump_version.outputs.next-version }}" >> $GITHUB_OUTPUT
PublishIosSDKSnapshot:
if: github.event_name == 'push' && (github.repository == 'trustbloc/wallet-sdk' && github.ref == 'refs/heads/main')
needs: GenerateVersion
runs-on: macos-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Derive the new version
run: |
echo "new version"
NEW_VER=${{ needs.GenerateVersion.outputs.version }}-SNAPSHOT-$(git rev-parse --short=7 HEAD)
echo "NEW_VERSION=$NEW_VER" >> $GITHUB_ENV
echo $NEW_VER
- name: Generate Binding
run: |
echo $PATH
echo ${{ github.workspace }}
echo ${GOPATH}
echo ${GOROOT}
export PATH=$PATH:$GOPATH/bin
echo $PATH
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
GIT_REV=$(git rev-parse HEAD) BUILD_TIME=$(date) make generate-ios-bindings
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOPATH: /Users/runner/work/wallet-sdk/go
- name: Upload iOS bindings to GitHub Actions Artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: ios-binding
path: ./cmd/wallet-sdk-gomobile/bindings/ios
- name: Zip walletsdk framework
run: |
cd ./cmd/wallet-sdk-gomobile/bindings/ios
zip -r -X walletsdk.xcframework.zip walletsdk.xcframework
- name: Clone walletsdk release repository
uses: actions/checkout@v2
with:
repository: trustbloc-cicd/wallet-sdk
path: ios
token: ${{ secrets.WALLET_SDK_CICD_PAT }}
- name: Build and commit walletsdk xcframework package
run: |
cp -r ./cmd/wallet-sdk-gomobile/bindings/ios/walletsdk.xcframework.zip ./ios/walletsdk.xcframework.zip
cd ios/
ls -lrt
echo "calculate new checksum"
NEW_CHECKSUM=$(swift package compute-checksum $FRAMEWORK_NAME.xcframework.zip)
echo "moduleName=$FRAMEWORK_NAME version=$NEW_VERSION checksum=$NEW_CHECKSUM"
echo "replace name module information in package manifest"
sed -E -i '' 's/let moduleName = ".+"/let moduleName = "'$FRAMEWORK_NAME\"/ Package.swift
echo "replace version information in package manifest"
sed -E -i '' 's/let version = ".+"/let version = "'$NEW_VERSION\"/ Package.swift
echo "replace checksum information in package manifest"
sed -E -i '' 's/let checksum = ".+"/let checksum = "'$NEW_CHECKSUM\"/ Package.swift
echo "Package.swift content file after update"
cat Package.swift
echo "git commit all without framework and push"
git status
git add Package.swift
git commit -m "New $FRAMEWORK_NAME version $NEW_VERSION"
git push
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FRAMEWORK_NAME: walletsdk
NEW_VERSION: '${{ env.NEW_VERSION }}'
- name: Tag and Release new version Swift package
uses: softprops/action-gh-release@v1
with:
draft: false
tag_name : ${{ env.NEW_VERSION }}
repository : trustbloc-cicd/wallet-sdk
files: |
ios/walletsdk.xcframework.zip
env:
GITHUB_TOKEN: ${{ secrets.WALLET_SDK_CICD_PAT }}
PublishAndroidSDKSnapshot:
needs: GenerateVersion
if: github.event_name == 'push' && (github.repository == 'trustbloc/wallet-sdk' && github.ref == 'refs/heads/main')
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Derive the new version
run: |
echo "new version"
NEW_VER=${{ needs.GenerateVersion.outputs.version }}-SNAPSHOT-$(git rev-parse --short=7 HEAD)
echo "NEW_VERSION=$NEW_VER" >> $GITHUB_ENV
echo $NEW_VER
- name: Generate Binding
run: |
export PATH=$PATH:$GOPATH/bin
echo $PATH
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
GIT_REV=$(git rev-parse HEAD) BUILD_TIME=$(date) make generate-android-bindings
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOPATH: /home/runner/work/wallet-sdk/go
- name: Upload Android bindings to GitHub Actions Artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: android-binding
path: ./cmd/wallet-sdk-gomobile/bindings/android
- name: Publish
run: |
export USER=$USER
export TOKEN=$TOKEN
export ANDROID_GROUP_ID=dev.trustbloc
export ANDROID_ARTIFACT_ID=vc-wallet-sdk
export ANDROID_VERSION=${{ env.NEW_VERSION }}
export PROJECT_PKG_REPO=https://maven.pkg.github.com/trustbloc-cicd/snapshot
echo $ANDROID_VERSION
gradle publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
USER: ${{ secrets.CR_USER }}
TOKEN: ${{ secrets.CR_PAT }}
NEW_VERSION: '${{ env.NEW_VERSION }}'
PublishJSSDKSnapshot:
needs: GenerateVersion
if: github.event_name == 'push' && (github.repository == 'trustbloc/wallet-sdk' && github.ref == 'refs/heads/main')
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Derive the new version
run: |
echo "new version"
NEW_VER=${{ needs.GenerateVersion.outputs.version }}-snapshot-$(git rev-parse --short=7 HEAD)
echo "NEW_VERSION=$NEW_VER" >> $GITHUB_ENV
echo $NEW_VER
- name: Set npm authentication tokens
run: |
echo $PATH
echo ${{ github.workspace }}
echo '//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}' > ~/.npmrc
echo '@trustbloc-cicd:registry=https://npm.pkg.github.com' >> ~/.npmrc
- name: Generate bindings and publish to npm
run: |
export PATH=$PATH:$GOPATH/bin
echo $PATH
cd ./cmd/wallet-sdk-js
sed -i 's/"version": "[0-9]\+\.[0-9]\+\.[0-9]\+"/"version": "${{ env.NEW_VERSION }}"/g' package.json
sed -i 's#"name": "@trustbloc/wallet-sdk"#"name": "@trustbloc-cicd/wallet-sdk-js"#g' package.json
sed -i 's#"url": "https://github.com/trustbloc/wallet-sdk.git",#"url": "https://github.com/trustbloc-cicd/snapshot.git"#g' package.json
sed -i '/"directory": "cmd\/wallet-sdk-js"/d' package.json
pushd ../../
make generate-js-bindings
popd
npm publish
env:
DOCKER_USER: ${{ secrets.CR_USER }}
GITHUB_TOKEN: ${{ secrets.CR_PAT }}
GOPATH: /home/runner/work/wallet-sdk/go
PublishDemoAppSnapshot:
needs: GenerateVersion
if: github.event_name == 'push' && (github.repository == 'trustbloc/wallet-sdk' && github.ref == 'refs/heads/main')
runs-on: ubuntu-22.04
timeout-minutes: 40
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Derive the new version
run: |
echo "new version"
NEW_VER=${{ needs.GenerateVersion.outputs.version }}-snapshot-$(git rev-parse --short=7 HEAD)
echo "NEW_VERSION=$NEW_VER" >> $GITHUB_ENV
echo $NEW_VER
- name: Set npm authentication tokens
run: |
echo $PATH
echo ${{ github.workspace }}
echo '//npm.pkg.github.com/:_authToken=${{ secrets.CR_PAT }}' > ~/.npmrc
echo '@trustbloc-cicd:registry=https://npm.pkg.github.com' >> ~/.npmrc
- name: Install dependencies
run: |
pushd ./demo/app/web
npm install
popd
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Github Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
- name: Build and Push container image
uses: docker/build-push-action@v4
with:
context: .
file: ./images/demo/app/Dockerfile
platforms: linux/amd64,linux/arm64
build-args: |
ALPINE_VER=3.18
GO_VER=1.21
push: true
tags: |
ghcr.io/trustbloc-cicd/wallet-demo-app:${{ env.NEW_VERSION }}