forked from Yoast/wordpress-seo
-
Notifications
You must be signed in to change notification settings - Fork 0
226 lines (194 loc) · 7.43 KB
/
jstest.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
name: TestJS
on:
# Run on relevant pushes to select branches and on all relevant pull requests.
push:
branches:
- main
- trunk
- 'release/**'
- 'hotfix/[0-9]+.[0-9]+*'
- 'feature/**'
paths:
- '**.js' # Includes Gruntfile.js.
- '.browserslistrc'
- '.eslintignore'
- '.eslintrc'
- '.nvmrc'
- '.yarnrc'
- 'lerna.json'
- 'package.json'
- 'yarn.lock'
- '.github/workflows/jstest.yml'
- '.yarn/**'
- 'apps/**'
- 'config/grunt/**'
- 'packages/**'
pull_request:
paths:
- '**.js' # Includes Gruntfile.js.
- '.browserslistrc'
- '.eslintignore'
- '.eslintrc'
- '.nvmrc'
- '.yarnrc'
- 'lerna.json'
- 'package.json'
- 'yarn.lock'
- '.github/workflows/jstest.yml'
- '.yarn/**'
- 'apps/**'
- 'config/grunt/**'
- 'packages/**'
# Allow manually triggering the workflow.
workflow_dispatch:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
#########################################################################################
# For packages in this job, the full test suite is always run.
#########################################################################################
yarn-test-full:
runs-on: ubuntu-latest
strategy:
# As these packages are all unique, don't stop the workflow when the test run of one package fails.
fail-fast: false
matrix:
package:
- 'analysis-report'
- 'browserslist-config'
- 'components'
- 'feature-flag'
- 'helpers'
- 'js'
- 'replacement-variable-editor'
- 'search-metadata-previews'
- 'social-metadata-forms'
- 'social-metadata-previews'
- 'yoast-components'
name: "TestJS - ${{ matrix.package }} (full)"
steps:
- name: Checkout code
uses: actions/checkout@v4
# The ubuntu images come with Node, npm and yarn pre-installed.
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md
# This action also handles the caching of the Yarn dependencies.
# https://github.com/actions/setup-node
- name: Set up node and enable caching of dependencies
uses: actions/setup-node@v4
with:
node-version-file: './.nvmrc'
cache: 'yarn'
- name: Yarn install
run: yarn install
- name: Show debug info
run: |
npm --version
node --version
yarn --version
grunt --version
yarn run jest --version
- name: Build all packages
run: yarn run build --ignore "@yoast/wordpress-seo"
- name: Show Jest version
run: yarn run jest --version
working-directory: packages/${{ matrix.package }}
- name: Show Config
run: yarn test --showConfig
working-directory: packages/${{ matrix.package }}
- name: Run Javascript tests
run: yarn test --ci --coverage
working-directory: packages/${{ matrix.package }}
- name: Upload coverage results to Coveralls
uses: coverallsapp/github-action@v2
env:
COVERALLS_SERVICE_NUMBER: ${{ github.sha }} # Connect all builds together.
with:
flag-name: package-${{ matrix.package }}
parallel: true
#########################################################################################
# For packages in this job, PRs will only run the tests related to changed files
# to make the build faster.
# For merges and pushes to select branches, the full test suite is still run.
# Packages should (only) be moved to this job if the full test run is exceedingly slow.
#########################################################################################
yarn-test-onlyChanged:
runs-on: ubuntu-latest
strategy:
# As these packages are all unique, don't stop the workflow when the test run of one package fails.
fail-fast: false
matrix:
include:
- package: 'yoastseo'
needs_premium_config: true
name: "TestJS - ${{ matrix.package }}${{ github.event_name == 'pull_request' && ' (onlyChanged)' || ' (full)' }}"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checks for changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # dorny/paths-filter@v3.0.2
id: changes
with:
filters: |
src:
- 'packages/${{ matrix.package }}/**'
# For pull requests, only run the full tests when touching this package.
- name: Checks if tests should be run
id: checks-run
run: |
echo "should=${{ github.event_name != 'pull_request' || steps.changes.outputs.src == 'true' }}" >> "$GITHUB_OUTPUT"
# Check out the premium config repo ahead of running the tests to prevent issues with permissions.
- name: Checkout premium configuration
if: ${{ steps.checks-run.outputs.should == 'true' && matrix.needs_premium_config == true }}
uses: actions/checkout@v4
with:
repository: Yoast/YoastSEO.js-premium-configuration
path: packages/yoastseo/premium-configuration
fetch-depth: 0
token: ${{ secrets.YOASTBOT_CI_PAT_DIST }}
# The ubuntu images come with Node, npm and yarn pre-installed.
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md
# This action also handles the caching of the Yarn dependencies.
# https://github.com/actions/setup-node
- name: Set up node and enable caching of dependencies
if: ${{ steps.checks-run.outputs.should == 'true' }}
uses: actions/setup-node@v4
with:
node-version-file: './.nvmrc'
cache: 'yarn'
- name: Yarn install
if: ${{ steps.checks-run.outputs.should == 'true' }}
run: yarn install
- name: Show debug info
if: ${{ steps.checks-run.outputs.should == 'true' }}
run: |
npm --version
node --version
yarn --version
grunt --version
yarn run jest --version
- name: Build all packages
if: ${{ steps.checks-run.outputs.should == 'true' }}
run: yarn run build --ignore "@yoast/wordpress-seo"
- name: Show Jest version
if: ${{ steps.checks-run.outputs.should == 'true' }}
run: yarn run jest --version
working-directory: packages/${{ matrix.package }}
- name: Show Config
if: ${{ steps.checks-run.outputs.should == 'true' }}
run: yarn test --showConfig
working-directory: packages/${{ matrix.package }}
- name: Run Javascript tests
if: ${{ steps.checks-run.outputs.should == 'true' }}
run: yarn test --ci --coverage
working-directory: packages/${{ matrix.package }}
- name: Upload coverage results to Coveralls
if: ${{ steps.checks-run.outputs.should == 'true' }}
uses: coverallsapp/github-action@v2
env:
COVERALLS_SERVICE_NUMBER: ${{ github.sha }} # Connect all builds together.
with:
flag-name: package-${{ matrix.package }}
parallel: true