Skip to content

Commit

Permalink
build: Add image-test target to Makefile
Browse files Browse the repository at this point in the history
Signed-off-by: Paulo Gomes <[email protected]>
  • Loading branch information
pjbgf committed Mar 5, 2024
1 parent 179507f commit 2021b8e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,23 @@ jobs:
uses: docker/setup-buildx-action@v3
- name: Checkout code
uses: actions/checkout@v4

- name: E2E Tests
env:
KUBERNETES_VERSION: ${{ matrix.k8s-version }}
run: make e2e

image-build:
runs-on: ubuntu-latest
needs: [ validate ]

steps:
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Checkout code
uses: actions/checkout@v4

- name: Image build
run: make image-test
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ REPO ?= rancher
IMAGE = $(REPO)/security-scan:$(TAG)
TARGET_BIN ?= build/bin/kb-summarizer
ARCH ?= $(shell docker info --format '{{.ClientInfo.Arch}}')
BUILD_ACTION = --load

.DEFAULT_GOAL := ci
ci: build test validate e2e ## run the targets needed to validate a PR in CI.
Expand All @@ -30,11 +31,16 @@ build: # build project and output binary to TARGET_BIN.
$(TARGET_BIN) --version
md5sum $(TARGET_BIN)

image-test: buildx-machine ## build the container image for all target architecures.
# Instead of loading image, target all platforms, effectivelly testing
# the build for the target architectures.
$(MAKE) image-build BUILD_ACTION="--platform=$(TARGET_PLATFORMS)"

.PHONY: image-build
image-build: buildx-machine ## build (and load) the container image targeting the current platform.
$(IMAGE_BUILDER) build -f package/Dockerfile \
--builder $(MACHINE) $(IMAGE_ARGS) \
--build-arg VERSION=$(VERSION) -t "$(IMAGE)" --load .
--build-arg VERSION=$(VERSION) -t "$(IMAGE)" $(BUILD_ACTION) .
@echo "Built $(IMAGE)"

.PHONY: image-push
Expand Down

0 comments on commit 2021b8e

Please sign in to comment.