forked from appsmithorg/appsmith
-
Notifications
You must be signed in to change notification settings - Fork 0
300 lines (268 loc) · 11.1 KB
/
integration-tests-command.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
name: Appsmith External Integration Test Workflow
on:
# This workflow is only triggered by the ok to test command dispatch
repository_dispatch:
types: [ ok-to-test-command ]
jobs:
notify:
runs-on: ubuntu-latest
steps:
# This step creates a comment on the PR with a link to this workflow run.
- name: Add a comment on the PR with link to workflow run
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.client_payload.pull_request.number }}
body: |
Tests running at: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>.
Workflow: `${{ github.workflow }}`.
Commit: `${{ github.event.client_payload.slash_command.args.named.sha }}`.
PR: ${{ github.event.client_payload.pull_request.number }}.
Perf tests will be available at <https://app.appsmith.com/app/performance-infra-dashboard/pr-details-638dd7cd2913ba43778b915e?pr=${{ github.event.client_payload.pull_request.number }}&runId=${{ github.run_id }}_${{github.run_attempt}}>
server-build:
name: server-build
uses: ./.github/workflows/server-build.yml
secrets: inherit
with:
pr: ${{ github.event.client_payload.pull_request.number }}
client-build:
name: client-build
uses: ./.github/workflows/client-build.yml
secrets: inherit
with:
pr: ${{ github.event.client_payload.pull_request.number }}
rts-build:
name: rts-build
uses: ./.github/workflows/rts-build.yml
secrets: inherit
with:
pr: ${{ github.event.client_payload.pull_request.number }}
test-shared-modules:
name: shared-modules
uses: ./.github/workflows/shared-modules.yml
secrets: inherit
with:
pr: ${{ github.event.client_payload.pull_request.number }}
test-appsmithctl:
name: appsmithctl
uses: ./.github/workflows/appsmithctl.yml
secrets: inherit
with:
pr: ${{ github.event.client_payload.pull_request.number }}
build-docker-image:
needs: [ client-build, server-build, rts-build ]
# Only run if the build step is successful
if: success()
name: build-docker-image
uses: ./.github/workflows/build-docker-image.yml
secrets: inherit
with:
pr: ${{ github.event.client_payload.pull_request.number }}
ci-test:
needs: [ build-docker-image ]
# Only run if the build step is successful
if: success()
name: ci-test
uses: ./.github/workflows/ci-test.yml
secrets: inherit
with:
pr: ${{ github.event.client_payload.pull_request.number }}
perf-test:
needs: [ build-docker-image ]
# Only run if the build step is successful
if: success()
name: perf-test
uses: ./.github/workflows/perf-test.yml
secrets: inherit
with:
pr: ${{ github.event.client_payload.pull_request.number }}
ci-test-result:
needs: [ci-test, perf-test ]
# Only run if the ci-test with matrices step is successful
if: always()
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Dump the client payload context
env:
PAYLOAD_CONTEXT: ${{ toJson(github.event.client_payload) }}
run: echo "$PAYLOAD_CONTEXT"
# Download failed_spec list for all jobs
- uses: actions/download-artifact@v3
if: needs.ci-test.result
id: download_ci
with:
name: failed-spec-ci
path: ~/failed_spec_ci
# In case for any ci job failure, create combined failed spec
- name: "combine all specs for CI"
if: needs.ci-test.result != 'success'
run: cat ~/failed_spec_ci/failed_spec_ci* >> ~/combined_failed_spec_ci
# Force save the CI failed spec list into a cache
- name: Store the combined run result for CI
if: needs.ci-test.result != 'success'
uses: martijnhols/actions-cache/save@v3
with:
path: |
~/combined_failed_spec_ci
key: ${{ github.run_id }}-"ci-test-result"
restore-keys: |
${{ github.run_id }}-${{ github.job }}
# Upload combined failed CI spec list to a file
# This is done for debugging.
- name: upload combined failed spec
if: needs.ci-test.result != 'success'
uses: actions/upload-artifact@v3
with:
name: combined_failed_spec_ci
path: ~/combined_failed_spec_ci
- name: Get Latest flaky Tests
shell: bash
run: |
curl --request POST --url https://yatin-s-workspace-jk8ru5.us-east-1.xata.sh/db/CypressKnownFailures:main/tables/CypressKnownFailuires/query --header 'Authorization: Bearer ${{ secrets.XATA_TOKEN }}' --header 'Content-Type: application/json'|jq -r |grep Spec|cut -d ':' -f 2 2> /dev/null|sed 's/"//g'|sed 's/,//g' > ~/knownfailures
# Verify CI test failures against known failures
- name: Verify CI test failures against known failures
if: needs.ci-test.result != 'success'
shell: bash
run: |
new_failed_spec_env="<ol>$(comm -1 -3 <(sort ~/knownfailures) <(sort ~/combined_failed_spec_ci) | sed 's/|cypress|cypress/\n/g' | sed 's/^/<li>/')</ol>"
echo "$new_failed_spec_env"
echo "new_failed_spec_env<<EOF" >> $GITHUB_ENV
echo "$new_failed_spec_env" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Add a comment on the PR with new CI failures
if: needs.ci-test.result != 'success'
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.client_payload.pull_request.number }}
body: |
<details><summary>The following are new failures, please fix them before merging the PR</summary> ${{ env.new_failed_spec_env }}</details>
# Update check run called "ci-test-result"
- name: Mark ci-test-result job as complete
uses: actions/github-script@v6
id: update-check-run
if: ${{ always() }}
env:
run_id: ${{ github.run_id }}
repository: ${{ github.repository }}
number: ${{ github.event.client_payload.pull_request.number }}
job: ${{ github.job }}
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
conclusion: ${{ job.status }}
matrix_result: ${{ toJson(needs.ci-test) }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pull } = await github.rest.pulls.get({
...context.repo,
pull_number: process.env.number
});
const ref = pull.head.sha;
const { data: checks } = await github.rest.checks.listForRef({
...context.repo,
ref
});
const check = checks.check_runs.filter(c => c.name === process.env.job);
if(check.length == 0) {
const head_sha = pull.head.sha;
const { data: completed_at } = await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
head_sha: head_sha,
name: process.env.job,
status: 'completed',
conclusion: JSON.parse(process.env.matrix_result).result,
output: {
title: "Integration tests result for ok to test",
summary: "https://github.com/" + process.env.repository + "/actions/runs/" + process.env.run_id
}
});
return completed_at;
} else {
try {
const { data: result } = await github.rest.checks.update({
...context.repo,
check_run_id: check[0].id,
status: 'completed',
conclusion: JSON.parse(process.env.matrix_result).result,
output: {
title: "Integration tests result for ok to test",
summary: "https://github.com/" + process.env.repository + "/actions/runs/" + process.env.run_id
}
});
console.log({ result });
return result;
} catch(e) {
console.error({ error: e.message });
}
}
- name: Dump the client payload context
env:
PAYLOAD_CONTEXT: ${{ toJson(github.event.client_payload) }}
run: echo "$PAYLOAD_CONTEXT"
- name: Check ci-test set status
if: needs.ci-test.result != 'success' || needs.perf-test.result != 'success'
run: exit 1
package:
needs: [ ci-test ]
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/client
# Run this job only if all the previous steps are a success and the reference if the release or master branch
if: success() && (github.ref == 'refs/heads/release' || github.ref == 'refs/heads/master')
steps:
# Update check run called "package"
- name: Mark package job as complete
uses: actions/github-script@v6
id: update-check-run
if: ${{ always() }}
env:
run_id: ${{ github.run_id }}
repository: ${{ github.repository }}
number: ${{ github.event.client_payload.pull_request.number }}
job: ${{ github.job }}
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
conclusion: ${{ job.status }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pull } = await github.rest.pulls.get({
...context.repo,
pull_number: process.env.number
});
const ref = pull.head.sha;
const { data: checks } = await github.rest.checks.listForRef({
...context.repo,
ref
});
const check = checks.check_runs.filter(c => c.name === process.env.job);
if(check.length == 0) {
const head_sha = pull.head.sha;
const { data: completed_at } = await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
head_sha: head_sha,
name: process.env.job,
status: 'completed',
conclusion: process.env.conclusion,
output: {
title: "Package result for ok to test",
summary: "https://github.com/" + process.env.repository + "/actions/runs/" + process.env.run_id
}
});
return completed_at;
} else {
const { data: result } = await github.rest.checks.update({
...context.repo,
check_run_id: check[0].id,
status: 'completed',
conclusion: process.env.conclusion,
output: {
title: "Package result for ok to test",
summary: "https://github.com/" + process.env.repository + "/actions/runs/" + process.env.run_id
}
});
return result;
}