find-cypress-specs 1.42.0 → 1.43.0

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.
Files changed (3) hide show
  1. package/README.md +12 -0
  2. package/bin/find.js +25 -0
  3. 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,13 +191,35 @@ 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
225
  const summary = changedSpecs.length
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "find-cypress-specs",
3
- "version": "1.42.0",
3
+ "version": "1.43.0",
4
4
  "description": "Find Cypress spec files using the config settings",
5
5
  "main": "src",
6
6
  "files": [