forked from apache/incubator-kie-tools
-
Notifications
You must be signed in to change notification settings - Fork 6
285 lines (257 loc) · 12.5 KB
/
ci_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
name: "CI :: Build"
on:
push:
branches: [main]
pull_request:
branches: ["**"]
types: [opened, reopened, ready_for_review, synchronize]
concurrency:
group: ${{ github.event.pull_request && format('ci-build-full-pr-{0}', github.event.pull_request.number) || format('ci-build-full-push-main-{0}', github.sha) }}
cancel-in-progress: true
env:
TMPDIR: "/tmp"
jobs:
run:
if: github.event.pull_request.draft == false
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: "Support longpaths"
if: runner.os == 'Windows'
run: git config --system core.longpaths true
- name: "Checkout @ GitHub default"
uses: actions/checkout@v3
- name: "Checkout @ Simulated squashed-merge if PR"
id: checkout_pr
uses: ./.github/actions/checkout-pr
with:
ref: ${{ github.base_ref }}
- name: "Setup CI patterns"
id: ci_patterns
uses: ./.github/actions/setup-ci-patterns
- name: "Setup build mode {none,full,partial}"
id: setup_build_mode
shell: bash
run: |
export CHANGED_SOURCE_PATHS=($(eval "git diff --name-only ${{ steps.checkout_pr.outputs.base_sha }} ${{ steps.checkout_pr.outputs.head_sha }} -- ${{ steps.ci_patterns.outputs.non_source_files_patterns_for_git_diff }}"))
echo "Changed source paths:"
echo ${#CHANGED_SOURCE_PATHS[@]}
printf '%s\n' "${CHANGED_SOURCE_PATHS[@]}"
export CHANGED_SOURCE_PATHS_IN_ROOT=($(printf '%s\n' "${CHANGED_SOURCE_PATHS[@]}" | grep -v -e "^packages" -e "^examples"))
echo "Changed source paths in root:"
echo ${#CHANGED_SOURCE_PATHS_IN_ROOT[@]}
printf '%s\n' "${CHANGED_SOURCE_PATHS_IN_ROOT[@]}"
if [ ${#CHANGED_SOURCE_PATHS[@]} -eq 0 ]; then
echo 'No source files changed; `CI :: Build` (none) will run.'
echo "mode=none" >> $GITHUB_OUTPUT
elif [ ! ${{ github.event.pull_request }} ]; then
echo 'Push to the `main` branch happened; `CI :: Build` (full) will run.'
echo "mode=full" >> $GITHUB_OUTPUT
elif [ ${#CHANGED_SOURCE_PATHS_IN_ROOT[@]} -eq 0 ]; then
echo 'No source files changed in root; `CI :: Build` (partial) will run.'
echo "mode=partial" >> $GITHUB_OUTPUT
else
echo 'Source files changed in root; `CI :: Build` (full) will run.'
echo "mode=full" >> $GITHUB_OUTPUT
fi
echo "Done"
- name: "Setup environment"
if: steps.setup_build_mode.outputs.mode != 'none'
uses: ./.github/actions/setup-env
- name: "FULL → Bootstrap"
if: steps.setup_build_mode.outputs.mode == 'full'
env:
PLAYWRIGHT_BASE__installDeps: "true"
uses: ./.github/actions/bootstrap
- name: "FULL → Build (without some images)"
if: steps.setup_build_mode.outputs.mode == 'full'
env:
WEBPACK__minimize: "false"
WEBPACK__tsLoaderTranspileOnly: "false"
KIE_TOOLS_BUILD__runLinters: "true"
KIE_TOOLS_BUILD__runTests: "true"
KIE_TOOLS_BUILD__runEndToEndTests: ${{ runner.os == 'Linux' }}
KIE_TOOLS_BUILD__buildContainerImages: ${{ runner.os != 'Windows' }}
KIE_TOOLS_BUILD__buildExamples: "true"
KIE_TOOLS_BUILD__ignoreTestFailures: ${{ !github.event.pull_request }}
KIE_TOOLS_BUILD__ignoreEndToEndTestFailures: ${{ !github.event.pull_request }}
DISPLAY: ":99.0"
START_SERVER_AND_TEST_INSECURE: "true"
NODE_OPTIONS: "--max_old_space_size=4096"
run: >-
pnpm
-F='!@kie-tools/serverless-logic-web-tools-swf-dev-mode-image'
-F='!@kie-tools/dev-deployment-base-image'
-F='!@kie-tools/dev-deployment-kogito-quarkus-blank-app-image'
-F='!@kie-tools/dev-deployment-dmn-form-webapp-image'
-F='!@kie-tools/serverless-logic-web-tools-base-builder-image'
-F='!@kie-tools/dashbuilder-viewer-image'
-r --workspace-concurrency=1 build:prod
- name: "FULL → Build → serverless-logic-web-tools-swf-dev-mode-image"
if: steps.setup_build_mode.outputs.mode == 'full' && runner.os == 'Linux'
env:
KIE_TOOLS_BUILD__runTests: "true"
KIE_TOOLS_BUILD__runEndToEndTests: "true"
KIE_TOOLS_BUILD__buildContainerImages: "true"
run: |
echo "Clean up container image resources"
if command -v docker &> /dev/null; then
docker system prune -af
fi
if command -v podman &> /dev/null; then
podman system prune --all --force
fi
echo "Build @kie-tools/serverless-logic-web-tools-swf-dev-mode-image"
pnpm -F @kie-tools/serverless-logic-web-tools-swf-dev-mode-image... --workspace-concurrency=1 build:prod
- name: "FULL → Build → dev-deployment-base-image and dev-deployment-kogito-quarkus-blank-app"
if: steps.setup_build_mode.outputs.mode == 'full' && runner.os == 'Linux'
env:
KIE_TOOLS_BUILD__runTests: "true"
KIE_TOOLS_BUILD__runEndToEndTests: "true"
KIE_TOOLS_BUILD__buildContainerImages: "true"
run: |
echo "Clean up container image resources"
if command -v docker &> /dev/null; then
docker system prune -af
fi
if command -v podman &> /dev/null; then
podman system prune --all --force
fi
echo "Build @kie-tools/dev-deployment-base-image"
pnpm -F @kie-tools/dev-deployment-base-image... -F @kie-tools/dev-deployment-kogito-quarkus-blank-app... --workspace-concurrency=1 build:prod
- name: "FULL → Build → dev-deployment-dmn-form-webapp-image"
if: steps.setup_build_mode.outputs.mode == 'full' && runner.os == 'Linux'
env:
KIE_TOOLS_BUILD__runTests: "true"
KIE_TOOLS_BUILD__runEndToEndTests: "true"
KIE_TOOLS_BUILD__buildContainerImages: "true"
run: |
echo "Clean up container image resources"
if command -v docker &> /dev/null; then
docker system prune -af
fi
if command -v podman &> /dev/null; then
podman system prune --all --force
fi
echo "Build @kie-tools/dev-deployment-dmn-form-webapp-image"
pnpm -F @kie-tools/dev-deployment-dmn-form-webapp-image... --workspace-concurrency=1 build:prod
- name: "FULL → Build → serverless-logic-web-tools-base-builder-image"
if: steps.setup_build_mode.outputs.mode == 'full' && runner.os == 'Linux'
env:
KIE_TOOLS_BUILD__runTests: "true"
KIE_TOOLS_BUILD__runEndToEndTests: "true"
KIE_TOOLS_BUILD__buildContainerImages: "true"
run: |
echo "Clean up container image resources"
if command -v docker &> /dev/null; then
docker system prune -af
fi
if command -v podman &> /dev/null; then
podman system prune --all --force
fi
echo "Build @kie-tools/serverless-logic-web-tools-base-builder-image"
pnpm -F @kie-tools/serverless-logic-web-tools-base-builder-image... --workspace-concurrency=1 build:prod
- name: "FULL → Build → dashbuilder-viewer-image"
if: steps.setup_build_mode.outputs.mode == 'full' && runner.os == 'Linux'
env:
KIE_TOOLS_BUILD__runTests: "true"
KIE_TOOLS_BUILD__runEndToEndTests: "true"
KIE_TOOLS_BUILD__buildContainerImages: "true"
run: |
echo "Clean up container image resources"
if command -v docker &> /dev/null; then
docker system prune -af
fi
if command -v podman &> /dev/null; then
podman system prune --all --force
fi
echo "Build @kie-tools/dashbuilder-viewer-image"
pnpm -F @kie-tools/dashbuilder-viewer-image... --workspace-concurrency=1 build:prod
- name: "PARTIAL → Bootstrap"
if: steps.setup_build_mode.outputs.mode == 'partial'
env:
PLAYWRIGHT_BASE__installDeps: "true"
uses: ./.github/actions/bootstrap
with:
pnpm_filter_string: -F "...[${{ steps.checkout_pr.outputs.base_sha }}]..."
- name: "PARTIAL → Build dependencies"
if: steps.setup_build_mode.outputs.mode == 'partial'
shell: bash
env:
KIE_TOOLS_BUILD__buildContainerImages: ${{ runner.os != 'Windows' }}
KIE_TOOLS_BUILD__buildExamples: "true"
run: |
export ALL_DEPENDENCIES_FILTER=$(pnpm -F="...[${{ steps.checkout_pr.outputs.base_sha }}]" exec bash -c 'echo -n " -F=$(jq --raw-output .name package.json)^..."')
export CHANGED_PKGS_EXCLUSION_FILTER=$(pnpm -F="...[${{ steps.checkout_pr.outputs.base_sha }}]" exec bash -c 'echo -n " -F='"'"'!$(jq --raw-output .name package.json)'"'"'"')
echo $ALL_DEPENDENCIES_FILTER
echo $CHANGED_PKGS_EXCLUSION_FILTER
eval "pnpm $ALL_DEPENDENCIES_FILTER $CHANGED_PKGS_EXCLUSION_FILTER build:dev"
- name: "PARTIAL → Build changed and dependents"
if: steps.setup_build_mode.outputs.mode == 'partial'
env:
WEBPACK__minimize: "false"
KIE_TOOLS_BUILD__runLinters: "true"
KIE_TOOLS_BUILD__runTests: "true"
KIE_TOOLS_BUILD__runEndToEndTests: ${{ runner.os == 'Linux' }}
KIE_TOOLS_BUILD__buildContainerImages: ${{ runner.os != 'Windows' }}
KIE_TOOLS_BUILD__buildExamples: "true"
DISPLAY: ":99.0"
START_SERVER_AND_TEST_INSECURE: "true"
NODE_OPTIONS: "--max_old_space_size=4096"
run: |
pnpm -F "...[${{ steps.checkout_pr.outputs.base_sha }}]" --workspace-concurrency=1 build:prod
- name: "Check tests result (`main` only)"
if: always() && !cancelled() && steps.setup_build_mode.outputs.mode != 'none'
uses: actions/github-script@v6
env:
KIE_TOOLS_CI__JUNIT_REPORT_RESULTS_PATTERNS: |-
${{ steps.ci_patterns.outputs.tests_reports_patterns }}
${{ steps.ci_patterns.outputs.end_to_end_tests_reports_patterns }}
with:
result-encoding: string
script: |
const patterns = process.env["KIE_TOOLS_CI__JUNIT_REPORT_RESULTS_PATTERNS"]
.split("\n")
.map(p => p.trim())
.filter(p => p);
const script = require("./scripts/check-junit-report-results/src/index.js");
await script({ core, glob, patterns });
- name: "Check hanging uncommitted files (you should commit those!)"
if: always() && !cancelled() && steps.setup_build_mode.outputs.mode != 'none'
shell: bash
run: |
git diff
[ "0" == "$(git diff | wc -l | tr -d ' ')" ]
- name: "Upload reports and artifacts"
if: always() && !cancelled() && steps.setup_build_mode.outputs.mode != 'none'
uses: ./.github/actions/upload-ci-reports-and-artifacts
- name: "Upload end-to-end tests results to Buildkite (`main` only)"
if: always() && !cancelled() && steps.setup_build_mode.outputs.mode != 'none' && !github.event.pull_request
shell: bash
env:
BUILDKITE_ANALYTICS_TOKEN: ${{ secrets.BUILDKITE_TOKEN }}
BUILDKITE_BRANCH: ${{ github.ref_name }}
BUILDKITE_MESSAGE: ${{ github.event.commits[0].message }}
run: |
eval "find -P * -type f ${{ steps.ci_patterns.outputs.end_to_end_tests_reports_patterns_for_find }}"
echo "---------------------------- starting upload -----------------------"
eval "find -P * -type f ${{ steps.ci_patterns.outputs.end_to_end_tests_reports_patterns_for_find }}" | xargs -I{} curl -X POST \
-H "Authorization: Token token=\"$BUILDKITE_ANALYTICS_TOKEN\"" \
-F "format=junit" \
-F "data=@{}" \
-F "run_env[CI]=github_actions" \
-F "run_env[key]=$GITHUB_ACTION-$GITHUB_RUN_NUMBER-$GITHUB_RUN_ATTEMPT" \
-F "run_env[number]=$GITHUB_RUN_NUMBER" \
-F "run_env[branch]=$BUILDKITE_BRANCH" \
-F "run_env[commit_sha]=$GITHUB_SHA" \
-F "run_env[message]=$BUILDKITE_MESSAGE" \
-F "run_env[url]=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
https://analytics-api.buildkite.com/v1/uploads
- name: "Print storage usage (after build)"
if: always() && !cancelled()
shell: bash
run: |
df -h .