-
Notifications
You must be signed in to change notification settings - Fork 387
166 lines (163 loc) · 6 KB
/
ci-merge-checks.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
on:
pull_request:
types: [ready_for_review]
branches:
- develop
- develop-*
- release/**
workflow_dispatch:
# empty as it is used only to manually trigger the workflow
env:
CYPRESS_KEY: ${{ secrets.CYPRESS_KEY }}
GH_TOKEN: ${{ github.token }}
NODE_VERSION: '16'
concurrency:
group: ci-merge-checks-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
name: Merge Checks
jobs:
no_retries:
name: MC - Prevent retries
# E2Es can't be retried. Moreover, in some retry cases, they don't run
# and the job returns a success code.
runs-on: ubuntu-latest
steps:
- name: Forcefully fail build if jobs are all retried
uses: actions/github-script@v5
with:
script: |
core.setFailed('Please push a commit to trigger the build. To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`')
if: ${{ github.run_attempt > 1 }}
validate_e2e_execution:
name: MC - Confirm e2es should run
runs-on: ubuntu-latest
outputs:
SHOULD_RUN_E2E: ${{ steps.save-e2e-output-result.outputs.SHOULD_RUN_E2E }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Determine whether to run e2es
id: save-e2e-output-result
run: |
source ci-scripts/validate-e2e-execution.sh
echo "::set-output name=SHOULD_RUN_E2E::$(echo $RUN_E2E)"
b2c_e2e_tests:
needs: [no_retries, validate_e2e_execution]
name: MC - E2E B2C core
runs-on: ubuntu-latest
strategy:
matrix:
containers: [1, 2, 3, 4, 5]
if: ${{ needs.validate_e2e_execution.outputs.SHOULD_RUN_E2E == 'true' }}
steps:
- name: Forcefully fail build if e2e job is retried
uses: actions/github-script@v5
with:
script: |
core.setFailed('Please push a commit to trigger the build. To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`')
if: ${{ github.run_attempt > 1 }}
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: |
node_modules
projects/storefrontapp-e2e-cypress/node_modules
~/.cache/Cypress
key: nodemodules-${{ github.event.pull_request.base.sha }}
restore-keys: nodemodules-${{ github.event.pull_request.base.sha }}
- name: Run e2es
env:
SPA_ENV: ci,b2c
BUILD_NUMBER: ci-build-number-${{ github.event.pull_request.head.sha || github.run_id }}
run: |
ci-scripts/e2e-cypress.sh
b2c_ssr_e2e_tests:
needs: [no_retries, validate_e2e_execution]
name: MC - E2E SSR (B2C)
runs-on: ubuntu-latest
if: ${{ needs.validate_e2e_execution.outputs.SHOULD_RUN_E2E == 'true' }}
steps:
- name: Forcefully fail build if e2e job is retried
uses: actions/github-script@v5
with:
script: |
core.setFailed('Please push a commit to trigger the build. To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`')
if: ${{ github.run_attempt > 1 }}
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: |
node_modules
projects/storefrontapp-e2e-cypress/node_modules
~/.cache/Cypress
key: nodemodules-${{ github.event.pull_request.base.sha }}
restore-keys: nodemodules-${{ github.event.pull_request.base.sha }}
- name: Run e2es
env:
SPA_ENV: ci,b2c
BUILD_NUMBER: ci-build-number-${{ github.event.pull_request.head.sha || github.run_id }}
run: |
ci-scripts/e2e-cypress.sh --ssr
b2b_e2e_tests:
needs: [no_retries, validate_e2e_execution]
name: MC - E2E B2B core
runs-on: ubuntu-latest
strategy:
matrix:
containers: [1, 2, 3, 4]
if: ${{ needs.validate_e2e_execution.outputs.SHOULD_RUN_E2E == 'true' }}
steps:
- name: Forcefully fail build if e2e job is retried
uses: actions/github-script@v5
with:
script: |
core.setFailed('Please push a commit to trigger the build. To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`')
if: ${{ github.run_attempt > 1 }}
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: |
node_modules
projects/storefrontapp-e2e-cypress/node_modules
~/.cache/Cypress
key: nodemodules-${{ github.event.pull_request.base.sha }}
restore-keys: nodemodules-${{ github.event.pull_request.base.sha }}
- name: Run e2es
env:
SPA_ENV: ci,b2b
BUILD_NUMBER: ci-build-number-${{ github.event.pull_request.head.sha || github.run_id }}
run: |
ci-scripts/e2e-cypress.sh -s b2b
merge_checks_result:
needs: [b2c_e2e_tests, b2c_ssr_e2e_tests, b2b_e2e_tests]
name: MC - Result
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Aggregate Required Job Results
run: |
gh pr ready --undo ${{github.event.number}} -R ${{ github.repository }}
exit 1
if: |
needs.b2c_e2e_tests.result == 'failure' || needs.b2c_e2e_tests.result == 'cancelled' ||
needs.b2c_ssr_e2e_tests.result == 'failure' || needs.b2c_ssr_e2e_tests.result == 'cancelled' ||
needs.b2b_e2e_tests.result == 'failure' || needs.b2b_e2e_tests.result == 'cancelled'