Skip to content

Commit

Permalink
fix(ci): add summary file so tests can run locally
Browse files Browse the repository at this point in the history
  • Loading branch information
tembleking committed Jul 25, 2024
1 parent 554d91a commit 6c8c7ad
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ const exampleReport = JSON.stringify(require("./fixtures/report-test.json"));
describe("input parsing", () => {
let oldEnv;

beforeAll(() => {
beforeAll(async () => {
oldEnv = process.env;
await createReportFileIfNotExists();
})

beforeEach(() => {
Expand Down Expand Up @@ -632,4 +633,21 @@ describe("run the full action", () => {
expect(exec.exec.mock.calls[2][0]).toMatch(`${index.cliScannerName} --apiurl https://secure.sysdig.com/ --override-pullstring=my-custom-image:latest --json-scan-result=scan-result.json image:tag`);
})

})
})

async function createReportFileIfNotExists() {
const summary_file = process.env.GITHUB_STEP_SUMMARY || "/tmp/github_summary.html";
const promise = new Promise((resolve, reject) => {
if (fs.existsSync(summary_file)) {
return resolve();
}
fs.writeFile(summary_file, "", (err) => {
if (err == null) {
return resolve();
}
return reject(err);
});
});

return promise;
}

0 comments on commit 6c8c7ad

Please sign in to comment.