Skip to content

Commit

Permalink
GD-61: Remove the npm install (#63)
Browse files Browse the repository at this point in the history
# Why
We do not want to report warnings as errors by default.

# What
Introducing a new option  `warnings-as-errors` with default false to control the final job result
  • Loading branch information
MikeSchulze authored Jan 29, 2025
1 parent 1951e9b commit bc24087
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 31 deletions.
37 changes: 13 additions & 24 deletions .gdunit4_action/unit-test/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const actionCore = require('@actions/core'); // renamed to avoid conflicts
const pathLib = require("path");
const {spawnSync } = require("node:child_process");

Expand All @@ -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 = '',
Expand All @@ -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 = [
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand Down
8 changes: 1 addition & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down

0 comments on commit bc24087

Please sign in to comment.