From ed339e4fed10912d7ed9b98c588ec38241fb020b Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Tue, 6 Jan 2026 11:43:51 -0500 Subject: [PATCH] fix: ensure java image build failures stop the build (#4531) --------- Signed-off-by: Alex Goodman --- .github/workflows/test-fixture-cache-publish.yaml | 7 +++---- Taskfile.yaml | 5 ++++- syft/file/cataloger/executable/test-fixtures/Makefile | 4 ++-- syft/pkg/cataloger/golang/test-fixtures/Makefile | 4 ++-- syft/pkg/cataloger/java/test-fixtures/Makefile | 4 ++-- .../java-builds/build-example-java-app-gradle.sh | 1 - .../java-builds/build-example-java-app-maven.sh | 1 - .../java-builds/build-example-java-app-native-image.sh | 6 ++---- .../java-builds/build-example-jenkins-plugin.sh | 1 - .../java-builds/build-example-sb-app-nestedjar.sh | 1 - 10 files changed, 15 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test-fixture-cache-publish.yaml b/.github/workflows/test-fixture-cache-publish.yaml index 5003a63b7..61d226810 100644 --- a/.github/workflows/test-fixture-cache-publish.yaml +++ b/.github/workflows/test-fixture-cache-publish.yaml @@ -13,12 +13,11 @@ jobs: Publish: name: "Publish test fixture image cache" - # runs-on.com: memory-optimized instances for building test fixture cache + # runs-on.com: general purpose instances for building test fixture cache # spot disabled: can run up to an hour, avoid interruptions - # disk=large: need more storage for docker images and fixture cache # s3-cache: faster actions cache - # tmpfs: faster io-intensive workflows - runs-on: runs-on=${{ github.run_id }}/cpu=4+8/ram=64+128/family=r5+r6+r7+r8/spot=false/extras=s3-cache+tmpfs + # family: note that m*d instances have local nvme storage which is beneficial for building large test fixture images + runs-on: "runs-on=${{ github.run_id }}/cpu=8+16/ram=32+64/family=m5d+m5ad+m5dn+m6gd+m6id+m6idn+m7gd+m8gd/spot=false/extras=s3-cache" if: github.repository == 'anchore/syft' # only run for main repo permissions: packages: write diff --git a/Taskfile.yaml b/Taskfile.yaml index e4f636e28..cbce8378f 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -373,6 +373,9 @@ tasks: # this will look for `test-fixtures/Makefile` and invoke the `fixtures` target to generate any and all test fixtures cmds: - | + # we want to stop on the first build error + set -e + BOLD='\033[1m' YELLOW='\033[0;33m' RESET='\033[0m' @@ -381,7 +384,7 @@ tasks: for dir in $(find . -type d -name 'test-fixtures'); do if [ -f "$dir/Makefile" ]; then echo -e "${YELLOW}${BOLD}generating fixtures in $dir${RESET}" - (make -C "$dir" fixtures) + make -C "$dir" fixtures fi done echo -e "${BOLD}generated all fixtures${RESET}" diff --git a/syft/file/cataloger/executable/test-fixtures/Makefile b/syft/file/cataloger/executable/test-fixtures/Makefile index da3e730e1..f742a3228 100644 --- a/syft/file/cataloger/executable/test-fixtures/Makefile +++ b/syft/file/cataloger/executable/test-fixtures/Makefile @@ -3,13 +3,13 @@ default: @for dir in $(shell find . -mindepth 1 -maxdepth 1 -type d); do \ if [ -f "$$dir/Makefile" ]; then \ - $(MAKE) -C $$dir; \ + $(MAKE) -C $$dir || exit 1; \ fi; \ done %: @for dir in $(shell find . -mindepth 1 -maxdepth 1 -type d); do \ if [ -f "$$dir/Makefile" ]; then \ - $(MAKE) -C $$dir $@; \ + $(MAKE) -C $$dir $@ || exit 1; \ fi; \ done diff --git a/syft/pkg/cataloger/golang/test-fixtures/Makefile b/syft/pkg/cataloger/golang/test-fixtures/Makefile index da3e730e1..f742a3228 100644 --- a/syft/pkg/cataloger/golang/test-fixtures/Makefile +++ b/syft/pkg/cataloger/golang/test-fixtures/Makefile @@ -3,13 +3,13 @@ default: @for dir in $(shell find . -mindepth 1 -maxdepth 1 -type d); do \ if [ -f "$$dir/Makefile" ]; then \ - $(MAKE) -C $$dir; \ + $(MAKE) -C $$dir || exit 1; \ fi; \ done %: @for dir in $(shell find . -mindepth 1 -maxdepth 1 -type d); do \ if [ -f "$$dir/Makefile" ]; then \ - $(MAKE) -C $$dir $@; \ + $(MAKE) -C $$dir $@ || exit 1; \ fi; \ done diff --git a/syft/pkg/cataloger/java/test-fixtures/Makefile b/syft/pkg/cataloger/java/test-fixtures/Makefile index da3e730e1..f742a3228 100644 --- a/syft/pkg/cataloger/java/test-fixtures/Makefile +++ b/syft/pkg/cataloger/java/test-fixtures/Makefile @@ -3,13 +3,13 @@ default: @for dir in $(shell find . -mindepth 1 -maxdepth 1 -type d); do \ if [ -f "$$dir/Makefile" ]; then \ - $(MAKE) -C $$dir; \ + $(MAKE) -C $$dir || exit 1; \ fi; \ done %: @for dir in $(shell find . -mindepth 1 -maxdepth 1 -type d); do \ if [ -f "$$dir/Makefile" ]; then \ - $(MAKE) -C $$dir $@; \ + $(MAKE) -C $$dir $@ || exit 1; \ fi; \ done diff --git a/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-java-app-gradle.sh b/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-java-app-gradle.sh index 075733ddc..80df9e35a 100755 --- a/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-java-app-gradle.sh +++ b/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-java-app-gradle.sh @@ -11,7 +11,6 @@ function cleanup() { } trap cleanup EXIT -set +e docker cp "$(pwd)/example-java-app" "${CTRID}:/" docker start -a "${CTRID}" diff --git a/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-java-app-maven.sh b/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-java-app-maven.sh index 2521a37f2..11b8b8a07 100755 --- a/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-java-app-maven.sh +++ b/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-java-app-maven.sh @@ -11,7 +11,6 @@ function cleanup() { } trap cleanup EXIT -set +e docker cp "$(pwd)/example-java-app" "${CTRID}:/" docker start -a "${CTRID}" diff --git a/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-java-app-native-image.sh b/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-java-app-native-image.sh index 8c2cc655d..46d358b02 100755 --- a/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-java-app-native-image.sh +++ b/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-java-app-native-image.sh @@ -3,16 +3,14 @@ set -uxe PKGSDIR=$1 -CTRID=$(docker create -v /example-java-app ghcr.io/graalvm/native-image:22.2.0 -cp /example-java-app/example-java-app-maven-0.1.0.jar -XX:-UseContainerSupport --no-fallback -H:Class=hello.HelloWorld -H:Name=example-java-app) +CTRID=$(docker create -v /example-java-app ghcr.io/graalvm/native-image:22.2.0 -J-XX:-UseContainerSupport -cp /example-java-app/example-java-app-maven-0.1.0.jar --no-fallback -H:Class=hello.HelloWorld -H:Name=example-java-app) function cleanup() { docker rm "${CTRID}" } trap cleanup EXIT -set +e docker cp "${PKGSDIR}/example-java-app-maven-0.1.0.jar" "${CTRID}:/example-java-app/" - docker start -a "${CTRID}" -docker cp "${CTRID}:/app/example-java-app" $PKGSDIR +docker cp "${CTRID}:/app/example-java-app" "$PKGSDIR" diff --git a/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-jenkins-plugin.sh b/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-jenkins-plugin.sh index 3c24b582a..b9f7d4d04 100755 --- a/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-jenkins-plugin.sh +++ b/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-jenkins-plugin.sh @@ -11,7 +11,6 @@ function cleanup() { } trap cleanup EXIT -set +e docker cp "$(pwd)/example-jenkins-plugin" "${CTRID}:/" docker start -a "${CTRID}" diff --git a/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-sb-app-nestedjar.sh b/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-sb-app-nestedjar.sh index 80dfbeb12..2483cf804 100755 --- a/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-sb-app-nestedjar.sh +++ b/syft/pkg/cataloger/java/test-fixtures/java-builds/build-example-sb-app-nestedjar.sh @@ -11,7 +11,6 @@ function cleanup() { } trap cleanup EXIT -set +e docker cp "$(pwd)/example-sb-app" "${CTRID}:/" docker start -a "${CTRID}"