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] on: [push, pull_request]
jobs: jobs:
TestAction: test_1:
name: "Test Action with Container"
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Run Action - name: Run Action
id: run_tests
uses: ./ uses: ./
with: with:
directory: test_proj 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. 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 ## 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. 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: containerImage:
description: "The container to run tests inside of." description: "The container to run tests inside of."
default: "barichello/godot-ci:latest" default: "barichello/godot-ci:latest"
useContainer:
description: "Boolean value of whether or not to run container."
default: true
directory: directory:
description: "The name directory to run tests in." description: "The name directory to run tests in."
runs: runs:

193
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: /***/ 87:
@ -1715,6 +1741,42 @@ ServerStderr.prototype._write = function(data, encoding, cb) {
module.exports = Channel; 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: /***/ 107:
@ -12178,6 +12240,7 @@ function plural(ms, msAbs, n, name) {
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) { /***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
const core = __webpack_require__(470); const core = __webpack_require__(470);
const { spawnSync } = __webpack_require__(129);
const fs = __webpack_require__(747); const fs = __webpack_require__(747);
const path = __webpack_require__(622) const path = __webpack_require__(622)
@ -12190,47 +12253,67 @@ try {
// Get inputs // Get inputs
var docker_image = core.getInput('containerImage'); var docker_image = core.getInput('containerImage');
var work_dir = core.getInput('directory'); var work_dir = core.getInput('directory');
var use_container = core.getInput('useContainer');
if(work_dir) if(work_dir)
{ {
process.chdir(work_dir); process.chdir(work_dir);
} }
// Pull docker image for building if(use_container == "true")
console.log("Pulling build image..."); {
docker.pull(docker_image, function(err, stream)
{
docker.modem.followProgress(stream, onFinished, onProgress); // Pull docker image for building
console.log("Pulling build image...");
// Wait to run build until after pull complete docker.pull(docker_image, function(err, stream)
function onFinished(err, output)
{ {
console.log("Starting image...")
docker.run(docker_image, ['godot', '-d', '-s', '--path', '/project', 'addons/gut/gut_cmdln.gd'], process.stdout, docker.modem.followProgress(stream, onFinished, onProgress);
// Wait to run build until after pull complete
function onFinished(err, output)
{
console.log("Starting image...")
docker.run(docker_image, ['godot', '-d', '-s', '--path', '/project', 'addons/gut/gut_cmdln.gd'], process.stdout,
// Mount working directory to `/project`
{ HostConfig: { Binds: [ process.cwd() + ":/project" ] }},
function (err, data, container) {
if(err)
{
core.setFailed(error.message);
}
console.log("Tests exited with status: " + data.StatusCode);
if( data.StatusCode != "0" )
{
core.setFailed("GUT tests failed!");
}
// Mount working directory to `/project` })
{ HostConfig: { Binds: [ process.cwd() + ":/project" ] }}, }
function onProgress(event) {}
function (err, data, container) {
if(err) });
{ }
core.setFailed(error.message); else
} {
console.log("Running GUT tests locally");
console.log("Tests exited with status: " + data.StatusCode); var result = spawnSync('godot -d -s --path . addons/gut/gut_cmdln.gd', {
stdio: 'inherit',
shell: true
});
if( data.StatusCode != "0" ) if(result.status != null && result.status != 0)
{ {
core.setFailed("GUT tests failed!"); core.setFailed("GUT tests failed!");
}
})
} }
function onProgress(event) {}
}
});
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
@ -14343,6 +14426,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const os = __importStar(__webpack_require__(87)); const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(82);
/** /**
* Commands * Commands
* *
@ -14396,28 +14480,14 @@ class Command {
return cmdStr; 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) { function escapeData(s) {
return toCommandValue(s) return utils_1.toCommandValue(s)
.replace(/%/g, '%25') .replace(/%/g, '%25')
.replace(/\r/g, '%0D') .replace(/\r/g, '%0D')
.replace(/\n/g, '%0A'); .replace(/\n/g, '%0A');
} }
function escapeProperty(s) { function escapeProperty(s) {
return toCommandValue(s) return utils_1.toCommandValue(s)
.replace(/%/g, '%25') .replace(/%/g, '%25')
.replace(/\r/g, '%0D') .replace(/\r/g, '%0D')
.replace(/\n/g, '%0A') .replace(/\n/g, '%0A')
@ -14760,6 +14830,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = __webpack_require__(431); 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 os = __importStar(__webpack_require__(87));
const path = __importStar(__webpack_require__(622)); const path = __importStar(__webpack_require__(622));
/** /**
@ -14786,9 +14858,17 @@ var ExitCode;
*/ */
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
function exportVariable(name, val) { function exportVariable(name, val) {
const convertedVal = command_1.toCommandValue(val); const convertedVal = utils_1.toCommandValue(val);
process.env[name] = convertedVal; process.env[name] = convertedVal;
command_1.issueCommand('set-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; exports.exportVariable = exportVariable;
/** /**
@ -14804,7 +14884,13 @@ exports.setSecret = setSecret;
* @param inputPath * @param inputPath
*/ */
function addPath(inputPath) { function addPath(inputPath) {
command_1.issueCommand('add-path', {}, 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']}`; process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
} }
exports.addPath = addPath; exports.addPath = addPath;
@ -25582,12 +25668,13 @@ BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
if (bytes > l) { if (bytes > l) {
this._bufs[i].copy(dst, bufoff, start) this._bufs[i].copy(dst, bufoff, start)
bufoff += l
} else { } else {
this._bufs[i].copy(dst, bufoff, start, start + bytes) this._bufs[i].copy(dst, bufoff, start, start + bytes)
bufoff += l
break break
} }
bufoff += l
bytes -= l bytes -= l
if (start) { 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 return dst
} }
@ -25636,6 +25726,11 @@ BufferList.prototype.toString = function toString (encoding, start, end) {
} }
BufferList.prototype.consume = function consume (bytes) { 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) { while (this._bufs.length) {
if (bytes >= this._bufs[0].length) { if (bytes >= this._bufs[0].length) {
bytes -= this._bufs[0].length bytes -= this._bufs[0].length
@ -26295,7 +26390,7 @@ try {
/***/ 724: /***/ 724:
/***/ (function(module) { /***/ (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"};
/***/ }), /***/ }),

77
main.js
View File

@ -1,4 +1,5 @@
const core = require('@actions/core'); const core = require('@actions/core');
const { spawnSync } = require("child_process");
const fs = require('fs'); const fs = require('fs');
const path = require('path') const path = require('path')
@ -11,47 +12,67 @@ try {
// Get inputs // Get inputs
var docker_image = core.getInput('containerImage'); var docker_image = core.getInput('containerImage');
var work_dir = core.getInput('directory'); var work_dir = core.getInput('directory');
var use_container = core.getInput('useContainer');
if(work_dir) if(work_dir)
{ {
process.chdir(work_dir); process.chdir(work_dir);
} }
// Pull docker image for building if(use_container == "true")
console.log("Pulling build image..."); {
docker.pull(docker_image, function(err, stream)
{
docker.modem.followProgress(stream, onFinished, onProgress); // Pull docker image for building
console.log("Pulling build image...");
// Wait to run build until after pull complete docker.pull(docker_image, function(err, stream)
function onFinished(err, output)
{ {
console.log("Starting image...")
docker.run(docker_image, ['godot', '-d', '-s', '--path', '/project', 'addons/gut/gut_cmdln.gd'], process.stdout, docker.modem.followProgress(stream, onFinished, onProgress);
// Wait to run build until after pull complete
function onFinished(err, output)
{
console.log("Starting image...")
docker.run(docker_image, ['godot', '-d', '-s', '--path', '/project', 'addons/gut/gut_cmdln.gd'], process.stdout,
// Mount working directory to `/project`
{ HostConfig: { Binds: [ process.cwd() + ":/project" ] }},
function (err, data, container) {
if(err)
{
core.setFailed(error.message);
}
console.log("Tests exited with status: " + data.StatusCode);
if( data.StatusCode != "0" )
{
core.setFailed("GUT tests failed!");
}
// Mount working directory to `/project` })
{ HostConfig: { Binds: [ process.cwd() + ":/project" ] }}, }
function onProgress(event) {}
function (err, data, container) {
if(err) });
{ }
core.setFailed(error.message); else
} {
console.log("Running GUT tests locally");
console.log("Tests exited with status: " + data.StatusCode); var result = spawnSync('godot -d -s --path . addons/gut/gut_cmdln.gd', {
stdio: 'inherit',
shell: true
});
if( data.StatusCode != "0" ) if(result.status != null && result.status != 0)
{ {
core.setFailed("GUT tests failed!"); core.setFailed("GUT tests failed!");
}
})
} }
function onProgress(event) {}
}
});
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);

View File

@ -1,26 +1,26 @@
{ {
"name": "run-gut-tests-action", "name": "run-gut-tests-action",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "dist/main.js", "main": "dist/main.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"package": "ncc build main.js -o dist" "package": "ncc build main.js -o dist"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/josephbmanley/run-gut-tests-action.git" "url": "git+https://github.com/josephbmanley/run-gut-tests-action.git"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"bugs": { "bugs": {
"url": "https://github.com/josephbmanley/run-gut-tests-action/issues" "url": "https://github.com/josephbmanley/run-gut-tests-action/issues"
}, },
"homepage": "https://github.com/josephbmanley/run-gut-tests-action#readme", "homepage": "https://github.com/josephbmanley/run-gut-tests-action#readme",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@zeit/ncc": "^0.22.3", "@zeit/ncc": "^0.22.3",
"dockerode": "^3.2.1" "dockerode": "^3.2.1"
} }
} }