diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index 28b924b..361afb6 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -5,9 +5,6 @@ on: types: - build-push pull_request: - branches: - - main - - rc workflow_dispatch: inputs: version: diff --git a/test/artifacts/config.json b/test/artifacts/config.json index 6fafe23..12bccf1 100644 --- a/test/artifacts/config.json +++ b/test/artifacts/config.json @@ -3,7 +3,7 @@ "input": ".", "output": ".", "recursive": true, - "logLevel": "debug", + "logLevel": "info", "relativePathBase": "file", "runTests": { "input": ".", @@ -17,19 +17,7 @@ "contexts": [ { "app": { "name": "chrome", "options": { "headless": true } }, - "platforms": ["mac", "linux"] - }, - { - "app": { "name": "chrome", "options": { "headless": true } }, - "platforms": ["windows"] - }, - { - "app": { "name": "firefox", "options": { "headless": true } }, - "platforms": ["mac", "linux"] - }, - { - "app": { "name": "firefox", "options": { "headless": true } }, - "platforms": ["windows"] + "platforms": ["mac", "linux", "windows"] } ] }, diff --git a/test/runTests.test.js b/test/runTests.test.js index e0b478b..906ecdb 100644 --- a/test/runTests.test.js +++ b/test/runTests.test.js @@ -52,12 +52,22 @@ if (process.platform === "win32") { // }); // Run tests in Docker container -describe("Run tests sucessfully", async function () { +describe("Run tests successfully", async function () { // Set indefinite timeout this.timeout(0); - it("All specs pass", async () => { return new Promise((resolve, reject) => { + it("All specs pass", async () => { + return new Promise((resolve, reject) => { + let hasCompleted = false; + + const handleCompletion = (callback) => { + if (hasCompleted) return; + hasCompleted = true; + callback(); + }; + const runTests = exec( - `docker run --rm -v "${artifactPath}:${internalPath}" docdetective/docdetective:${version}-${os} -c ./config.json -i . -o ./results.json` + `docker run --rm --memory=2g --cpus=2 -v "${artifactPath}:${internalPath}" docdetective/docdetective:${version}-${os} -c ./config.json -i . -o ./results.json`, + { maxBuffer: 10 * 1024 * 1024 } // 10MB buffer for output ); runTests.stdout.on("data", (data) => { @@ -70,28 +80,35 @@ describe("Run tests sucessfully", async function () { runTests.on("error", (error) => { console.error(`Error: ${error.message}`); - reject(error); - }); - - runTests.on("close", (code) => { - console.log(`Child process exited with code ${code}`); - if (code !== null && code !== 0) { - reject(new Error(`Docker process exited with code ${code}`)); - } + handleCompletion(() => reject(error)); }); - runTests.on("exit", () => { - try { - const result = JSON.parse( - fs.readFileSync(outputFile, { encoding: "utf8" }) - ); - console.log(JSON.stringify(result, null, 2)); - assert.equal(result.summary.specs.fail, 0); - fs.unlinkSync(outputFile); - resolve(); - } catch (error) { - reject(error); - } + runTests.on("close", (code, signal) => { + handleCompletion(() => { + console.log(`Child process closed with code ${code} and signal ${signal}`); + + if (signal != null) { + reject(new Error(`Docker process terminated by signal ${signal}`)); + return; + } + + if (code !== null && code !== 0) { + reject(new Error(`Docker process exited with code ${code}`)); + return; + } + + try { + const result = JSON.parse( + fs.readFileSync(outputFile, { encoding: "utf8" }) + ); + console.log(JSON.stringify(result, null, 2)); + assert.equal(result.summary.specs.fail, 0); + fs.unlinkSync(outputFile); + resolve(); + } catch (error) { + reject(error); + } + }); }); }); });