Skip to content

Commit 8924418

Browse files
authored
Add installation acceptance tests (#1)
* require install tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove snapshot build during acceptance Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix mac install steps Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * make docker dir during acceptance tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update docs to reflect installation via script Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
1 parent b883a03 commit 8924418

5 files changed

Lines changed: 107 additions & 20 deletions

File tree

.github/workflows/release.yaml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
id: static-analysis
3131
with:
3232
token: ${{ secrets.GITHUB_TOKEN }}
33-
# This check name is defined as the github action job name (in .github/workflows/testing.yaml)
33+
# This check name is defined as the github action job name (in .github/workflows/validations.yaml)
3434
checkName: "Static analysis"
3535
ref: ${{ github.event.pull_request.head.sha || github.sha }}
3636

@@ -39,15 +39,35 @@ jobs:
3939
id: unit
4040
with:
4141
token: ${{ secrets.GITHUB_TOKEN }}
42-
# This check name is defined as the github action job name (in .github/workflows/testing.yaml)
42+
# This check name is defined as the github action job name (in .github/workflows/validations.yaml)
4343
checkName: "Unit tests"
4444
ref: ${{ github.event.pull_request.head.sha || github.sha }}
4545

46+
- name: Check acceptance test results (linux)
47+
uses: fountainhead/action-wait-for-check@v1.0.0
48+
id: acceptance-linux
49+
with:
50+
token: ${{ secrets.GITHUB_TOKEN }}
51+
# This check name is defined as the github action job name (in .github/workflows/validations.yaml)
52+
checkName: "Acceptance tests (Linux)"
53+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
54+
55+
- name: Check acceptance test results (mac)
56+
uses: fountainhead/action-wait-for-check@v1.0.0
57+
id: acceptance-mac
58+
with:
59+
token: ${{ secrets.GITHUB_TOKEN }}
60+
# This check name is defined as the github action job name (in .github/workflows/validations.yaml)
61+
checkName: "Acceptance tests (Mac)"
62+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
63+
4664
- name: Quality gate
47-
if: steps.static-analysis.outputs.conclusion != 'success' || steps.unit.outputs.conclusion != 'success'
65+
if: steps.static-analysis.outputs.conclusion != 'success' || steps.unit.outputs.conclusion != 'success' || steps.acceptance-linux.outputs.conclusion != 'success' || steps.acceptance-mac.outputs.conclusion != 'success'
4866
run: |
4967
echo "Static Analysis Status: ${{ steps.static-analysis.conclusion }}"
5068
echo "Unit Test Status: ${{ steps.unit.outputs.conclusion }}"
69+
echo "Acceptance Test (Linux) Status: ${{ steps.acceptance-linux.outputs.conclusion }}"
70+
echo "Acceptance Test (Mac) Status: ${{ steps.acceptance-mac.outputs.conclusion }}"
5171
false
5272
5373
release:

.github/workflows/validations.yaml

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ jobs:
8787

8888
- uses: actions/checkout@v2
8989

90-
- name: Set up QEMU
91-
uses: docker/setup-qemu-action@v1
92-
9390
- name: Restore tool cache
9491
id: tool-cache
9592
uses: actions/cache@v2.1.3
@@ -117,3 +114,65 @@ jobs:
117114
with:
118115
name: artifacts
119116
path: snapshot/**/*
117+
118+
Acceptance-Linux:
119+
# Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
120+
name: "Acceptance tests (Linux)"
121+
needs: [Build-Snapshot-Artifacts]
122+
runs-on: ubuntu-20.04
123+
steps:
124+
- uses: actions/checkout@v2
125+
126+
- uses: actions/download-artifact@v2
127+
with:
128+
name: artifacts
129+
path: snapshot
130+
131+
- name: Build key for image cache
132+
run: make install-fingerprint
133+
134+
- name: Restore install.sh test image cache
135+
id: install-test-image-cache
136+
uses: actions/cache@v2.1.3
137+
with:
138+
path: ${{ github.workspace }}/test/install/cache
139+
key: ${{ runner.os }}-install-test-image-cache-${{ hashFiles('test/install/cache.fingerprint') }}
140+
141+
- name: Restore tool cache
142+
id: tool-cache
143+
uses: actions/cache@v2.1.3
144+
with:
145+
path: ${{ github.workspace }}/.tmp
146+
key: ${{ runner.os }}-tool-${{ hashFiles('Makefile') }}
147+
148+
- name: Load test image cache
149+
if: steps.install-test-image-cache.outputs.cache-hit == 'true'
150+
run: make install-test-cache-load
151+
152+
- name: Run install.sh tests (Linux)
153+
run: make install-test
154+
155+
- name: (cache-miss) Create test image cache
156+
if: steps.install-test-image-cache.outputs.cache-hit != 'true'
157+
run: make install-test-cache-save
158+
159+
Acceptance-Mac:
160+
# Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
161+
name: "Acceptance tests (Mac)"
162+
needs: [Build-Snapshot-Artifacts]
163+
runs-on: macos-latest
164+
steps:
165+
- uses: actions/checkout@v2
166+
167+
- uses: actions/download-artifact@v2
168+
with:
169+
name: artifacts
170+
path: snapshot
171+
172+
- name: Install docker CLI
173+
run: |
174+
brew install docker
175+
mkdir ~/.docker
176+
177+
- name: Run install.sh tests (Mac)
178+
run: make install-test-ci-mac

Makefile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ RESET := $(shell tput -T linux sgr0)
1717
TITLE := $(BOLD)$(PURPLE)
1818
SUCCESS := $(BOLD)$(GREEN)
1919

20-
21-
ifeq "$(strip $(VERSION))" ""
22-
override VERSION = $(shell git describe --always --tags --dirty)
23-
endif
24-
2520
## Variable assertions
2621

2722
ifndef TEMP_DIR
@@ -104,19 +99,19 @@ install-fingerprint:
10499
cd test/install && \
105100
make cache.fingerprint
106101

107-
install-test: $(SNAPSHOT_DIR)
102+
install-test:
108103
cd test/install && \
109104
make
110105

111-
install-test-cache-save: $(SNAPSHOT_DIR)
106+
install-test-cache-save:
112107
cd test/install && \
113108
make save
114109

115-
install-test-cache-load: $(SNAPSHOT_DIR)
110+
install-test-cache-load:
116111
cd test/install && \
117112
make load
118113

119-
install-test-ci-mac: $(SNAPSHOT_DIR)
114+
install-test-ci-mac:
120115
cd test/install && \
121116
make ci-test-mac
122117

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,25 @@ Plugin for Docker CLI to support SBOM creation using Syft.
1010
# install syft
1111
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
1212
13-
# build
13+
# install the docker-sbom plugin
14+
curl -sSfL https://raw.githubusercontent.com/anchore/docker-sbom-cli-plugin/main/install.sh | sh -s --
15+
16+
# use the sbom plugin
17+
docker sbom <my-image>
18+
```
19+
20+
## Developing
21+
22+
```
23+
# get development tooling
24+
make bootstrap
25+
26+
# make a snapshot build
1427
make snapshot
1528
1629
# install
1730
cp snapshot/<path/to/your>/docker-sbom ~/.docker/cli-plugins
1831
19-
# use
32+
# use the sbom plugin
2033
docker sbom <my-image>
21-
```
34+
```

test/install/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ endef
2626
test: unit acceptance
2727

2828
.PHONY: ci-test-mac
29-
ci-test-mac: unit-local acceptance-local
29+
ci-test-mac: acceptance-local
3030

3131
# note: do not add acceptance-local to this list
3232
acceptance: acceptance-ubuntu-20.04 acceptance-alpine-3.6
@@ -38,7 +38,7 @@ unit-local:
3838
@for f in $(shell ls *_test.sh); do echo "Running unit test suite '$${f}'"; bash $${f} || exit 1; done
3939

4040
acceptance-local:
41-
$(acceptance)
41+
$(CURL_INSTALL_SYFT) && $(ACCEPTANCE_CMD)
4242

4343
save: ubuntu-20.04 alpine-3.6
4444
@mkdir cache || true

0 commit comments

Comments
 (0)