find-cypress-specs 1.42.0 → 1.43.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/bin/find.js +42 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,6 +38,16 @@ $ npx find-cypress-specs --branch main
|
|
|
38
38
|
# prints only some specs, the ones that have changed against the "origin/main"
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
+
## find number of machines
|
|
42
|
+
|
|
43
|
+
If we find all the changed specs to run, we might need to decide how many machines we need. We can do a rough job by specifying the number of specs per machine plus the max number.
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
$ npx find-cypress-specs --branch main --specs-per-machine 4 --max-machines 5
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
For now, it is only useful when setting the GHA outputs.
|
|
50
|
+
|
|
41
51
|
## set GitHub Actions outputs
|
|
42
52
|
|
|
43
53
|
If you add `--set-gha-outputs` command line switch, then the number of changed specs and the comma-separated file list will be set as GH Actions outputs `changedSpecsN` and `changedSpecs`. See [pr.yml](./.github/workflows/pr.yml) for example
|
|
@@ -52,6 +62,8 @@ If you add `--set-gha-outputs` command line switch, then the number of changed s
|
|
|
52
62
|
run: echo ${{ steps.step1.outputs.changedSpecsN }} ${{ steps.step1.outputs.changedSpecs }}
|
|
53
63
|
```
|
|
54
64
|
|
|
65
|
+
If you set the number of machines, it will set the output `machinesNeeded`
|
|
66
|
+
|
|
55
67
|
## Write GitHub Actions job summary
|
|
56
68
|
|
|
57
69
|
You can output changes specs by using the parameter `--gha-summary`
|
package/bin/find.js
CHANGED
|
@@ -53,6 +53,9 @@ const args = arg({
|
|
|
53
53
|
'--update-badge': Boolean,
|
|
54
54
|
// output the list in Markdown format
|
|
55
55
|
'--markdown': Boolean,
|
|
56
|
+
// optional: output the number of machines needed to run the tests
|
|
57
|
+
'--specs-per-machine': Number,
|
|
58
|
+
'--max-machines': Number,
|
|
56
59
|
//
|
|
57
60
|
// aliases
|
|
58
61
|
'-n': '--names',
|
|
@@ -188,22 +191,55 @@ if (args['--test-counts']) {
|
|
|
188
191
|
})
|
|
189
192
|
}
|
|
190
193
|
|
|
194
|
+
let machinesNeeded
|
|
195
|
+
if (args['--specs-per-machine'] > 0 && args['--max-machines'] > 0) {
|
|
196
|
+
const specsPerMachine = args['--specs-per-machine']
|
|
197
|
+
const maxMachines = args['--max-machines']
|
|
198
|
+
machinesNeeded = Math.min(
|
|
199
|
+
Math.ceil(changedSpecs.length / specsPerMachine),
|
|
200
|
+
maxMachines,
|
|
201
|
+
)
|
|
202
|
+
debug(
|
|
203
|
+
'specs per machine %d with max %d machines',
|
|
204
|
+
specsPerMachine,
|
|
205
|
+
maxMachines,
|
|
206
|
+
)
|
|
207
|
+
debug(
|
|
208
|
+
'from %d specs, set %d output machinesNeeded',
|
|
209
|
+
changedSpecs.length,
|
|
210
|
+
machinesNeeded,
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
|
|
191
214
|
if (args['--set-gha-outputs']) {
|
|
192
215
|
debug('setting GitHub Actions outputs changedSpecsN and changedSpecs')
|
|
193
216
|
debug('changedSpecsN %d', changedSpecs.length)
|
|
194
217
|
debug('plus changedSpecs')
|
|
195
218
|
core.setOutput('changedSpecsN', changedSpecs.length)
|
|
196
219
|
core.setOutput('changedSpecs', changedSpecs.join(','))
|
|
220
|
+
core.setOutput('machinesNeeded', machinesNeeded)
|
|
197
221
|
}
|
|
222
|
+
|
|
198
223
|
if (args['--gha-summary']) {
|
|
199
224
|
debug('writing GitHub Actions summary')
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
225
|
+
let summary
|
|
226
|
+
|
|
227
|
+
if (changedSpecs.length > 0) {
|
|
228
|
+
summary = `Found that ${pluralize(
|
|
229
|
+
'spec',
|
|
230
|
+
changedSpecs.length,
|
|
231
|
+
true,
|
|
232
|
+
)} changed: ${changedSpecs.join(', ')}`
|
|
233
|
+
if (machinesNeeded > 0) {
|
|
234
|
+
summary += `\nestimated ${pluralize(
|
|
235
|
+
'machine',
|
|
236
|
+
machinesNeeded,
|
|
204
237
|
true,
|
|
205
|
-
)}
|
|
206
|
-
|
|
238
|
+
)} needed`
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
summary = 'No specs changed'
|
|
242
|
+
}
|
|
207
243
|
if (process.env.GITHUB_STEP_SUMMARY) {
|
|
208
244
|
core.summary.addRaw(summary).write()
|
|
209
245
|
} else {
|