-
Notifications
You must be signed in to change notification settings - Fork 19
320 lines (319 loc) · 12.4 KB
/
build.yaml
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
name: build ara
on:
push:
branches:
- 'main'
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '30 1 * * 0'
workflow_dispatch:
inputs:
FULL_BUILD:
description: 'Full build launch '
required: false
default: 'true'
jobs:
prepare:
runs-on: ubuntu-latest
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: false
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
paths_result: ${{ steps.skip_check.outputs.paths_result }}
api_new_release_published: ${{ steps.semantic_api.outputs.new_release_published }}
api_new_release_version: ${{ steps.semantic_api.outputs.new_release_version }}
web-ui_new_release_published: ${{ steps.semantic_web-ui.outputs.new_release_published }}
web-ui_new_release_version: ${{ steps.semantic_web-ui.outputs.new_release_version }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
paths_filter: |
api:
paths:
- 'code/api/**/*'
- '.github/workflows/build.yaml'
webui:
paths:
- 'code/web-ui/**/*'
- '.github/workflows/build.yaml'
candidate:
paths:
- 'charts/candidate/**/*'
skip_after_successful_duplicate: 'false'
cancel_others: 'true'
- name: Checkout
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
persist-credentials: false # To use github token provide for semantic release
- if: ${{ steps.skip_check.outputs.should_skip != 'true' || !fromJSON(steps.skip_check.outputs.paths_result).api.should_skip }}
name: Ensure package json for semantic-release-monorepo
working-directory: code/api
run: test -e package.json || echo '{"name":"ara-api"}' > package.json
- if: ${{ steps.skip_check.outputs.should_skip != 'true' || !fromJSON(steps.skip_check.outputs.paths_result).api.should_skip }}
name: Semantic Release api
id: semantic_api
uses: cycjimmy/semantic-release-action@v4
with:
working_directory: code/api
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
env:
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
- if: ${{ steps.skip_check.outputs.should_skip != 'true' || !fromJSON(steps.skip_check.outputs.paths_result).webui.should_skip }}
name: Semantic Release web-ui
id: semantic_web-ui
uses: cycjimmy/semantic-release-action@v4
with:
working_directory: code/web-ui
semantic_version: 18
dry_run: false
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
env:
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
build-api:
needs: prepare
if: ${{ needs.prepare.outputs.should_skip != 'true' || !fromJSON(needs.prepare.outputs.paths_result).api.should_skip || needs.prepare.outputs.api_new_release_published == 'true' }}
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
ref: ${{ github.ref }}
- name: Set up JDK
uses: actions/[email protected]
with:
distribution: 'adopt'
java-version: '17'
cache: 'maven'
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: java
config-file: .github/codeql/codeql-api-config.yml
- name: Add host binding
run: sudo echo "127.0.0.1 oauth2.dev.localhost" >> sudo tee -a /etc/hosts
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: start oauth2-dev-server
run: docker-compose -f code/docker-compose.dev.yaml up -d oauth2-dev-server
- name: check oauth2-dev-server is running
run: docker run --rm --network host aligor/wait-for-url --url http://oauth2.dev.localhost:9001/actuator/health
- name: stop oauth2-dev-server
run: docker-compose -f code/docker-compose.dev.yaml down
- name: Install xmllint
run: sudo apt-get update && sudo apt-get install libxml2-utils
- name: Prepare
id: prep
run: |
PUSH=FALSE
pushd code
APP_EXISTS=$(make -s check-api-image)
popd
if [[ $GITHUB_REF == refs/heads/* ]]; then
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$BRANCH_NAME" ] && [ "$APP_EXISTS" != 'true' ]; then
PUSH=TRUE
fi
elif [[ $GITHUB_REF == refs/pull/* ]]; then
BRANCH_NAME=$(echo ${{ github.event.pull_request.head.ref }} | sed -r 's#/+#-#g')
if [[ $BRANCH_NAME == release-* ]]; then
PUSH=TRUE
SUFFIX=-rc
else
SUFFIX=-pr.${{ github.event.number }}
fi
fi
echo ::set-output name=push::${PUSH}
echo ::set-output name=suffix::${SUFFIX}
- if: ${{ steps.prep.outputs.push == 'true' }}
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
run: |
pushd code
make build-api SUFFIX=${{ steps.prep.outputs.suffix }} PUBLISH=${{ steps.prep.outputs.push }} FULL=true
popd
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "ara_api"
- name: Integration tests
run: |
pushd code/tests
make start-local
make test-karate BATCH=true
make destroy-local
popd
cat code/tests/target/results.txt | grep SUCCESS
build-web-ui:
needs: prepare
if: ${{ needs.prepare.outputs.should_skip != 'true' || !fromJSON(needs.prepare.outputs.paths_result).webui.should_skip || needs.prepare.outputs.web-ui_new_release_published == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
ref: ${{ github.ref }}
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: javascript
config-file: .github/codeql/codeql-web-ui-config.yml
- name: Get project version
id: getVersion
run: |
pushd code
PROJECT_VERSION=$(make -s get-web-ui-version)
popd
echo ::set-output name=projectVersion::${PROJECT_VERSION}
- name: Prepare
id: prep
run: |
PUSH=FALSE
pushd code
APP_EXISTS=$(make -s check-web-ui-image)
popd
if [[ $GITHUB_REF == refs/heads/* ]]; then
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$BRANCH_NAME" ] && [ "$APP_EXISTS" != 'true' ]; then
PUSH=TRUE
fi
elif [[ $GITHUB_REF == refs/pull/* ]]; then
BRANCH_NAME=$(echo ${{ github.event.pull_request.head.ref }} | sed -r 's#/+#-#g')
if [[ $BRANCH_NAME == release-* ]]; then
PUSH=TRUE
SUFFIX=rc
else
SUFFIX=pr-${{ github.event.number }}
fi
fi
echo ::set-output name=push::${PUSH}
echo ::set-output name=suffix::${SUFFIX}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- if: ${{ steps.prep.outputs.push == 'true' }}
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
run: |
pushd code
make build-web-ui SUFFIX=${{ steps.prep.outputs.suffix }} PUBLISH=${{ steps.prep.outputs.push }}
popd
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "ara_web-ui"
bump-candidate:
needs: prepare
if: ${{ needs.prepare.outputs.api_new_release_published == 'true' || needs.prepare.outputs.web-ui_new_release_published == 'true' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
outputs:
bump: ${{ steps.check.outputs.bump }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.ACCESS_TOKEN }}
ref: ${{ github.ref }}
- uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install xmllint
run: sudo apt-get update && sudo apt-get install libxml2-utils
- name: Bump version
working-directory: code
run: |
make update-ui-component TARGET_CHART=candidate
make update-api-component TARGET_CHART=candidate
- uses: EndBug/add-and-commit@v7
with:
add: 'charts/candidate'
branch_mode: throw
message: 'chore(release-candidate): bump components versions [skip ci]'
pathspec_error_handling: exitImmediately
pull: '--rebase --autostash'
default_author: github_actions
- id: check
run: echo ::set-output name=bump::true
release-candidate:
needs:
- prepare
- bump-candidate
if: ${{ always() && github.event_name != 'pull_request' && (needs.bump-candidate.outputs.bump == 'true' || needs.prepare.outputs.should_skip != 'true' || !fromJSON(needs.prepare.outputs.paths_result).candidate.should_skip) }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
persist-credentials: false # To use github token provide for semantic release
ref: ${{ github.ref }}
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
with:
working_directory: charts/candidate
semantic_version: 18
dry_run: false
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
env:
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Run chart-releaser
uses: Thomgrus/chart-releaser-action@feat/manage-chart-by-chart-diff
with:
config: .github/cr-config.yaml
version: v1.3.0
charts_dir: charts/candidate
env:
CR_TOKEN: "${{ secrets.ACCESS_TOKEN }}"