-
Notifications
You must be signed in to change notification settings - Fork 5
235 lines (222 loc) · 8.28 KB
/
test.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
name: Test Workflow
on:
# Triggers the workflow on push events
push:
branches:
- development
# Triggers the workflow on pull request events
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
GITHUB_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }}
IS_DEV: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/development' }}
REPOSITORY: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}
jobs:
test-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.GITHUB_REF }}
repository: ${{ env.REPOSITORY }}
fetch-depth: 0
- uses: ./.github/actions/init
- name: Format
run: npx nx format:check --verbose
test-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.GITHUB_REF }}
repository: ${{ env.REPOSITORY }}
fetch-depth: 0
- uses: ./.github/actions/init
- name: Lint
uses: ./.github/actions/run-optimal
with:
cmd: npx nx run-many --target=lint --all --parallel=2
affectedCmd: npx nx affected:lint
isDev: ${{ env.IS_DEV }}
test-stylelint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.GITHUB_REF }}
repository: ${{ env.REPOSITORY }}
fetch-depth: 0
- uses: ./.github/actions/init
- name: Style Lint All
uses: ./.github/actions/run-optimal
with:
cmd: npx nx run-many --target=stylelint --all --parallel=2
affectedCmd: npx nx affected --target=stylelint
isDev: ${{ env.IS_DEV }}
test-tsconfig:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.GITHUB_REF }}
repository: ${{ env.REPOSITORY }}
fetch-depth: 0
- uses: ./.github/actions/init
- name: TsConfig Paths
uses: ./.github/actions/run-optimal
with:
cmd: npx nx run-many --target=paths --all --parallel=2
affectedCmd: npx nx affected --target=paths
isDev: ${{ env.IS_DEV }}
test-unit:
runs-on: ubuntu-latest
needs: [test-format, test-lint, test-stylelint, test-tsconfig]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.GITHUB_REF }}
repository: ${{ env.REPOSITORY }}
fetch-depth: 0
- uses: ./.github/actions/init
- name: Unit Tests
uses: ./.github/actions/run-optimal
with:
cmd: |
npx nx run-many --target=test --all --parallel=2
node tools/coverage-reports/create-merged-layer-coverage-report.js libs/base
node tools/coverage-reports/create-merged-layer-coverage-report.js libs/domain
node tools/coverage-reports/create-merged-layer-coverage-report.js libs/platform
affectedCmd: npx nx affected:test
isDev: ${{ env.IS_DEV }}
# Job for checking if we should run other jobs with specific conditions.
# This is usefull for forked repos where secrets are not available.
# Checking if specific secret is available to determine if we should run and also a type of event.
set-env:
runs-on: ubuntu-latest
outputs:
should-run-pr: ${{ steps.set-env.outputs.should-run-pr }}
should-run-push: ${{ steps.set-env.outputs.should-run-push }}
should-run-regression: ${{ steps.set-env.outputs.should-run-regression }}
steps:
- name: Set should-run for PR
id: set-env
run: |
echo "CHROMATIC_PROJECT_TOKEN=${{ secrets.CHROMATIC_PROJECT_TOKEN }}"
echo "SCOS_BASE_URL=${{ secrets.SCOS_BASE_URL }}"
if [ -n "${{ secrets.SCOS_BASE_URL }}" ]; then
echo "::set-output name=should-run-regression::true"
else
echo "::set-output name=should-run-regression::false"
fi
if [ "${{ github.event_name }}" = "pull_request" ] && [ -n "${{ secrets.CHROMATIC_PROJECT_TOKEN }}" ]; then
echo "::set-output name=should-run-pr::true"
else
echo "::set-output name=should-run-pr::false"
fi
if [ "${{ github.event_name }}" = "push" ] && [ -n "${{ secrets.CHROMATIC_PROJECT_TOKEN }}" ]; then
echo "::set-output name=should-run-push::true"
else
echo "::set-output name=should-run-push::false"
fi
test-visual-pr:
runs-on: ubuntu-latest
needs: [test-format, test-lint, test-stylelint, test-tsconfig, set-env]
if: needs.set-env.outputs.should-run-pr == 'true'
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- uses: ./.github/actions/init
- name: Visual Regression Tests
env:
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
CHROMATIC_SHA: ${{ github.event.pull_request.head.sha }}
CHROMATIC_BRANCH: ${{ github.event.pull_request.head.ref }}
run: npx nx run storybook:visual-regression-pr
test-visual-dev:
runs-on: ubuntu-latest
needs: [test-format, test-lint, test-stylelint, test-tsconfig, set-env]
if: needs.set-env.outputs.should-run-push == 'true'
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.GITHUB_REF }}
repository: ${{ env.REPOSITORY }}
fetch-depth: 0
- uses: ./.github/actions/init
- name: Visual Regression Tests
env:
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
CHROMATIC_SHA: ${{ github.event.after }}
CHROMATIC_BRANCH: development
run: npx nx run storybook:visual-regression-branch
test-e2e-storefront:
runs-on: ubuntu-latest
needs: [test-format, test-lint, test-stylelint, test-tsconfig]
# # Commented out while we are still having long unit test runs
# strategy:
# matrix:
# os: [ubuntu-latest]
# parallelism: [1, 2, 3]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.GITHUB_REF }}
repository: ${{ env.REPOSITORY }}
fetch-depth: 0
- uses: ./.github/actions/init
- name: Storefront E2E Tests
uses: ./.github/actions/run-optimal
env:
SCOS_BASE_URL: ${{ secrets.SCOS_BASE_URL }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
STORE: DE
ORYX_FEATURE_VERSION: latest
with:
cmd: npm run sf:e2e:headless:ci
affectedCmd: npm run sf:e2e:headless:ci:affected
isDev: ${{ env.IS_DEV }}
test-storefront-visual-regression:
runs-on: ubuntu-latest
needs: [test-format, test-lint, test-stylelint, test-tsconfig, set-env]
if: needs.set-env.outputs.should-run-regression == 'true'
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.GITHUB_REF }}
repository: ${{ env.REPOSITORY }}
fetch-depth: 0
- uses: ./.github/actions/init
- name: Storefront B2C visual regression tests
uses: ./.github/actions/run-optimal
env:
SCOS_BASE_URL: ${{ secrets.SCOS_BASE_URL }}
STORE: DE
ORYX_FEATURE_VERSION: latest
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
PERCY_BRANCH: ${{ github.head_ref || github.ref_name }}
with:
cmd: npm run sf:e2e:headless:ci:visual-regression
affectedCmd: npm run sf:e2e:headless:ci:visual-regression
isDev: ${{ env.IS_DEV }}
test-build:
runs-on: ubuntu-latest
needs: [test-format, test-lint, test-stylelint, test-tsconfig]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.GITHUB_REF }}
repository: ${{ env.REPOSITORY }}
fetch-depth: 0
- uses: ./.github/actions/init
- name: Build
uses: ./.github/actions/run-optimal
with:
cmd: npx nx run-many --target=build --all --parallel=2
affectedCmd: npx nx affected:build
isDev: ${{ env.IS_DEV }}