From 728eb39a708ef1ba3634940394e2d5222d29bdde Mon Sep 17 00:00:00 2001 From: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> Date: Tue, 29 Apr 2025 15:19:56 +0200 Subject: [PATCH 1/2] feat: validate other parameters against command parameter when used --- dist/index.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ index.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/dist/index.js b/dist/index.js index ca75c807d..99bc887f4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -93982,10 +93982,57 @@ const runTestsUsingCommandLine = async () => { return exec.exec(quote(npxPath), cmd, opts) } +/** + * Validate input parameters for consistency when command parameter is used + * Output GitHub actions annotation warning if ignored parameters are used + */ +const commandIgnoredBooleanInputs = [ + // parameter name, default value + [`component`, false], + [`headed`, false], + [`parallel`, false], + [`quiet`, false], + [`record`, false], + [`publish-summary`, true] +] +const commandIgnoredStringInputs = [ + `auto-cancel-after-failures`, + `browser`, + `ci-build-id`, + `config`, + `config-file`, + `group`, + `project`, + `spec`, + `tag`, + `command-prefix`, + `summary-title` +] +let ignoredInputParameters = [] +const validateCustomCommand = () => { + commandIgnoredBooleanInputs.forEach((input) => { + const inputParameter = input[0] + const inputDefault = input[1] + if (getInputBool(inputParameter) !== inputDefault) { + ignoredInputParameters.push(inputParameter) + } + }) + commandIgnoredStringInputs.forEach((input) => { + if (core.getInput(input)) { + ignoredInputParameters.push(input) + } + }) + if (ignoredInputParameters.length > 0) { + core.warning( + `command parameter is used and the following other parameters are ignored: ${ignoredInputParameters.sort().join(', ')}.` + ) + } +} /** * Run Cypress tests by collecting input parameters * and using Cypress module API to run tests. + * If command parameter is specified, then run using @actions/exec instead. * @see https://on.cypress.io/module-api */ const runTests = async () => { @@ -94014,6 +94061,7 @@ const runTests = async () => { if (customCommand) { console.log('Using custom test command: %s', customCommand) + validateCustomCommand() // catch ignored parameters and output warning return execCommand(customCommand, true, 'run tests') } diff --git a/index.js b/index.js index 2ef4d6d60..d41eeb42f 100644 --- a/index.js +++ b/index.js @@ -719,10 +719,57 @@ const runTestsUsingCommandLine = async () => { return exec.exec(quote(npxPath), cmd, opts) } +/** + * Validate input parameters for consistency when command parameter is used + * Output GitHub actions annotation warning if ignored parameters are used + */ +const commandIgnoredBooleanInputs = [ + // parameter name, default value + [`component`, false], + [`headed`, false], + [`parallel`, false], + [`quiet`, false], + [`record`, false], + [`publish-summary`, true] +] +const commandIgnoredStringInputs = [ + `auto-cancel-after-failures`, + `browser`, + `ci-build-id`, + `config`, + `config-file`, + `group`, + `project`, + `spec`, + `tag`, + `command-prefix`, + `summary-title` +] +let ignoredInputParameters = [] +const validateCustomCommand = () => { + commandIgnoredBooleanInputs.forEach((input) => { + const inputParameter = input[0] + const inputDefault = input[1] + if (getInputBool(inputParameter) !== inputDefault) { + ignoredInputParameters.push(inputParameter) + } + }) + commandIgnoredStringInputs.forEach((input) => { + if (core.getInput(input)) { + ignoredInputParameters.push(input) + } + }) + if (ignoredInputParameters.length > 0) { + core.warning( + `command parameter is used and the following other parameters are ignored: ${ignoredInputParameters.sort().join(', ')}.` + ) + } +} /** * Run Cypress tests by collecting input parameters * and using Cypress module API to run tests. + * If command parameter is specified, then run using @actions/exec instead. * @see https://on.cypress.io/module-api */ const runTests = async () => { @@ -751,6 +798,7 @@ const runTests = async () => { if (customCommand) { console.log('Using custom test command: %s', customCommand) + validateCustomCommand() // catch ignored parameters and output warning return execCommand(customCommand, true, 'run tests') } From f85f4d5e320d3d5755bd59a89e150bccf7bb38fa Mon Sep 17 00:00:00 2001 From: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> Date: Tue, 29 Apr 2025 16:59:19 +0200 Subject: [PATCH 2/2] add env and change quotes --- dist/index.js | 35 ++++++++++++++++++----------------- index.js | 35 ++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/dist/index.js b/dist/index.js index 99bc887f4..378070809 100644 --- a/dist/index.js +++ b/dist/index.js @@ -93988,25 +93988,26 @@ const runTestsUsingCommandLine = async () => { */ const commandIgnoredBooleanInputs = [ // parameter name, default value - [`component`, false], - [`headed`, false], - [`parallel`, false], - [`quiet`, false], - [`record`, false], - [`publish-summary`, true] + ['component', false], + ['headed', false], + ['parallel', false], + ['quiet', false], + ['record', false], + ['publish-summary', true] ] const commandIgnoredStringInputs = [ - `auto-cancel-after-failures`, - `browser`, - `ci-build-id`, - `config`, - `config-file`, - `group`, - `project`, - `spec`, - `tag`, - `command-prefix`, - `summary-title` + 'auto-cancel-after-failures', + 'browser', + 'ci-build-id', + 'config', + 'config-file', + 'env', + 'group', + 'project', + 'spec', + 'tag', + 'command-prefix', + 'summary-title' ] let ignoredInputParameters = [] const validateCustomCommand = () => { diff --git a/index.js b/index.js index d41eeb42f..de026c3f5 100644 --- a/index.js +++ b/index.js @@ -725,25 +725,26 @@ const runTestsUsingCommandLine = async () => { */ const commandIgnoredBooleanInputs = [ // parameter name, default value - [`component`, false], - [`headed`, false], - [`parallel`, false], - [`quiet`, false], - [`record`, false], - [`publish-summary`, true] + ['component', false], + ['headed', false], + ['parallel', false], + ['quiet', false], + ['record', false], + ['publish-summary', true] ] const commandIgnoredStringInputs = [ - `auto-cancel-after-failures`, - `browser`, - `ci-build-id`, - `config`, - `config-file`, - `group`, - `project`, - `spec`, - `tag`, - `command-prefix`, - `summary-title` + 'auto-cancel-after-failures', + 'browser', + 'ci-build-id', + 'config', + 'config-file', + 'env', + 'group', + 'project', + 'spec', + 'tag', + 'command-prefix', + 'summary-title' ] let ignoredInputParameters = [] const validateCustomCommand = () => {