-
Notifications
You must be signed in to change notification settings - Fork 77
97 lines (86 loc) · 2.9 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: "Tests"
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
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- run: npm ci
- run: npm run audit
- run: npm run build
- run: git status --porcelain
- run: git diff
- run: git diff --exit-code
test:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Build images
run: |
for distro in alpine centos debian; do
docker build -t localhost:5000/match-coverage/$distro ./tests/fixtures/image-$distro-match-coverage
docker push localhost:5000/match-coverage/$distro:latest
done
- name: Inspect
run: |
docker images -a
for distro in alpine centos debian; do
docker buildx imagetools inspect localhost:5000/match-coverage/$distro:latest
done
- run: npm ci
- run: npm run audit
- run: npm test
test-download-action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
path: ./
- name: "Donwload Grype v0.54.0"
uses: ./download-grype # anchore/scan-action/download-grype
with:
grype-version: v0.54.0
- name: "Check Grype version before scan-action"
run: grype version | egrep "^Version:.*0.54.0$"
- name: "Scan test image"
uses: ./
with:
image: "alpine:latest"
grype-version: v0.54.0 # set the same version to test that current Grype binary wasn't overwritten by the latest version
fail-build: false # to prevent fail due to vuln:s on test image
- name: "Check Grype version after scan-action"
run: grype version | egrep "^Version:.*0.54.0$"
test-all:
strategy:
matrix:
config: [
{image: 'alpine:latest'},
{path: 'tests/fixtures/npm-project'},
{sbom: 'tests/fixtures/test_sbom.spdx.json'},
]
os: [ubuntu-latest, windows-latest, macos-latest]
output-format: [sarif, json, table]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: ./
id: scan
with:
image: ${{ matrix.config.image }}
path: ${{ matrix.config.path }}
sbom: ${{ matrix.config.sbom }}
output-format: ${{ matrix.output-format }}
fail-build: false
- name: Validate file exists
if: ${{ matrix.output-format != 'table' }}
run: test -f '${{ steps.scan.outputs[matrix.output-format] }}'