mirror of
https://github.com/yeslayla/run-gut-tests-action.git
synced 2025-12-06 09:13:25 +01:00
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:
77
main.js
77
main.js
@@ -1,4 +1,5 @@
|
||||
const core = require('@actions/core');
|
||||
const { spawnSync } = require("child_process");
|
||||
const fs = require('fs');
|
||||
const path = require('path')
|
||||
|
||||
@@ -11,47 +12,67 @@ 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);
|
||||
}
|
||||
|
||||
// Pull docker image for building
|
||||
console.log("Pulling build image...");
|
||||
docker.pull(docker_image, function(err, stream)
|
||||
{
|
||||
if(use_container == "true")
|
||||
{
|
||||
|
||||
docker.modem.followProgress(stream, onFinished, onProgress);
|
||||
|
||||
// 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', '-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 -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);
|
||||
|
||||
Reference in New Issue
Block a user