From cc64a5ed71f21cc8c370f606050b197c652cc3a5 Mon Sep 17 00:00:00 2001 From: Stefan Reimer Date: Thu, 22 Dec 2022 11:56:30 +0000 Subject: [PATCH] ci: test PR flow --- .ci/podman.mk | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.ci/podman.mk b/.ci/podman.mk index 55cff91..86d2739 100644 --- a/.ci/podman.mk +++ b/.ci/podman.mk @@ -1,11 +1,11 @@ # Parse version from latest git semver tag -BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) +GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) GIT_TAG := $(shell git describe --tags --match v*.*.* 2>/dev/null || git rev-parse --short HEAD 2>/dev/null) -TAG := $(GIT_TAG) # append branch name to tag if NOT main nor master -ifeq (,$(filter main master, $(BRANCH))) - TAG = $(GIT_TAG)-$(BRANCH) +TAG := $(GIT_TAG) +ifeq (,$(filter main master, $(GIT_BRANCH))) + TAG = $(GIT_TAG)-$(GIT_BRANCH) endif # optionally set by the caller @@ -19,7 +19,7 @@ ifneq ($(TRIVY_REMOTE),) TRIVY_OPTS := --server $(TRIVY_REMOTE) endif -.SILENT: ; # no need for @ +#.SILENT: ; # no need for @ .ONESHELL: ; # recipes execute in same shell .NOTPARALLEL: ; # wait for this target to finish .EXPORT_ALL_VARIABLES: ; # send all vars to shell @@ -30,6 +30,7 @@ help: ## Show Help grep -E '^[a-zA-Z_-]+:.*?## .*$$' .ci/podman.mk | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' build: ## Build the app + printenv buildah build --rm --layers -t $(IMAGE):$(TAG)-$(_ARCH) --build-arg TAG=$(TAG) --build-arg ARCH=$(_ARCH) --platform linux/$(_ARCH) . test: rm-test-image ## Execute Dockerfile.test @@ -68,13 +69,13 @@ rm-remote-untagged: ## delete all remote untagged images [ -n "$$IMAGE_IDS" ] && aws ecr-public batch-delete-image --repository-name $(IMAGE) --region $(REGION) --image-ids $$IMAGE_IDS || echo "No image to remove" rm-image: - test -z "$$(docker image ls -q $(IMAGE):$(TAG)-$(_ARCH))" || podman image rm -f $(IMAGE):$(TAG)-$(_ARCH) > /dev/null - test -z "$$(docker image ls -q $(IMAGE):$(TAG)-$(_ARCH))" || echo "Error: Removing image failed" + test -z "$$(podman image ls -q $(IMAGE):$(TAG)-$(_ARCH))" || podman image rm -f $(IMAGE):$(TAG)-$(_ARCH) > /dev/null + test -z "$$(podman image ls -q $(IMAGE):$(TAG)-$(_ARCH))" || echo "Error: Removing image failed" # Ensure we run the tests by removing any previous runs rm-test-image: - test -z "$$(docker image ls -q $(IMAGE):$(TAG)-$(_ARCH)-test)" || podman image rm -f $(IMAGE):$(TAG)-$(_ARCH)-test > /dev/null - test -z "$$(docker image ls -q $(IMAGE):$(TAG)-$(_ARCH)-test)" || echo "Error: Removing test image failed" + test -z "$$(podman image ls -q $(IMAGE):$(TAG)-$(_ARCH)-test)" || podman image rm -f $(IMAGE):$(TAG)-$(_ARCH)-test > /dev/null + test -z "$$(podman image ls -q $(IMAGE):$(TAG)-$(_ARCH)-test)" || echo "Error: Removing test image failed" ci-pull-upstream: ## pull latest shared .ci subtree git stash && git subtree pull --prefix .ci ssh://git@git.zero-downtime.net/ZeroDownTime/ci-tools-lib.git master --squash && git stash pop