-
Notifications
You must be signed in to change notification settings - Fork 83
328 lines (312 loc) · 10.8 KB
/
tests.yml
File metadata and controls
328 lines (312 loc) · 10.8 KB
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
name: Tests
on:
push:
branches:
- main
- maintenance
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-changes:
name: Verify changes
runs-on: ubuntu-latest
outputs:
run_backend_tests: ${{ steps.changed-files.outputs.backend_changed }}
run_postgres_tests: ${{ steps.changed-files.outputs.postgres_changed }}
run_ui_tests: ${{ steps.changed-files.outputs.ui_changed }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Find changed files
id: changed-files
run: |
./.github/scripts/detect_changed_files.sh
backend-tests:
if: ${{ needs.check-changes.outputs.run_backend_tests == 'true' }}
name: Backend tests
needs: check-changes
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Use Node.js 24
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 24
- name: Install Dependencies
run: npm ci
- name: Build the forge
run: npm run build
- name: Run forge unit tests
run: npm run cover:unit:forge
- name: Run forge system tests
run: npm run cover:system
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: backend
postgres-tests:
if: ${{ needs.check-changes.outputs.run_postgres_tests == 'true' }}
name: Postgres tests
needs: check-changes
runs-on: ubuntu-latest
timeout-minutes: 45
services:
postgres:
image: postgres:14
env:
POSTGRES_PASSWORD: secret
POSTGRES_USER: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
-m 3GB
ports:
- 5432:5432
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup NodeJS 24
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 24
- name: Install Dependencies
run: npm ci
- name: Build the forge
run: npm run build
- name: Test the forge (with PostgreSQL)
env:
FF_TEST_DB_POSTGRES: true
FF_TEST_DB_POSTGRES_HOST: localhost
FF_TEST_DB_POSTGRES_PORT: 5432
FF_TEST_DB_POSTGRES_USER: postgres
FF_TEST_DB_POSTGRES_PASSWORD: secret
FF_TEST_DB_POSTGRES_DATABASE: flowforge
NODE_OPTIONS: "--max-old-space-size=6144"
run: npm run test
ui-unit-tests:
if: ${{ needs.check-changes.outputs.run_ui_tests == 'true' }}
name: UI unit tests
needs: check-changes
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Dependencies
run: npm ci
- name: Run Linting Tests
run: npm run lint
- name: Run UI Unit Tests
run: npm run test:unit:frontend
ui-os-tests:
if: ${{ needs.check-changes.outputs.run_ui_tests == 'true' }}
name: UI OS tests
needs: check-changes
runs-on: ubuntu-latest
services:
email-service:
image: axllent/mailpit
ports:
- 8025:8025
- 1025:1025
options: >-
--env MP_MAX_MESSAGES=5000
--env MP_SMTP_AUTH_ACCEPT_ANY=1
--env MP_SMTP_AUTH_ALLOW_INSECURE=1
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Dependencies
run: npm ci
- name: Run UI E2E (Cypress) Tests - OS
uses: cypress-io/github-action@4c06c48f3ffea349b7189aa06dfcda47a9fa7b92 # v7.1.8
with:
install: false
config-file: config/cypress-os.config.js
build: npm run build
start: npm run cy:web-server:os
env:
NO_SMTP_SERVER: 'true'
SMTP_HOST: 'localhost'
SMTP_PORT: '1025'
SMTP_WEB_PORT: '8025'
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: failure()
with:
name: os-cypress-output-${{ github.run_id }}-${{ github.run_number }}
path: |
test/e2e/frontend/cypress/screenshots
test/e2e/frontend/cypress/videos
ui-ee-tests:
if: ${{ needs.check-changes.outputs.run_ui_tests == 'true' }}
name: UI EE tests
needs: check-changes
runs-on: ubuntu-latest
services:
email-service:
image: axllent/mailpit
ports:
- 8025:8025
- 1025:1025
options: >-
--env MP_MAX_MESSAGES=5000
--env MP_SMTP_AUTH_ACCEPT_ANY=1
--env MP_SMTP_AUTH_ALLOW_INSECURE=1
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Dependencies
run: npm ci
- name: Run UI E2E (Cypress) Tests - EE
uses: cypress-io/github-action@4c06c48f3ffea349b7189aa06dfcda47a9fa7b92 # v7.1.8
with:
install: false
config-file: config/cypress-ee.config.js
build: npm run build
start: npm run cy:web-server:ee
env:
NO_SMTP_SERVER: 'true'
SMTP_HOST: 'localhost'
SMTP_PORT: '1025'
SMTP_WEB_PORT: '8025'
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: failure()
with:
name: ee-cypress-output-${{ github.run_id }}-${{ github.run_number }}
path: |
test/e2e/frontend/cypress/screenshots
test/e2e/frontend/cypress/videos
### We use this job to gather results from all test jobs and determine the final status of the tests execution.
### Jobs executed with the matrix strategy have dynamic names and cannot be referenced in the status checks of the pull request.
tests-summary:
name: Tests summary
if: ${{ always() }}
needs:
- check-changes
- backend-tests
- postgres-tests
- ui-unit-tests
- ui-os-tests
- ui-ee-tests
runs-on: ubuntu-latest
steps:
- name: Evaluate test job results
run: |
results=(
'${{ needs.backend-tests.result }}'
'${{ needs.postgres-tests.result }}'
'${{ needs.ui-unit-tests.result }}'
'${{ needs.ui-os-tests.result }}'
'${{ needs.ui-ee-tests.result }}'
)
echo 'Test job results:'
printf '%s\n' "${results[@]}"
for result in "${results[@]}"; do
if [ "$result" = 'failure' ] || [ "$result" = 'cancelled' ]; then
echo 'One or more test jobs failed or were cancelled'
exit 1
fi
done
echo 'All test jobs succeeded or were skipped'
notify-slack:
name: Notify on failure
needs: tests-summary
if: failure()
runs-on: ubuntu-latest
steps:
- name: Map users
id: map-actor-to-slack
uses: icalia-actions/map-github-actor@e568d1dd6023e406a1db36db4e1e0b92d9dd7824 # v0.0.2
with:
actor-map: ${{ vars.SLACK_GITHUB_USERS_MAP }}
default-mapping: C067BD0377F
- name: Generate payload variables
run: |
if [[ "${{ github.ref_name }}" == 'main' || "${{ github.ref_name }}" == 'maintenance' ]] ; then
echo "HEADER_MESSAGE=Tests failed against ${{ github.ref_name }} branch" >> $GITHUB_ENV
echo "SUMMARY_ICON=no_entry" >> $GITHUB_ENV
echo "SUMMARY_MESSAGE= Deployment to FFC environments will not happen until this issue is resolved." >> $GITHUB_ENV
echo "LAST_COMMIT_SHA=${{ github.sha}}" >> $GITHUB_ENV
echo "PR_LINK=*Branch:* ${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "HEADER_MESSAGE=Tests failed against ${{ github.event.number }} pull request" >> $GITHUB_ENV
echo "SUMMARY_ICON=warning" >> $GITHUB_ENV
echo "SUMMARY_MESSAGE= Please resolve the problem before merging your changes into the main branch." >> $GITHUB_ENV
echo "LAST_COMMIT_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
echo "PR_LINK=*Pull request:* <https://github.com/FlowFuse/flowfuse/pull/${{ github.event.pull_request.number }}|${{ github.event.pull_request.number }}>" >> $GITHUB_ENV
fi
- name: Send notification
uses: slackapi/slack-github-action@af78098f536edbc4de71162a307590698245be95 # v3.0.1
with:
method: chat.postMessage
token: ${{ secrets.SLACK_GHBOT_TOKEN }}
payload: |
{
"channel": "C067BD0377F",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: ${{ env.HEADER_MESSAGE }}",
"emoji": true
}
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "emoji",
"name": "${{ env.SUMMARY_ICON }}"
},
{
"type": "text",
"text": " ${{ env.SUMMARY_MESSAGE }}",
"style": {
"bold": true
}
}
]
}
]
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Author:* <@${{ steps.map-actor-to-slack.outputs.actor-mapping }}>"
},
{
"type": "mrkdwn",
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View failed workflow>"
},
{
"type": "mrkdwn",
"text": "*Last commit:* <${{ github.server_url }}/${{ github.repository }}/commit/${{ env.LAST_COMMIT_SHA }}|${{ env.LAST_COMMIT_SHA }}>"
},
{
"type": "mrkdwn",
"text": "${{ env.PR_LINK }}"
}
]
}
]
}