Skip to content

Commit

Permalink
docs: update docs to v6 remove stale changelog (#422)
Browse files Browse the repository at this point in the history
Signed-off-by: Keith Zantow <[email protected]>
  • Loading branch information
kzantow authored Jan 3, 2025
1 parent 27d81ab commit 6eaf06d
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 76 deletions.
41 changes: 0 additions & 41 deletions CHANGELOG.md

This file was deleted.

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The simplest workflow for scanning a `localbuild/testimage` container:
load: true

- name: Scan image
uses: anchore/scan-action@v3
uses: anchore/scan-action@v6
with:
image: "localbuild/testimage:latest"
```
Expand All @@ -66,7 +66,7 @@ To scan a directory, add the following step:
```yaml
- name: Scan current project
uses: anchore/scan-action@v3
uses: anchore/scan-action@v6
with:
path: "."
```
Expand All @@ -85,7 +85,7 @@ Use the `sbom` key to scan an SBOM file:
output-file: "${{ github.event.repository.name }}-sbom.spdx.json"
- name: Scan SBOM
uses: anchore/scan-action@v3
uses: anchore/scan-action@v6
with:
sbom: "${{ github.event.repository.name }}-sbom.spdx.json"
```
Expand All @@ -98,7 +98,7 @@ With a different severity level:

```yaml
- name: Scan image
uses: anchore/scan-action@v3
uses: anchore/scan-action@v6
with:
image: "localbuild/testimage:latest"
fail-build: true
Expand All @@ -109,7 +109,7 @@ Optionally, change the `fail-build` field to `false` to avoid failing the build

```yaml
- name: Scan image
uses: anchore/scan-action@v3
uses: anchore/scan-action@v6
with:
image: "localbuild/testimage:latest"
fail-build: false
Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Build the container image
run: docker build . --file Dockerfile --tag localbuild/testimage:latest
- uses: anchore/scan-action@v3
- uses: anchore/scan-action@v6
with:
image: "localbuild/testimage:latest"
fail-build: true
Expand All @@ -180,7 +180,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Build the Container image
run: docker build . --file Dockerfile --tag localbuild/testimage:latest
- uses: anchore/scan-action@v3
- uses: anchore/scan-action@v6
id: scan
with:
image: "localbuild/testimage:latest"
Expand Down
12 changes: 9 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,17 @@ async function getDbDir(grypeCommand) {
}

async function getDbBuildTime(grypeCommand) {
const { stdout, exitCode } = await runCommand(
const { stdout, stderr, exitCode } = await runCommand(
grypeCommand,
["db", "status", "-vv"],
process.env,
);
if (exitCode !== 0) {
core.debug("nonzero exit from grype db status; exitCode: " + exitCode);
core.debug("stdout:");
core.debug(stdout);
core.debug("stderr:");
core.debug(stderr);
return;
}
for (let line of stdout.split("\n")) {
Expand Down Expand Up @@ -262,6 +267,7 @@ async function updateDbWithCache(grypeCommand) {

async function runCommand(cmd, cmdArgs, env) {
let stdout = "";
let stderr = "";

// This /dev/null writable stream is required so the entire Grype output
// is not written to the GitHub action log. the listener below
Expand All @@ -282,7 +288,7 @@ async function runCommand(cmd, cmdArgs, env) {
stdout += buffer.toString();
},
stderr(buffer) {
core.info(buffer.toString());
stderr += buffer.toString();
},
debug(message) {
core.debug(message);
Expand All @@ -293,7 +299,7 @@ async function runCommand(cmd, cmdArgs, env) {

core.debug(stdout);

return { stdout, exitCode };
return { stdout, stderr, exitCode };
}

async function runScan({
Expand Down
12 changes: 9 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,17 @@ async function getDbDir(grypeCommand) {
}

async function getDbBuildTime(grypeCommand) {
const { stdout, exitCode } = await runCommand(
const { stdout, stderr, exitCode } = await runCommand(
grypeCommand,
["db", "status", "-vv"],
process.env,
);
if (exitCode !== 0) {
core.debug("nonzero exit from grype db status; exitCode: " + exitCode);
core.debug("stdout:");
core.debug(stdout);
core.debug("stderr:");
core.debug(stderr);
return;
}
for (let line of stdout.split("\n")) {
Expand Down Expand Up @@ -248,6 +253,7 @@ async function updateDbWithCache(grypeCommand) {

async function runCommand(cmd, cmdArgs, env) {
let stdout = "";
let stderr = "";

// This /dev/null writable stream is required so the entire Grype output
// is not written to the GitHub action log. the listener below
Expand All @@ -268,7 +274,7 @@ async function runCommand(cmd, cmdArgs, env) {
stdout += buffer.toString();
},
stderr(buffer) {
core.info(buffer.toString());
stderr += buffer.toString();
},
debug(message) {
core.debug(message);
Expand All @@ -279,7 +285,7 @@ async function runCommand(cmd, cmdArgs, env) {

core.debug(stdout);

return { stdout, exitCode };
return { stdout, stderr, exitCode };
}

async function runScan({
Expand Down
34 changes: 18 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"homepage": "https://github.com/anchore/anchore-scan-action#readme",
"dependencies": {
"@actions/cache": "^4.0.0",
"@actions/core": "^1.11.0",
"@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1",
"@actions/tool-cache": "^2.0.1",
"lodash": "^4.17.21"
Expand All @@ -47,7 +47,7 @@
"eslint": "^9.17.0",
"husky": "^9.1.7",
"jest": "^29.7.0",
"lint-staged": "^15.2.11",
"lint-staged": "^15.3.0",
"prettier": "^3.4.2",
"tar": "^7.4.3",
"tslib": "^2.8.1"
Expand Down
2 changes: 2 additions & 0 deletions tests/action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ describe("Github action", () => {
requestedInputs[name] = true;
return expectedInputs[name];
},
// ignore setFailed calls that set process.exitCode due to https://github.com/jestjs/jest/issues/14501
setFailed() {},
});

await run();
Expand Down
10 changes: 6 additions & 4 deletions tests/mocks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const core = require("@actions/core");
const githubActionsCore = require("@actions/core");
const fs = require("fs");
const path = require("path");
const os = require("os");
Expand Down Expand Up @@ -28,13 +28,15 @@ module.exports = {

mockIO(inputs) {
const outputs = {};
module.exports.mock(core, {
module.exports.mock(githubActionsCore, {
getInput(name) {
return inputs[name];
},
setOutput(name, value) {
outputs[name] = value;
},
// ignore setFailed calls that set process.exitCode due to https://github.com/jestjs/jest/issues/14501
setFailed() {},
});
return outputs;
},
Expand Down Expand Up @@ -62,7 +64,7 @@ module.exports = {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "scan-action-test-"));
module.exports.onCleanup(() => {
if (fs.existsSync(dir)) {
fs.rmdirSync(dir, { recursive: true });
fs.rmSync(dir, { recursive: true });
}
});
return dir;
Expand All @@ -88,7 +90,7 @@ module.exports = {
GRYPE_DB_CACHE_DIR: path.join(path.dirname(__dirname), "grype-db"),
});

module.exports.mock(core, {
module.exports.mock(githubActionsCore, {
error: append,
info: append,
debug: append,
Expand Down

0 comments on commit 6eaf06d

Please sign in to comment.