diff --git a/.gdunit4_action/unit-test/index.js b/.gdunit4_action/unit-test/index.js index 3965ced..6524176 100644 --- a/.gdunit4_action/unit-test/index.js +++ b/.gdunit4_action/unit-test/index.js @@ -1,4 +1,3 @@ -const actionCore = require('@actions/core'); // renamed to avoid conflicts const pathLib = require("path"); const {spawnSync } = require("node:child_process"); @@ -22,17 +21,7 @@ function console_info(message) { } -function console_warning(message) { - actionCore.warning(message); -} - - -function setFailed(message) { - actionCore.setFailed(message); -} - - -async function runTests(exeArgs) { +async function runTests(exeArgs, core) { try { const { project_dir = '', @@ -47,9 +36,9 @@ async function runTests(exeArgs) { // verify support of multi paths/fixed since v4.2.1 if (pathsArray.length > 1 && process.env.GDUNIT_VERSION === "v4.2.0") { - console_warning(`Multiple path arguments not supported by GdUnit ${process.env.GDUNIT_VERSION}, please upgrade to GdUnit4 v4.2.1`); + core.warning(`Multiple path arguments not supported by GdUnit ${process.env.GDUNIT_VERSION}, please upgrade to GdUnit4 v4.2.1`); pathsArray.length = 1; - console_warning(`Use only the first entry of paths, ${pathsArray}!`); + core.warning(`Use only the first entry of paths, ${pathsArray}!`); } const args = [ @@ -87,7 +76,7 @@ async function runTests(exeArgs) { // Handle spawn errors if (child.error) { - actionCore.setFailed(`Run Godot process ends with error: ${child.error}`); + core.setFailed(`Run Godot process ends with error: ${child.error}`); return RETURN_ERROR_ABNORMAL_TERMINATED; } @@ -98,41 +87,41 @@ async function runTests(exeArgs) { } retriesCount++; if (retriesCount <= retries) { - console_warning(`Test run failed, retrying... ${retriesCount} of ${retries}`); + core.warning(`Test run failed, retrying... ${retriesCount} of ${retries}`); } } switch (exitCode) { case RETURN_SUCCESS: if (retriesCount > 0 && retries > 0) { - console_warning(`The tests was successfully after ${retriesCount} retries with exit code: ${exitCode}`); + core.warning(`The tests was successfully after ${retriesCount} retries with exit code: ${exitCode}`); } else { console_info(`The tests was successfully with exit code: ${exitCode}`); } break; case RETURN_ERROR: - setFailed(`The tests was failed after ${retries} retries with exit code: ${exitCode}`); + core.setFailed(`The tests was failed after ${retries} retries with exit code: ${exitCode}`); break; case RETURN_WARNING: if (warningsAsErrors === true) { - setFailed(`Tests completed with warnings (treated as errors)`); + core.setFailed(`Tests completed with warnings (treated as errors)`); } else { - console_warning('Tests completed successfully with warnings'); + core.warning('Tests completed successfully with warnings'); } break; case RETURN_ERROR_HEADLESS_NOT_SUPPORTED: - setFailed('Headless mode not supported'); + core.setFailed('Headless mode not supported'); break; case RETURN_ERROR_GODOT_VERSION_NOT_SUPPORTED: - setFailed('Godot version not supported'); + core.setFailed('Godot version not supported'); break; default: - setFailed(`Tests failed with unknown error code: ${exitCode}`); + core.setFailed(`Tests failed with unknown error code: ${exitCode}`); } return exitCode; } catch (error) { - setFailed(`Tests failed: ${error.message}`); + core.setFailed(`Tests failed: ${error.message}`); return RETURN_ERROR; } } diff --git a/action.yml b/action.yml index f2a45a5..8474694 100644 --- a/action.yml +++ b/action.yml @@ -203,12 +203,6 @@ runs: $GODOT_BIN --path ./ -e --headless --quit-after 2000 echo -e "\e[94mProject cache successfully restored.\e[0m" - - name: 'Install node modules' - if: ${{ !cancelled() && env.RUN_GDSCRIPT_TESTS == 'true'}} - shell: bash - run: | - npm install - ## GDScript test run - name: 'Run GDScript Tests' id: test-run @@ -227,7 +221,7 @@ runs: retries: ${{ inputs.retries }}, warningsAsErrors : ${{ inputs.warnings-as-errors }} }; - const exitCode = await runTests(args); + const exitCode = await runTests(args, core); core.setOutput('exit_code', exitCode); - name: 'Publish GDScript Unit Test Reports'