Skip to content

Commit

Permalink
chore: address test flakes (#249)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
willmurphyscode authored Nov 20, 2023
1 parent eeb941f commit 62370b5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: "Tests"

on: [push, pull_request, workflow_dispatch]
on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
build: # make sure build/ci work properly and there is no faked build ncc built scripts
Expand Down
2 changes: 1 addition & 1 deletion tests/action_args.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { run } = require("../index");
const core = require("@actions/core");
const exec = require("@actions/exec");

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

describe("Github action args", () => {
it("runs with json report", async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/grype_command.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const githubActionsExec = require("@actions/exec");
const githubActionsToolCache = require("@actions/tool-cache");
const core = require("@actions/core");

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

jest.spyOn(githubActionsToolCache, "find").mockImplementation(() => {
return "grype";
Expand Down
6 changes: 6 additions & 0 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ jest.mock("@actions/core");
jest.mock("@actions/exec");
jest.mock("@actions/tool-cache");

beforeAll(async () => {
const { grypeVersion } = require("../GrypeVersion");
const { installGrype } = require("../index");
await installGrype(grypeVersion);
});

const core = require("@actions/core");
const path = require("path");
const fs = require("fs");
Expand Down
2 changes: 1 addition & 1 deletion tests/sarif_output.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require("@microsoft/jest-sarif"); // for sarif validation
const fs = require("fs");
const { runScan } = require("../index");

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

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

0 comments on commit 62370b5

Please sign in to comment.