run-gut-tests-action/main.js

58 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-07-25 23:09:22 +02:00
const core = require('@actions/core');
const fs = require('fs');
const path = require('path')
// Setup Docker
const Docker = require('dockerode');
var docker = new Docker({socketPath: '/var/run/docker.sock'});
try {
// Get inputs
var docker_image = core.getInput('containerImage');
var work_dir = core.getInput('directory');
2020-07-25 23:57:44 +02:00
if(work_dir)
{
process.chdir(work_dir);
}
2020-07-25 23:09:22 +02:00
// Pull docker image for building
console.log("Pulling build image...");
docker.pull(docker_image, function(err, stream)
{
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,
2020-07-25 23:09:22 +02:00
// Mount working directory to `/project`
{ HostConfig: { Binds: [ process.cwd() + ":/project" ] }},
2020-07-25 23:09:22 +02:00
function (err, data, container) {
if(err)
{
core.setFailed(error.message);
2020-07-25 23:09:22 +02:00
}
console.log("Tests exited with status: " + data.StatusCode);
if( data.StatusCode != "0" )
{
core.setFailed("GUT tests failed!");
}
2020-07-25 23:09:22 +02:00
})
}
function onProgress(event) {}
});
} catch (error) {
core.setFailed(error.message);
}