Allow action to run locally

Update test workflows

Test Action: wget quiretly

Test Action: Install for user

Check condition on string

Cleanup and update test action

Run on runner: debug

Run on runner: debug

Run on runner: debug

Run on runner: debug

Run on runner: debug

Run on runner: debug

Run on runner: debug

Run on runner: debug

Run on runner: debug

Run on runner: debug
This commit is contained in:
Layla 2021-02-11 18:14:40 -05:00
parent ce937f3dd5
commit 5af87a011e
6 changed files with 241 additions and 105 deletions

View File

@ -3,13 +3,26 @@ name: Test Action
on: [push, pull_request]
jobs:
TestAction:
test_1:
name: "Test Action with Container"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run Action
id: run_tests
uses: ./
with:
directory: test_proj
test_2:
name: "Test Action Locally"
runs-on: ubuntu-latest
container:
image: barichello/godot-ci:latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run Action
uses: ./
with:
directory: test_proj
useContainer: false

View File

@ -26,6 +26,10 @@ steps:
The name directory to run tests within. Defaults to the current directory.
#### useContainer
Boolean value of whether or not to run container. Defaults to `true`
## Configure GUT
This action requires you to configure GUT using the `.gutconfig.json` file which would be located in the root directory of your project.

View File

@ -5,6 +5,9 @@ inputs:
containerImage:
description: "The container to run tests inside of."
default: "barichello/godot-ci:latest"
useContainer:
description: "Boolean value of whether or not to run container."
default: true
directory:
description: "The name directory to run tests in."
runs:

133
dist/index.js vendored
View File

@ -1193,6 +1193,32 @@ formatters.O = function (v) {
};
/***/ }),
/***/ 82:
/***/ (function(__unusedmodule, exports) {
"use strict";
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
*/
function toCommandValue(input) {
if (input === null || input === undefined) {
return '';
}
else if (typeof input === 'string' || input instanceof String) {
return input;
}
return JSON.stringify(input);
}
exports.toCommandValue = toCommandValue;
//# sourceMappingURL=utils.js.map
/***/ }),
/***/ 87:
@ -1715,6 +1741,42 @@ ServerStderr.prototype._write = function(data, encoding, cb) {
module.exports = Channel;
/***/ }),
/***/ 102:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
// For internal use, subject to change.
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
const fs = __importStar(__webpack_require__(747));
const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(82);
function issueCommand(command, message) {
const filePath = process.env[`GITHUB_${command}`];
if (!filePath) {
throw new Error(`Unable to find environment variable for file command ${command}`);
}
if (!fs.existsSync(filePath)) {
throw new Error(`Missing file at path: ${filePath}`);
}
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
encoding: 'utf8'
});
}
exports.issueCommand = issueCommand;
//# sourceMappingURL=file-command.js.map
/***/ }),
/***/ 107:
@ -12178,6 +12240,7 @@ function plural(ms, msAbs, n, name) {
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
const core = __webpack_require__(470);
const { spawnSync } = __webpack_require__(129);
const fs = __webpack_require__(747);
const path = __webpack_require__(622)
@ -12190,12 +12253,16 @@ try {
// Get inputs
var docker_image = core.getInput('containerImage');
var work_dir = core.getInput('directory');
var use_container = core.getInput('useContainer');
if(work_dir)
{
process.chdir(work_dir);
}
if(use_container == "true")
{
// Pull docker image for building
console.log("Pulling build image...");
docker.pull(docker_image, function(err, stream)
@ -12231,6 +12298,22 @@ try {
function onProgress(event) {}
});
}
else
{
console.log("Running GUT tests locally");
var result = spawnSync('godot -d -s --path . addons/gut/gut_cmdln.gd', {
stdio: 'inherit',
shell: true
});
if(result.status != null && result.status != 0)
{
core.setFailed("GUT tests failed!");
}
}
} catch (error) {
core.setFailed(error.message);
@ -14343,6 +14426,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(82);
/**
* Commands
*
@ -14396,28 +14480,14 @@ class Command {
return cmdStr;
}
}
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
*/
function toCommandValue(input) {
if (input === null || input === undefined) {
return '';
}
else if (typeof input === 'string' || input instanceof String) {
return input;
}
return JSON.stringify(input);
}
exports.toCommandValue = toCommandValue;
function escapeData(s) {
return toCommandValue(s)
return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A');
}
function escapeProperty(s) {
return toCommandValue(s)
return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A')
@ -14760,6 +14830,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = __webpack_require__(431);
const file_command_1 = __webpack_require__(102);
const utils_1 = __webpack_require__(82);
const os = __importStar(__webpack_require__(87));
const path = __importStar(__webpack_require__(622));
/**
@ -14786,9 +14858,17 @@ var ExitCode;
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function exportVariable(name, val) {
const convertedVal = command_1.toCommandValue(val);
const convertedVal = utils_1.toCommandValue(val);
process.env[name] = convertedVal;
const filePath = process.env['GITHUB_ENV'] || '';
if (filePath) {
const delimiter = '_GitHubActionsFileCommandDelimeter_';
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
file_command_1.issueCommand('ENV', commandValue);
}
else {
command_1.issueCommand('set-env', { name }, convertedVal);
}
}
exports.exportVariable = exportVariable;
/**
@ -14804,7 +14884,13 @@ exports.setSecret = setSecret;
* @param inputPath
*/
function addPath(inputPath) {
const filePath = process.env['GITHUB_PATH'] || '';
if (filePath) {
file_command_1.issueCommand('PATH', inputPath);
}
else {
command_1.issueCommand('add-path', {}, inputPath);
}
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
}
exports.addPath = addPath;
@ -25582,12 +25668,13 @@ BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
if (bytes > l) {
this._bufs[i].copy(dst, bufoff, start)
bufoff += l
} else {
this._bufs[i].copy(dst, bufoff, start, start + bytes)
bufoff += l
break
}
bufoff += l
bytes -= l
if (start) {
@ -25595,6 +25682,9 @@ BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
}
}
// safeguard so that we don't return uninitialized memory
if (dst.length > bufoff) return dst.slice(0, bufoff)
return dst
}
@ -25636,6 +25726,11 @@ BufferList.prototype.toString = function toString (encoding, start, end) {
}
BufferList.prototype.consume = function consume (bytes) {
// first, normalize the argument, in accordance with how Buffer does it
bytes = Math.trunc(bytes)
// do nothing if not a positive number
if (Number.isNaN(bytes) || bytes <= 0) return this
while (this._bufs.length) {
if (bytes >= this._bufs[0].length) {
bytes -= this._bufs[0].length
@ -26295,7 +26390,7 @@ try {
/***/ 724:
/***/ (function(module) {
module.exports = {"_from":"ssh2-streams@~0.4.10","_id":"ssh2-streams@0.4.10","_inBundle":false,"_integrity":"sha512-8pnlMjvnIZJvmTzUIIA5nT4jr2ZWNNVHwyXfMGdRJbug9TpI3kd99ffglgfSWqujVv/0gxwMsDn9j9RVst8yhQ==","_location":"/ssh2-streams","_phantomChildren":{},"_requested":{"type":"range","registry":true,"raw":"ssh2-streams@~0.4.10","name":"ssh2-streams","escapedName":"ssh2-streams","rawSpec":"~0.4.10","saveSpec":null,"fetchSpec":"~0.4.10"},"_requiredBy":["/ssh2"],"_resolved":"https://registry.npmjs.org/ssh2-streams/-/ssh2-streams-0.4.10.tgz","_shasum":"48ef7e8a0e39d8f2921c30521d56dacb31d23a34","_spec":"ssh2-streams@~0.4.10","_where":"/var/home/vetra/Projects/run-gut-tests-action/node_modules/ssh2","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"bugs":{"url":"https://github.com/mscdex/ssh2-streams/issues"},"bundleDependencies":false,"dependencies":{"asn1":"~0.2.0","bcrypt-pbkdf":"^1.0.2","streamsearch":"~0.1.2"},"deprecated":false,"description":"SSH2 and SFTP(v3) client/server protocol streams for node.js","engines":{"node":">=5.2.0"},"homepage":"https://github.com/mscdex/ssh2-streams#readme","keywords":["ssh","ssh2","sftp","secure","protocol","streams","client","server"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/ssh2-streams/raw/master/LICENSE"}],"main":"./index","name":"ssh2-streams","repository":{"type":"git","url":"git+ssh://git@github.com/mscdex/ssh2-streams.git"},"scripts":{"test":"node test/test.js"},"version":"0.4.10"};
module.exports = {"_args":[["ssh2-streams@0.4.10","/home/manley/Projects/run-gut-tests-action"]],"_from":"ssh2-streams@0.4.10","_id":"ssh2-streams@0.4.10","_inBundle":false,"_integrity":"sha512-8pnlMjvnIZJvmTzUIIA5nT4jr2ZWNNVHwyXfMGdRJbug9TpI3kd99ffglgfSWqujVv/0gxwMsDn9j9RVst8yhQ==","_location":"/ssh2-streams","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"ssh2-streams@0.4.10","name":"ssh2-streams","escapedName":"ssh2-streams","rawSpec":"0.4.10","saveSpec":null,"fetchSpec":"0.4.10"},"_requiredBy":["/ssh2"],"_resolved":"https://registry.npmjs.org/ssh2-streams/-/ssh2-streams-0.4.10.tgz","_spec":"0.4.10","_where":"/home/manley/Projects/run-gut-tests-action","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"bugs":{"url":"https://github.com/mscdex/ssh2-streams/issues"},"dependencies":{"asn1":"~0.2.0","bcrypt-pbkdf":"^1.0.2","streamsearch":"~0.1.2"},"description":"SSH2 and SFTP(v3) client/server protocol streams for node.js","engines":{"node":">=5.2.0"},"homepage":"https://github.com/mscdex/ssh2-streams#readme","keywords":["ssh","ssh2","sftp","secure","protocol","streams","client","server"],"licenses":[{"type":"MIT","url":"http://github.com/mscdex/ssh2-streams/raw/master/LICENSE"}],"main":"./index","name":"ssh2-streams","repository":{"type":"git","url":"git+ssh://git@github.com/mscdex/ssh2-streams.git"},"scripts":{"test":"node test/test.js"},"version":"0.4.10"};
/***/ }),

21
main.js
View File

@ -1,4 +1,5 @@
const core = require('@actions/core');
const { spawnSync } = require("child_process");
const fs = require('fs');
const path = require('path')
@ -11,12 +12,16 @@ try {
// Get inputs
var docker_image = core.getInput('containerImage');
var work_dir = core.getInput('directory');
var use_container = core.getInput('useContainer');
if(work_dir)
{
process.chdir(work_dir);
}
if(use_container == "true")
{
// Pull docker image for building
console.log("Pulling build image...");
docker.pull(docker_image, function(err, stream)
@ -52,6 +57,22 @@ try {
function onProgress(event) {}
});
}
else
{
console.log("Running GUT tests locally");
var result = spawnSync('godot -d -s --path . addons/gut/gut_cmdln.gd', {
stdio: 'inherit',
shell: true
});
if(result.status != null && result.status != 0)
{
core.setFailed("GUT tests failed!");
}
}
} catch (error) {
core.setFailed(error.message);

View File

@ -23,4 +23,4 @@
"@zeit/ncc": "^0.22.3",
"dockerode": "^3.2.1"
}
}
}