diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 1c4de830..dd2259b3 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -15,19 +15,25 @@ name: End-to-end Tests on: - workflow_run: - workflows: [image] - types: - - completed - branches: - - "pull-request/[0-9]+" - - main - - release-* + workflow_call: + inputs: {} + secrets: + AWS_ACCESS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + AWS_SSH_KEY: + required: true + E2E_SSH_USER: + required: true + SLACK_BOT_TOKEN: + required: true + SLACK_CHANNEL_ID: + required: true jobs: e2e-tests: runs-on: linux-amd64-cpu4 - if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: Check out code uses: actions/checkout@v4 diff --git a/.github/workflows/image.yaml b/.github/workflows/image.yaml index 81434839..16f79328 100644 --- a/.github/workflows/image.yaml +++ b/.github/workflows/image.yaml @@ -94,7 +94,7 @@ jobs: if [[ "${{ matrix.ispr }}" == "true" ]]; then BUILD_MULTI_ARCH_IMAGES="false" fi - echo "PUSH_ON_BUILD=\"true\"" >> $GITHUB_ENV + echo "PUSH_ON_BUILD="true" >> $GITHUB_ENV echo "BUILD_MULTI_ARCH_IMAGES=${BUILD_MULTI_ARCH_IMAGES}" >> $GITHUB_ENV - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -122,3 +122,9 @@ jobs: run: | echo "${VERSION}" make -f deployments/container/Makefile build-${{ matrix.dist }} + + test: + name: End-to-end Tests + uses: ./.github/workflows/e2e.yaml + secrets: inherit + needs: image \ No newline at end of file diff --git a/deployments/container/Makefile b/deployments/container/Makefile index 3d37051e..a2a1f23b 100644 --- a/deployments/container/Makefile +++ b/deployments/container/Makefile @@ -43,6 +43,7 @@ DISTRIBUTIONS := ubuntu20.04 ubi8 META_TARGETS := packaging +IMAGE_TARGETS := $(patsubst %,image-%,$(DISTRIBUTIONS) $(META_TARGETS)) BUILD_TARGETS := $(patsubst %,build-%,$(DISTRIBUTIONS) $(META_TARGETS)) PUSH_TARGETS := $(patsubst %,push-%,$(DISTRIBUTIONS) $(META_TARGETS)) TEST_TARGETS := $(patsubst %,test-%,$(DISTRIBUTIONS)) @@ -83,7 +84,7 @@ build-%: DOCKERFILE = $(CURDIR)/deployments/container/Dockerfile.$(DOCKERFILE_SU ARTIFACTS_ROOT ?= $(shell realpath --relative-to=$(CURDIR) $(DIST_DIR)) # Use a generic build target to build the relevant images -$(BUILD_TARGETS): build-%: $(ARTIFACTS_ROOT) +$(IMAGE_TARGETS): image-%: $(ARTIFACTS_ROOT) DOCKER_BUILDKIT=1 \ $(DOCKER) $(BUILDX) build --pull \ --provenance=false --sbom=false \ @@ -102,7 +103,6 @@ $(BUILD_TARGETS): build-%: $(ARTIFACTS_ROOT) -f $(DOCKERFILE) \ $(CURDIR) - build-ubuntu%: DOCKERFILE_SUFFIX := ubuntu build-ubuntu%: PACKAGE_DIST = ubuntu18.04 @@ -116,6 +116,12 @@ build-packaging: PACKAGE_DIST = all # Test targets test-%: DIST = $(*) +# Handle the default build target. +.PHONY: build +build: $(DEFAULT_PUSH_TARGET) +$(DEFAULT_PUSH_TARGET): build-$(DEFAULT_PUSH_TARGET) +$(DEFAULT_PUSH_TARGET): DIST = $(DEFAULT_PUSH_TARGET) + TEST_CASES ?= docker crio containerd $(TEST_TARGETS): test-%: TEST_CASES="$(TEST_CASES)" bash -x $(CURDIR)/test/container/main.sh run \ diff --git a/deployments/container/multi-arch.mk b/deployments/container/multi-arch.mk index d2824e99..72f34ab2 100644 --- a/deployments/container/multi-arch.mk +++ b/deployments/container/multi-arch.mk @@ -16,8 +16,7 @@ PUSH_ON_BUILD ?= false DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD) DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64,linux/arm64 -# We only generate amd64 image for ubuntu18.04 -build-ubuntu18.04: DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64 +$(BUILD_TARGETS): build-%: image-% # We only generate a single image for packaging targets build-packaging: DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64 diff --git a/deployments/container/native-only.mk b/deployments/container/native-only.mk index d15b78a4..79d7fa99 100644 --- a/deployments/container/native-only.mk +++ b/deployments/container/native-only.mk @@ -12,4 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64 +PUSH_ON_BUILD ?= false +ARCH ?= $(shell uname -m) +DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/$(ARCH) + +ifeq ($(PUSH_ON_BUILD),true) +DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD) +$(BUILD_TARGETS): build-%: image-% + $(DOCKER) push "$(IMAGE)" +else +$(BUILD_TARGETS): build-%: image-% +endif + +# For the default distribution we also retag the image. +# Note: This needs to be updated for multi-arch images. +ifeq ($(IMAGE_TAG),$(VERSION)-$(DIST)) +$(DEFAULT_PUSH_TARGET): + $(DOCKER) image inspect $(IMAGE) > /dev/null || $(DOCKER) pull $(IMAGE) + $(DOCKER) tag $(IMAGE) $(subst :$(IMAGE_TAG),:$(VERSION),$(IMAGE)) +endif