This repository has been archived by the owner on Apr 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
260 lines (241 loc) · 9.74 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
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
name: 'Wallet CI'
env:
GO_VERSION: 1.19
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
SemanticPR:
name: Semantic PR Check
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Prettier:
name: Prettier Check
timeout-minutes: 5
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Run Prettier Check
run: |
echo '//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}' > ~/.npmrc
echo '@hyperledger:registry=https://npm.pkg.github.com' >> ~/.npmrc
echo '@trustbloc-cicd:registry=https://npm.pkg.github.com' >> ~/.npmrc
echo '@trustbloc:registry=https://npm.pkg.github.com' >> ~/.npmrc
npm install && npm run prettier-check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ESLint:
name: ESLint Check
timeout-minutes: 5
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Run Wallet Web ESLint Check
run: |
echo '//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}' > ~/.npmrc
echo '@hyperledger:registry=https://npm.pkg.github.com' >> ~/.npmrc
echo '@trustbloc-cicd:registry=https://npm.pkg.github.com' >> ~/.npmrc
echo '@trustbloc:registry=https://npm.pkg.github.com' >> ~/.npmrc
make check-lint
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
License:
name: License Check
runs-on: ubuntu-20.04
timeout-minutes: 5
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 }}
echo '//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}' > ~/.npmrc
echo '@hyperledger:registry=https://npm.pkg.github.com' >> ~/.npmrc
echo '@trustbloc-cicd:registry=https://npm.pkg.github.com' >> ~/.npmrc
echo '@trustbloc:registry=https://npm.pkg.github.com' >> ~/.npmrc
make check-license
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Unit:
name: Wallet Unit Tests
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 Wallet Web Unit Test
run: |
echo '127.0.0.1 testnet.orb.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 mediator.trustbloc.local' | sudo tee -a /etc/hosts
echo '//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}' > ~/.npmrc
echo '@hyperledger:registry=https://npm.pkg.github.com' >> ~/.npmrc
echo '@trustbloc-cicd:registry=https://npm.pkg.github.com' >> ~/.npmrc
echo '@trustbloc:registry=https://npm.pkg.github.com' >> ~/.npmrc
make test-unit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v3
if: always()
with:
name: logs
path: test/fixtures/wallet-web/docker-compose.log
VCWallet-e2e:
name: VC Wallet Automation Tests
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 VC Wallet Automation Tests
run: |
echo '127.0.0.1 testnet.orb.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 vcwallet.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 mediator.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 uni-resolver-web.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 auth.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 auth-hydra.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 demo-hydra.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 edv.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 kms.trustbloc.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 demo-adapter.trustbloc.local' | sudo tee -a /etc/hosts
echo '//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}' > ~/.npmrc
echo '@hyperledger:registry=https://npm.pkg.github.com' >> ~/.npmrc
echo '@trustbloc-cicd:registry=https://npm.pkg.github.com' >> ~/.npmrc
echo '@trustbloc:registry=https://npm.pkg.github.com' >> ~/.npmrc
make test-e2e-vcwallet
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v3
if: always()
with:
name: logs
path: test/fixtures/wallet-web/docker-compose.log
Wallet-e2e:
name: Wallet Automation Tests
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 Wallet Automation Tests
run: |
echo '127.0.0.1 testnet.orb.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 wallet.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 mediator.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 uni-resolver-web.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 auth.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 auth-hydra.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 demo-hydra.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 edv.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 kms.trustbloc.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 demo-adapter.trustbloc.local' | sudo tee -a /etc/hosts
echo '//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}' > ~/.npmrc
echo '@hyperledger:registry=https://npm.pkg.github.com' >> ~/.npmrc
echo '@trustbloc-cicd:registry=https://npm.pkg.github.com' >> ~/.npmrc
echo '@trustbloc:registry=https://npm.pkg.github.com' >> ~/.npmrc
make test-e2e-wallet
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v3
if: always()
with:
name: logs
path: test/fixtures/wallet-web/docker-compose.log
Publish:
name: Publish image
if: github.event_name == 'push' && (github.repository == 'trustbloc/wallet' && github.ref == 'refs/heads/main')
needs: [Prettier, ESLint, License, Unit, VCWallet-e2e, Wallet-e2e]
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Setup Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.19
- 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=v0.0.0
fi
echo "CURRENT_SEMVER=${TAG:1}" >> $GITHUB_ENV
echo "repoTag=${TAG} repoVersion=${VERSION} currentSemVer=${TAG:1}"
- name: Bump published version
id: bump_version
uses: christian-draeger/increment-semantic-version@1.0.3
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'
- name: Set ENV vars
run: |
VERSION=$(git rev-parse --short=7 HEAD)
echo "${{ env.CURRENT_SEMVER }}"
echo "${{ steps.bump_version.outputs.next-version }}"
echo "IMAGE_TAG"=v${{ steps.bump_version.outputs.next-version }}-snapshot-$VERSION >> $GITHUB_ENV
echo "WALLET_WEB_IMAGE_PREFIX"=ghcr.io/trustbloc-cicd/wallet-web >> $GITHUB_ENV
echo $DOCKER_PASSWORD | docker login ghcr.io --username $DOCKER_USER --password-stdin
echo '//npm.pkg.github.com/:_authToken=${DOCKER_PASSWORD}' > ~/.npmrc
echo '@hyperledger:registry=https://npm.pkg.github.com' >> ~/.npmrc
echo '@trustbloc-cicd:registry=https://npm.pkg.github.com' >> ~/.npmrc
echo '@trustbloc:registry=https://npm.pkg.github.com' >> ~/.npmrc
make build-wallet-web
env:
DOCKER_USER: ${{ secrets.CR_USER }}
DOCKER_PASSWORD: ${{ secrets.CR_PAT }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- 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 wallet-web image
uses: docker/build-push-action@v3
with:
context: .
file: ./images/wallet-web/Dockerfile
platforms: linux/amd64,linux/arm64
build-args: |
ALPINE_VER=3.15
GO_VER=1.19
push: true
tags: |
${{ env.WALLET_WEB_IMAGE_PREFIX }}:${{ env.IMAGE_TAG }}
${{ env.WALLET_WEB_IMAGE_PREFIX }}:latest