find-cypress-specs 1.21.0 → 1.22.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.
- package/README.md +14 -0
- package/bin/find.js +10 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -19,6 +19,20 @@ $ npx find-cypress-specs --branch main
|
|
|
19
19
|
# prints only some specs, the ones that have changed against the "origin/main"
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
## set GitHub Actions outputs
|
|
23
|
+
|
|
24
|
+
If you add `--set-gh-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
|
|
25
|
+
|
|
26
|
+
```yml
|
|
27
|
+
- name: Print specs changed against the parent of this branch 🌳
|
|
28
|
+
# and set GitHub Actions output
|
|
29
|
+
id: step1
|
|
30
|
+
run: node ./bin/find --branch main --parent --set-gha-outputs
|
|
31
|
+
|
|
32
|
+
- name: Print set outputs
|
|
33
|
+
run: echo ${{ steps.step1.outputs.changedSpecsN }} ${{ steps.step1.outputs.changedSpecs }}
|
|
34
|
+
```
|
|
35
|
+
|
|
22
36
|
## against the parent commit
|
|
23
37
|
|
|
24
38
|
When dealing with a long-term branch, you do not want to see the changed files in the main branch. Instead, you want to only consider the specs changed in the _current_ branch all the way to its parent commit. You can pass the flag `--parent` to only pick the modified and added specs.
|
package/bin/find.js
CHANGED
|
@@ -12,6 +12,7 @@ const { getTestNames, countTags } = require('find-test-names')
|
|
|
12
12
|
const consoleTable = require('console.table')
|
|
13
13
|
const debug = require('debug')('find-cypress-specs')
|
|
14
14
|
const { getDependsInFolder } = require('spec-change')
|
|
15
|
+
const core = require('@actions/core')
|
|
15
16
|
|
|
16
17
|
const args = arg({
|
|
17
18
|
'--names': Boolean,
|
|
@@ -32,7 +33,10 @@ const args = arg({
|
|
|
32
33
|
// and consider specs that import a changes source file changed to
|
|
33
34
|
// The value of this argument is the subfolder with Cypress tests, like "cypress"
|
|
34
35
|
'--trace-imports': String,
|
|
35
|
-
|
|
36
|
+
// when enabled, this code uses GitHub Actions Core package
|
|
37
|
+
// to set two named outputs, one for number of changed specs
|
|
38
|
+
// another for actual list of files
|
|
39
|
+
'--set-gha-outputs': Boolean,
|
|
36
40
|
// aliases
|
|
37
41
|
'-n': '--names',
|
|
38
42
|
'--name': '--names',
|
|
@@ -160,6 +164,11 @@ if (args['--names'] || args['--tags']) {
|
|
|
160
164
|
}
|
|
161
165
|
let changedSpecs = specs.filter((file) => changedFiles.includes(file))
|
|
162
166
|
debug('changed %d specs %o', changedSpecs.length, changedSpecs)
|
|
167
|
+
if (args['--set-gha-outputs']) {
|
|
168
|
+
debug('setting GitHub Actions outputs changedSpecsN and changedSpecs')
|
|
169
|
+
core.setOutput('changedSpecsN', changedSpecs.length)
|
|
170
|
+
core.setOutput('changedSpecs', changedSpecs.join(','))
|
|
171
|
+
}
|
|
163
172
|
|
|
164
173
|
if (args['--tagged']) {
|
|
165
174
|
const splitTags = args['--tagged']
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "find-cypress-specs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.0",
|
|
4
4
|
"description": "Find Cypress spec files using the config settings",
|
|
5
5
|
"main": "src",
|
|
6
6
|
"files": [
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"typescript": "^4.6.3"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
+
"@actions/core": "^1.10.0",
|
|
55
56
|
"arg": "^5.0.1",
|
|
56
57
|
"console.table": "^0.10.0",
|
|
57
58
|
"debug": "^4.3.3",
|