@cypress/github-action 6.8.0 → 6.9.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 +16 -6
- package/dist/index.js +49 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -931,7 +931,19 @@ If you do not commit a lock file to the repository, you cannot use the action to
|
|
|
931
931
|
|
|
932
932
|
### Command prefix
|
|
933
933
|
|
|
934
|
-
You can prefix
|
|
934
|
+
You can prefix a test command using the `command-prefix` parameter. This is useful, for example, when running [BrowserStack Percy](https://www.browserstack.com/docs/percy/integrate/cypress), which requires the test command to be prefixed with `percy exec --`. When this parameter is used, the action constructs and executes a CLI command using [npx](https://docs.npmjs.com/cli/v11/commands/npx) in the following form:
|
|
935
|
+
|
|
936
|
+
```shell
|
|
937
|
+
npx <command-prefix> cypress run <cli run options>
|
|
938
|
+
```
|
|
939
|
+
|
|
940
|
+
where the `<command-prefix>` is the literal string value from the `command-prefix` parameter and `<cli run options>` are put together from action parameters such as the value of the `browser` parameter. The complete constructed command is shown in the logs. For the example below, this is shown as:
|
|
941
|
+
|
|
942
|
+
```text
|
|
943
|
+
Cypress test command: npx percy exec -- npx cypress run --browser chrome
|
|
944
|
+
```
|
|
945
|
+
|
|
946
|
+
Since `command-prefix` is run using `npx`, it is compatible with [npm](https://docs.npmjs.com/cli/v11/) and [Yarn Classic](https://classic.yarnpkg.com/). It may also be used with [pnpm](https://pnpm.io/settings#nodelinker) and [Yarn Modern](https://yarnpkg.com/configuration/yarnrc#nodeLinker) when they are configured for `nodeLinker` compatibility with the `node_modules` directory structure of npm. An alternative to using `command-prefix` is to pass a complete [command](#custom-test-command) parameter instead, including the exact command to be passed to the CLI.
|
|
935
947
|
|
|
936
948
|
```yml
|
|
937
949
|
name: Visual
|
|
@@ -945,14 +957,12 @@ jobs:
|
|
|
945
957
|
- name: Cypress run
|
|
946
958
|
uses: cypress-io/github-action@v6
|
|
947
959
|
with:
|
|
948
|
-
start: npm start
|
|
949
|
-
# quote the url to be safe against YML parsing surprises
|
|
950
|
-
wait-on: 'http://localhost:8080'
|
|
951
|
-
# the entire command will automatically be prefixed with "npm"
|
|
952
|
-
# and we need the second "npm" to execute "cypress run ..." command line
|
|
953
960
|
command-prefix: 'percy exec -- npx'
|
|
961
|
+
browser: chrome
|
|
954
962
|
```
|
|
955
963
|
|
|
964
|
+
If `command-prefix` is used, then no [job summary](#job-summary-title) is produced, since it runs Cypress with a CLI [cypress run](https://on.cypress.io/app/references/command-line#cypress-run) command instead of using the [Cypress Module API](https://docs.cypress.io/app/references/module-api). The `command` parameter overrides the `command-prefix` parameter, preventing these two parameters from being used together.
|
|
965
|
+
|
|
956
966
|
### Custom test command
|
|
957
967
|
|
|
958
968
|
You can overwrite the Cypress run command with your own command.
|
package/dist/index.js
CHANGED
|
@@ -93982,10 +93982,58 @@ const runTestsUsingCommandLine = async () => {
|
|
|
93982
93982
|
|
|
93983
93983
|
return exec.exec(quote(npxPath), cmd, opts)
|
|
93984
93984
|
}
|
|
93985
|
+
/**
|
|
93986
|
+
* Validate input parameters for consistency when command parameter is used
|
|
93987
|
+
* Output GitHub actions annotation warning if ignored parameters are used
|
|
93988
|
+
*/
|
|
93989
|
+
const commandIgnoredBooleanInputs = [
|
|
93990
|
+
// parameter name, default value
|
|
93991
|
+
['component', false],
|
|
93992
|
+
['headed', false],
|
|
93993
|
+
['parallel', false],
|
|
93994
|
+
['quiet', false],
|
|
93995
|
+
['record', false],
|
|
93996
|
+
['publish-summary', true]
|
|
93997
|
+
]
|
|
93998
|
+
const commandIgnoredStringInputs = [
|
|
93999
|
+
'auto-cancel-after-failures',
|
|
94000
|
+
'browser',
|
|
94001
|
+
'ci-build-id',
|
|
94002
|
+
'config',
|
|
94003
|
+
'config-file',
|
|
94004
|
+
'env',
|
|
94005
|
+
'group',
|
|
94006
|
+
'project',
|
|
94007
|
+
'spec',
|
|
94008
|
+
'tag',
|
|
94009
|
+
'command-prefix',
|
|
94010
|
+
'summary-title'
|
|
94011
|
+
]
|
|
94012
|
+
let ignoredInputParameters = []
|
|
94013
|
+
const validateCustomCommand = () => {
|
|
94014
|
+
commandIgnoredBooleanInputs.forEach((input) => {
|
|
94015
|
+
const inputParameter = input[0]
|
|
94016
|
+
const inputDefault = input[1]
|
|
94017
|
+
if (getInputBool(inputParameter) !== inputDefault) {
|
|
94018
|
+
ignoredInputParameters.push(inputParameter)
|
|
94019
|
+
}
|
|
94020
|
+
})
|
|
94021
|
+
commandIgnoredStringInputs.forEach((input) => {
|
|
94022
|
+
if (core.getInput(input)) {
|
|
94023
|
+
ignoredInputParameters.push(input)
|
|
94024
|
+
}
|
|
94025
|
+
})
|
|
94026
|
+
if (ignoredInputParameters.length > 0) {
|
|
94027
|
+
core.warning(
|
|
94028
|
+
`command parameter is used and the following other parameters are ignored: ${ignoredInputParameters.sort().join(', ')}.`
|
|
94029
|
+
)
|
|
94030
|
+
}
|
|
94031
|
+
}
|
|
93985
94032
|
|
|
93986
94033
|
/**
|
|
93987
94034
|
* Run Cypress tests by collecting input parameters
|
|
93988
94035
|
* and using Cypress module API to run tests.
|
|
94036
|
+
* If command parameter is specified, then run using @actions/exec instead.
|
|
93989
94037
|
* @see https://on.cypress.io/module-api
|
|
93990
94038
|
*/
|
|
93991
94039
|
const runTests = async () => {
|
|
@@ -94014,6 +94062,7 @@ const runTests = async () => {
|
|
|
94014
94062
|
|
|
94015
94063
|
if (customCommand) {
|
|
94016
94064
|
console.log('Using custom test command: %s', customCommand)
|
|
94065
|
+
validateCustomCommand() // catch ignored parameters and output warning
|
|
94017
94066
|
return execCommand(customCommand, true, 'run tests')
|
|
94018
94067
|
}
|
|
94019
94068
|
|