Skip to content

Commit 62370b5

Browse files
chore: address test flakes (#249)
* chore: bump jest timeout We're seeing this timeout triggered in CI. Signed-off-by: Will Murphy <[email protected]> * bump timeout in remaining tests Signed-off-by: Will Murphy <[email protected]> * chore: only run push tests on main Otherwise, we'd run tests twice for each PR; once because it was a PR, and once because someone pushed to a branch. Signed-off-by: Will Murphy <[email protected]> * chore: even higher jest timeout Signed-off-by: Will Murphy <[email protected]> * chore: install grype ahead of tests Signed-off-by: Will Murphy <[email protected]> * chore: comment test timeout Signed-off-by: Will Murphy <[email protected]> --------- Signed-off-by: Will Murphy <[email protected]>
1 parent eeb941f commit 62370b5

5 files changed

Lines changed: 15 additions & 4 deletions

File tree

.github/workflows/test.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: "Tests"
22

3-
on: [push, pull_request, workflow_dispatch]
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
49

510
jobs:
611
build: # make sure build/ci work properly and there is no faked build ncc built scripts

tests/action_args.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { run } = require("../index");
22
const core = require("@actions/core");
33
const exec = require("@actions/exec");
44

5-
jest.setTimeout(30000);
5+
jest.setTimeout(90000); // 90 seconds; tests were timing out in CI. https://github.com/anchore/scan-action/pull/249
66

77
describe("Github action args", () => {
88
it("runs with json report", async () => {

tests/grype_command.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const githubActionsExec = require("@actions/exec");
22
const githubActionsToolCache = require("@actions/tool-cache");
33
const core = require("@actions/core");
44

5-
jest.setTimeout(30000);
5+
jest.setTimeout(90000); // 90 seconds; tests were timing out in CI. https://github.com/anchore/scan-action/pull/249
66

77
jest.spyOn(githubActionsToolCache, "find").mockImplementation(() => {
88
return "grype";

tests/index.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ jest.mock("@actions/core");
22
jest.mock("@actions/exec");
33
jest.mock("@actions/tool-cache");
44

5+
beforeAll(async () => {
6+
const { grypeVersion } = require("../GrypeVersion");
7+
const { installGrype } = require("../index");
8+
await installGrype(grypeVersion);
9+
});
10+
511
const core = require("@actions/core");
612
const path = require("path");
713
const fs = require("fs");

tests/sarif_output.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require("@microsoft/jest-sarif"); // for sarif validation
33
const fs = require("fs");
44
const { runScan } = require("../index");
55

6-
jest.setTimeout(30000);
6+
jest.setTimeout(90000); // 90 seconds; tests were timing out in CI. https://github.com/anchore/scan-action/pull/249
77

88
const testSource = async (source, vulnerabilities) => {
99
if (fs.existsSync("./vulnerabilities.json")) {

0 commit comments

Comments
 (0)