Skip to content

Commit

Permalink
Fix bom test failures (#564)
Browse files Browse the repository at this point in the history
* test: Fix bom tests to account for /stacker re-org

Commit 2f284d8 re-organized the /stacker content layout.
Instead of /stacker/tools/static-stacker we have /stacker/bin/stacker.

Signed-off-by: Scott Moser <[email protected]>

* ci: Add alpine:edge image to those cloned and use it in test.

The alpine image being used for the sbom test was already being
used (and cloned).  There is no reason to depend on ghcr.io for it.

Signed-off-by: Scott Moser <[email protected]>

* ci: Un-mark alpine bom test as slow.

Run the alpine bom test during normal c-i test.  This is a quick test
(~10 seconds).  Having it run as part of c-i will mean that we sniff
test the bom path without adding significant time.

Signed-off-by: Scott Moser <[email protected]>

---------

Signed-off-by: Scott Moser <[email protected]>
  • Loading branch information
smoser authored Nov 27, 2023
1 parent 3897848 commit a576aa3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ build_stacker = go build $1 -tags "$(BUILD_TAGS) $2" -ldflags "-X main.version=$
# See doc/hacking.md for how to use a local oci or docker repository.
STACKER_DOCKER_BASE?=docker://ghcr.io/project-stacker/
# They default to their image name in STACKER_DOCKER_BASE
STACKER_BUILD_BASE_IMAGE?=$(STACKER_DOCKER_BASE)alpine:edge
STACKER_BUILD_BASE_IMAGE?=$(STACKER_BUILD_ALPINE_IMAGE)
STACKER_BUILD_ALPINE_IMAGE?=$(STACKER_DOCKER_BASE)alpine:edge
STACKER_BUILD_BUSYBOX_IMAGE?=$(STACKER_DOCKER_BASE)busybox:latest
STACKER_BUILD_CENTOS_IMAGE?=$(STACKER_DOCKER_BASE)centos:latest
STACKER_BUILD_UBUNTU_IMAGE?=$(STACKER_DOCKER_BASE)ubuntu:latest
STACKER_BUILD_IMAGES = \
$(STACKER_BUILD_ALPINE_IMAGE) \
$(STACKER_BUILD_BASE_IMAGE) \
$(STACKER_BUILD_BUSYBOX_IMAGE) \
$(STACKER_BUILD_CENTOS_IMAGE) \
Expand Down Expand Up @@ -149,7 +151,7 @@ test: stacker $(REGCLIENT) $(SKOPEO) $(ZOT)
sudo -E PATH="$$PATH" \
LXC_BRANCH=$(LXC_BRANCH) \
LXC_CLONE_URL=$(LXC_CLONE_URL) \
STACKER_BUILD_BASE_IMAGE=$(STACKER_BUILD_BASE_IMAGE) \
STACKER_BUILD_ALPINE_IMAGE=$(STACKER_BUILD_ALPINE_IMAGE) \
STACKER_BUILD_BUSYBOX_IMAGE=$(STACKER_BUILD_BUSYBOX_IMAGE) \
STACKER_BUILD_CENTOS_IMAGE=$(STACKER_BUILD_CENTOS_IMAGE) \
STACKER_BUILD_UBUNTU_IMAGE=$(STACKER_BUILD_UBUNTU_IMAGE) \
Expand All @@ -166,7 +168,8 @@ test-cov: stacker-cov $(REGCLIENT) $(SKOPEO) $(ZOT)
-E GOCOVERDIR="$$GOCOVERDIR" \
LXC_BRANCH=$(LXC_BRANCH) \
LXC_CLONE_URL=$(LXC_CLONE_URL) \
STACKER_BUILD_BASE_IMAGE=$(STACKER_BUILD_BASE_IMAGE) \
STACKER_BUILD_ALPINE_IMAGE=$(STACKER_BUILD_ALPINE_IMAGE) \
STACKER_BUILD_BUSYBOX_IMAGE=$(STACKER_BUILD_BUSYBOX_IMAGE) \
STACKER_BUILD_CENTOS_IMAGE=$(STACKER_BUILD_CENTOS_IMAGE) \
STACKER_BUILD_UBUNTU_IMAGE=$(STACKER_BUILD_UBUNTU_IMAGE) \
./test/main.py \
Expand Down
11 changes: 5 additions & 6 deletions test/bom.bats
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bom-parent:
paths: [/pkg2]
run: |
# discover installed pkgs
/stacker/tools/static-stacker bom discover
/stacker/bin/stacker bom discover
# our own custom packages
mkdir -p /pkg1
touch /pkg1/file
Expand Down Expand Up @@ -86,7 +86,7 @@ bom-parent:
paths: [/pkg2]
run: |
# discover installed pkgs
/stacker/tools/static-stacker bom discover
/stacker/bin/stacker bom discover
# our own custom packages
mkdir -p /pkg1
touch /pkg1/file
Expand Down Expand Up @@ -156,12 +156,11 @@ EOF
}

@test "bom for alpine-based image" {
skip_slow_test
cat > stacker.yaml <<EOF
bom-alpine:
from:
type: docker
url: docker://ghcr.io/project-stacker/alpine:edge
type: oci
url: $ALPINE_OCI
bom:
generate: true
packages:
Expand All @@ -175,7 +174,7 @@ bom-alpine:
org.opencontainers.image.licenses: MIT
run: |
# discover installed pkgs
/stacker/tools/static-stacker bom discover
/stacker/bin/stacker bom discover
# run our cmds
ls -al /
# some changes
Expand Down
3 changes: 3 additions & 0 deletions test/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,18 @@ function image_copy {
}

STACKER_DOCKER_BASE=${STACKER_DOCKER_BASE:-docker://}
STACKER_BUILD_ALPINE_IMAGE=${STACKER_BUILD_ALPINE_IMAGE:-${STACKER_DOCKER_BASE}alpine:edge}
STACKER_BUILD_BUSYBOX_IMAGE=${STACKER_BUILD_BUSYBOX_IMAGE:-${STACKER_DOCKER_BASE}busybox:latest}
STACKER_BUILD_CENTOS_IMAGE=${STACKER_BUILD_CENTOS_IMAGE:-${STACKER_DOCKER_BASE}centos:latest}
STACKER_BUILD_UBUNTU_IMAGE=${STACKER_BUILD_UBUNTU_IMAGE:-${STACKER_DOCKER_BASE}ubuntu:latest}
(
flock 9
[ -f "$ROOT_DIR/test/alpine/index.json" ] || (image_copy "${STACKER_BUILD_ALPINE_IMAGE}" "oci:$ROOT_DIR/test/alpine:edge" && chmod -R 777 "$ROOT_DIR/test/alpine")
[ -f "$ROOT_DIR/test/busybox/index.json" ] || (image_copy "${STACKER_BUILD_BUSYBOX_IMAGE}" "oci:$ROOT_DIR/test/busybox:latest" && chmod -R 777 "$ROOT_DIR/test/busybox")
[ -f "$ROOT_DIR/test/centos/index.json" ] || (image_copy "${STACKER_BUILD_CENTOS_IMAGE}" "oci:$ROOT_DIR/test/centos:latest" && chmod -R 777 "$ROOT_DIR/test/centos")
[ -f "$ROOT_DIR/test/ubuntu/index.json" ] || (image_copy "${STACKER_BUILD_UBUNTU_IMAGE}" "oci:$ROOT_DIR/test/ubuntu:latest" && chmod -R 777 "$ROOT_DIR/test/ubuntu")
) 9<$ROOT_DIR/test/main.py
export ALPINE_OCI="$ROOT_DIR/test/alpine:edge"
export BUSYBOX_OCI="$ROOT_DIR/test/busybox:latest"
export CENTOS_OCI="$ROOT_DIR/test/centos:latest"
export UBUNTU_OCI="$ROOT_DIR/test/ubuntu:latest"
Expand Down

0 comments on commit a576aa3

Please sign in to comment.