From b6d5f4cc56e2b43c8881dd3e270bba139428ebb8 Mon Sep 17 00:00:00 2001 From: Adam Birds Date: Sun, 9 Apr 2023 16:19:20 +0100 Subject: [PATCH] action: Add timeout before running tests. --- main.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/main.js b/main.js index 3f58911..e8550a4 100644 --- a/main.js +++ b/main.js @@ -1,7 +1,7 @@ const core = require("@actions/core"); const compose = require("docker-compose"); const utils = require("./utils"); -const path = require("path"); +//const path = require("path"); try { const composeFiles = utils.parseComposeFiles( @@ -33,19 +33,26 @@ try { const testContainer = core.getInput("test-container"); const testCommand = core.getInput("test-command"); + + console.log("testContainer", testContainer); + console.log("testCommand", testCommand); + if (testCommand && testContainer) { - const test = compose.exec(testContainer, testCommand, { - cwd: path.join(__dirname), - config: composeFiles, - }); - - test - .then(() => { - console.log("tests passed"); - }) - .catch((err) => { - core.setFailed(`tests failed ${JSON.stringify(err)}`); + setTimeout(() => { + const test = compose.exec(testContainer, testCommand, { + config: composeFiles, }); + + test + .then(() => { + console.log("tests passed"); + }) + .catch((err) => { + console.log(err.out); + console.log(err.err); + core.setFailed(`tests failed ${JSON.stringify(err)}`); + }); + }, 10000); } }) .catch((err) => {