Compare commits

...

9 Commits

Author SHA1 Message Date
763318a75e
Update ReadMe.md 2022-04-27 01:59:23 -04:00
77ba28181d
Merge pull request #5 from josephbmanley/feature/runLocally
Allow running tests directly on runner
2021-02-11 19:06:55 -05:00
2c73dad9ae Allow user to change executable path 2021-02-11 19:03:58 -05:00
5af87a011e 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
2021-02-11 19:01:02 -05:00
ce937f3dd5
Merge pull request #2 from josephbmanley/dependabot/npm_and_yarn/actions/core-1.2.6
Bump @actions/core from 1.2.4 to 1.2.6
2020-10-01 20:14:45 -04:00
dependabot[bot]
b67af43622
Bump @actions/core from 1.2.4 to 1.2.6
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.4 to 1.2.6.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-01 17:41:51 +00:00
26be40e483
Merge pull request #1 from josephbmanley/dependabot/npm_and_yarn/bl-4.0.3
Bump bl from 4.0.2 to 4.0.3
2020-09-02 15:09:48 -04:00
dependabot[bot]
877b7b7c8b
Bump bl from 4.0.2 to 4.0.3
Bumps [bl](https://github.com/rvagg/bl) from 4.0.2 to 4.0.3.
- [Release notes](https://github.com/rvagg/bl/releases)
- [Commits](https://github.com/rvagg/bl/compare/v4.0.2...v4.0.3)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-02 19:07:58 +00:00
db0ad0d03b
Bugfix cwd 2020-07-25 17:57:44 -04:00
7 changed files with 269 additions and 116 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
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

@ -1,4 +1,4 @@
![Release Version](https://img.shields.io/github/v/release/josephbmanley/run-gut-tests-action) ![Test Action](https://github.com/josephbmanley/run-gut-tests-action/workflows/Test%20Action/badge.svg)
![Release Version](https://img.shields.io/github/v/release/manleydev/run-gut-tests-action) ![Test Action](https://github.com/manleydev/run-gut-tests-action/workflows/Test%20Action/badge.svg)
# Run GUT tests
This is an action that runs [GUT](https://github.com/bitwes/Gut) tests for Godot to easily automate testing.
@ -11,7 +11,7 @@ Example:
```yaml
steps:
- uses: josephbmanley/run-gut-tests-action@[VERSION]
- uses: manleydev/run-gut-tests-action@[VERSION]
with:
directory: client
```
@ -26,6 +26,15 @@ 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`
#### godotExecutable
Path of Godot binary to call when running GUT tests. Defaults to `godot`
## 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.
@ -45,4 +54,4 @@ Here is an example `.gutconfig.json`:
}
```
For more information on the config file, [see the GUT wiki](https://github.com/bitwes/Gut/wiki/Command-Line#config-file).
For more information on the config file, [see the GUT wiki](https://github.com/bitwes/Gut/wiki/Command-Line#config-file).

View File

@ -5,9 +5,14 @@ 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
godotExecutable:
description: "Path of Godot binary to call when running GUT tests."
default: godot
directory:
description: "The name directory to run tests in."
defaut: "."
runs:
using: "node12"
main: "dist/index.js"

197
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,44 +12253,68 @@ try {
// Get inputs
var docker_image = core.getInput('containerImage');
var work_dir = core.getInput('directory');
var use_container = core.getInput('useContainer');
var godot_executable = core.getInput('godotExecutable');
process.chdir(work_dir);
// Pull docker image for building
console.log("Pulling build image...");
docker.pull(docker_image, function(err, stream)
if(work_dir)
{
process.chdir(work_dir);
}
docker.modem.followProgress(stream, onFinished, onProgress);
if(use_container == "true")
{
// Wait to run build until after pull complete
function onFinished(err, output)
// Pull docker image for building
console.log("Pulling build image...");
docker.pull(docker_image, function(err, stream)
{
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_executable, '-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 (err, data, container) {
})
}
function onProgress(event) {}
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_executable} -d -s --path . addons/gut/gut_cmdln.gd`, {
stdio: 'inherit',
shell: true
});
if( data.StatusCode != "0" )
{
core.setFailed("GUT tests failed!");
}
})
if(result.status != null && result.status != 0)
{
core.setFailed("GUT tests failed!");
}
function onProgress(event) {}
});
}
} catch (error) {
core.setFailed(error.message);
@ -14340,6 +14427,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
*
@ -14393,28 +14481,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')
@ -14757,6 +14831,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));
/**
@ -14783,9 +14859,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;
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;
/**
@ -14801,7 +14885,13 @@ exports.setSecret = setSecret;
* @param 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']}`;
}
exports.addPath = addPath;
@ -25579,12 +25669,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) {
@ -25592,6 +25683,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
}
@ -25633,6 +25727,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
@ -26292,7 +26391,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"};
/***/ }),

81
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,44 +12,68 @@ try {
// Get inputs
var docker_image = core.getInput('containerImage');
var work_dir = core.getInput('directory');
var use_container = core.getInput('useContainer');
var godot_executable = core.getInput('godotExecutable');
process.chdir(work_dir);
// Pull docker image for building
console.log("Pulling build image...");
docker.pull(docker_image, function(err, stream)
if(work_dir)
{
process.chdir(work_dir);
}
docker.modem.followProgress(stream, onFinished, onProgress);
if(use_container == "true")
{
// Wait to run build until after pull complete
function onFinished(err, output)
// Pull docker image for building
console.log("Pulling build image...");
docker.pull(docker_image, function(err, stream)
{
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_executable, '-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 (err, data, container) {
})
}
function onProgress(event) {}
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_executable} -d -s --path . addons/gut/gut_cmdln.gd`, {
stdio: 'inherit',
shell: true
});
if( data.StatusCode != "0" )
{
core.setFailed("GUT tests failed!");
}
})
if(result.status != null && result.status != 0)
{
core.setFailed("GUT tests failed!");
}
function onProgress(event) {}
});
}
} catch (error) {
core.setFailed(error.message);

16
package-lock.json generated
View File

@ -1,11 +1,13 @@
{
"requires": true,
"name": "run-gut-tests-action",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@actions/core": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.4.tgz",
"integrity": "sha512-YJCEq8BE3CdN8+7HPZ/4DxJjk/OkZV2FFIf+DlZTC/4iBlzYCD5yjRR6eiOS5llO11zbRltIRuKAjMKaWTE6cg=="
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
},
"@zeit/ncc": {
"version": "0.22.3",
@ -34,9 +36,9 @@
}
},
"bl": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/bl/-/bl-4.0.2.tgz",
"integrity": "sha512-j4OH8f6Qg2bGuWfRiltT2HYGx0e1QcBTrK9KAHNMwMZdQnDZFk0ZSYIpADjYCB3U12nicC5tVJwSIhwOWjb4RQ==",
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/bl/-/bl-4.0.3.tgz",
"integrity": "sha512-fs4G6/Hu4/EE+F75J8DuN/0IpQqNjAdC7aEQv7Qt8MHGUH7Ckv2MwTEEeN9QehD0pfIDkMI1bkHYkKy7xHyKIg==",
"requires": {
"buffer": "^5.5.0",
"inherits": "^2.0.4",

View File

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