-
Notifications
You must be signed in to change notification settings - Fork 57
326 lines (312 loc) · 10.3 KB
/
validation.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
name: Validation
defaults:
run:
shell: bash
on:
push:
branches: [ main, '24.4', '2.5', '1.5', '1.4', '1.3' ]
paths-ignore:
- 'hilla-logo.svg'
- 'README.md'
- '.github/ISSUE_TEMPLATE/*'
- 'packages/**/README.md'
- 'scripts/generator/templates/**/*.md'
pull_request_target:
types: [opened, synchronize, reopened]
paths-ignore:
- 'hilla-logo.svg'
- 'README.md'
- '.github/ISSUE_TEMPLATE/*'
- 'packages/**/README.md'
- 'scripts/generator/templates/**/*.md'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
init:
name: Build Java and TypeScript for other tasks
runs-on: ubuntu-latest
timeout-minutes: 5
env:
NX_SKIP_NX_CACHE: true
steps:
- uses: actions-cool/check-user-permission@main
id: checkUser
with:
username: ${{github.triggering_actor}}
require: 'write'
- name: Fail on external workflow triggering
if: ${{ steps.checkUser.outputs.require-result != 'true' && github.actor != 'dependabot[bot]' }}
run: |
echo "🚫 **${{ github.actor }}** is an external contributor, a **${{ github.repository }}** team member has to review this changes and re-run this build" \
| tee -a $GITHUB_STEP_SUMMARY && exit 1
- name: Check secrets
run: |
[ -z "${{secrets.TB_LICENSE}}" ] \
&& echo "🚫 **TB_LICENSE** is not defined, check that **${{github.repository}}** repo has a valid secret" \
| tee -a $GITHUB_STEP_SUMMARY && exit 1 || exit 0
- name: Checkout Project Code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Setup
uses: ./.github/actions/setup
- name: Build TypeScript
run: npm run build
- name: Build Java
run: mvn install -B -ntp -DskipTests -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
- name: Save Workspace
run: |
tar cf workspace.tar -C ~/ $( \
mvn -q -DskipTests \
-Dexec.executable='echo' \
-Dexec.args='${project.groupId}:${project.artifactId}' \
-Dexec.skip='${maven.deploy.skip}' \
exec:exec \
| perl -pe 's/\.(?=.*:)/\//g' \
| sed -e 's/:/\//' \
| sed -e 's/^/.m2\/repository\//' \
)
find packages/java -type d -name target -print0 | xargs -0 tar rf workspace.tar
find packages/java/tests -path */src/main/resources/vaadin-core-versions.json -print0 | xargs -0 tar rf workspace.tar
tar rf workspace.tar $(find packages/ts -name node_modules -prune -o -print | git check-ignore --stdin)
- uses: actions/upload-artifact@v4
with:
name: saved-workspace
path: workspace.tar
retention-days: 1
if-no-files-found: error
check-style:
needs: init
name: Check style
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
fail-fast: false
steps:
- name: Checkout Project Code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Setup
uses: ./.github/actions/setup
- uses: actions/download-artifact@v4
with:
name: saved-workspace
- name: Restore Workspace
run: |
set -x
tar xf workspace.tar
tar cf - .m2 | (cd ~ && tar xf -)
- name: Validate Java Format
run: mvn -B formatter:validate
- name: Lint TypeScript
run: npm run check
test-java:
needs: init
name: Test Java
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
fail-fast: false
steps:
- name: Checkout Project Code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Setup
uses: ./.github/actions/setup
- uses: actions/download-artifact@v4
with:
name: saved-workspace
- name: Restore Workspace
run: |
set -x
tar xf workspace.tar
tar cf - .m2 | (cd ~ && tar xf -)
- name: Test
run: mvn -B -am -P\!it-modules verify -pl '!:hilla-gradle-plugin'
- name: Collect Coverage
run: |
COVFILES=$(find packages/java -wholename 'target/site/jacoco/jacoco.xml' | tr '\n' ',' | sed '$s/,$//')
echo "COVFILES=$COVFILES" >> $GITHUB_ENV
- name: Send Coverage to Codecov
if: ${{ env.COVFILES != '' }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ env.COVFILES }}
flags: unittests
fail_ci_if_error: true
root_dir: ${{ github.workspace }}
test-typescript:
needs: init
name: Test TypeScript
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
fail-fast: false
steps:
- name: Install Chrome
uses: browser-actions/setup-chrome@v1
- name: Checkout Project Code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Setup
uses: ./.github/actions/setup
- uses: actions/download-artifact@v4
with:
name: saved-workspace
- name: Restore Workspace
run: |
set -x
tar xf workspace.tar
tar cf - .m2 | (cd ~ && tar xf -)
- name: Test
run: npm run test:coverage
env:
CI: true
- name: Collect Coverage
run: |
COVFILES=$(find packages/ts -wholename '*/.coverage/lcov.info' | tr '\n' ',' | sed '$s/,$//')
echo "COVFILES=$COVFILES" >> $GITHUB_ENV
- name: Send Coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ env.COVFILES }}
flags: unittests
fail_ci_if_error: true
root_dir: ${{ github.workspace }}
test-it:
needs:
- init
name: ITs
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
it-modules: group-1
- os: ubuntu-latest
it-modules: group-2
- os: ubuntu-latest
it-modules: some
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Project Code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Setup
uses: ./.github/actions/setup
- uses: actions/download-artifact@v4
with:
name: saved-workspace
- name: Restore Workspace
run: |
set -x
tar xf workspace.tar
tar cf - .m2 | (cd ~ && tar xf -)
- name: Set TB License
run: |
TB_LICENSE=${{secrets.TB_LICENSE}}
mkdir -p ~/.vaadin/
echo '{"username":"'`echo $TB_LICENSE | cut -d / -f1`'","proKey":"'`echo $TB_LICENSE | cut -d / -f2`'"}' > ~/.vaadin/proKey
- name: Verify
run: |
(
cd packages/java/tests && \
mvn -B -am -ntp -fae \
-Dfailsafe.forkCount=4 \
-Dcom.vaadin.testbench.Parameters.testsInParallel=5 \
-Dfailsafe.rerunFailingTestsCount=2 \
-Dmaven.wagon.httpconnectionManager.ttlSeconds=25 \
-Dmaven.wagon.http.retryHandler.count=3 \
-P\!it-modules \
-Pit-modules-${{ matrix.it-modules }} \
-Pproduction \
verify
)
- uses: actions/upload-artifact@v4
if: ${{ failure() || success() }}
with:
name: saved-outputs-it-${{ matrix.os }}-${{ matrix.it-modules }}
path: |
packages/java/tests/**/target/*-reports/*
packages/java/tests/**/error-screenshots/*.png
test-gradle:
needs:
- init
name: Gradle tests
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Project Code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Setup
uses: ./.github/actions/setup
- uses: actions/download-artifact@v4
with:
name: saved-workspace
- name: Restore Workspace
run: |
set -x
tar xf workspace.tar
tar cf - .m2 | (cd ~ && tar xf -)
- name: Set TB License
run: |
TB_LICENSE=${{secrets.TB_LICENSE}}
mkdir -p ~/.vaadin/
echo '{"username":"'`echo $TB_LICENSE | cut -d / -f1`'","proKey":"'`echo $TB_LICENSE | cut -d / -f2`'"}' > ~/.vaadin/proKey
- name: Test gradle-plugin's functional tests
run: ./packages/java/gradle-plugin/gradlew --info -p packages/java/gradle-plugin functionalTest
- name: Gradle ITs
run: ./packages/java/tests/gradle/single-module-tests/gradlew --info -p packages/java/tests/gradle/single-module-tests test
- uses: actions/upload-artifact@v4
if: ${{ failure() || success() }}
with:
name: saved-outputs-gradle-${{ matrix.os }}
path: |
packages/java/tests/**/target/*-reports/*
packages/java/tests/**/error-screenshots/*.png
packages/java/gradle-plugin/build/test-results/*
packages/java/gradle-plugin/build/reports/*
test-all:
name: Tests Summary
runs-on: ubuntu-latest
if: ${{ always() }}
needs:
- check-style
- test-java
- test-typescript
- test-it
- test-gradle
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: saved-outputs
pattern: saved-outputs-*
- name: Fail if test jobs did not succeed
if: ${{ needs.check-style.result != 'success' || needs.test-java.result != 'success' || needs.test-typescript.result != 'success' || needs.test-it.result != 'success' || needs.test-gradle.result != 'success' }}
run: exit 1