Skip to content

Commit 03266c5

Browse files
[no-relnote] Run e2e tests as reusable workflow
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent 92472bd commit 03266c5

File tree

5 files changed

+50
-15
lines changed

5 files changed

+50
-15
lines changed

.github/workflows/e2e.yaml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,25 @@
1515
name: End-to-end Tests
1616

1717
on:
18-
workflow_run:
19-
workflows: [image]
20-
types:
21-
- completed
22-
branches:
23-
- "pull-request/[0-9]+"
24-
- main
25-
- release-*
18+
workflow_call:
19+
inputs: {}
20+
secrets:
21+
AWS_ACCESS_KEY_ID:
22+
required: true
23+
AWS_SECRET_ACCESS_KEY:
24+
required: true
25+
AWS_SSH_KEY:
26+
required: true
27+
E2E_SSH_USER:
28+
required: true
29+
SLACK_BOT_TOKEN:
30+
required: true
31+
SLACK_CHANNEL_ID:
32+
required: true
2633

2734
jobs:
2835
e2e-tests:
2936
runs-on: linux-amd64-cpu4
30-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
3137
steps:
3238
- name: Check out code
3339
uses: actions/checkout@v4

.github/workflows/image.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
if [[ "${{ matrix.ispr }}" == "true" ]]; then
9595
BUILD_MULTI_ARCH_IMAGES="false"
9696
fi
97-
echo "PUSH_ON_BUILD=\"true\"" >> $GITHUB_ENV
97+
echo "PUSH_ON_BUILD="true" >> $GITHUB_ENV
9898
echo "BUILD_MULTI_ARCH_IMAGES=${BUILD_MULTI_ARCH_IMAGES}" >> $GITHUB_ENV
9999
- name: Set up QEMU
100100
uses: docker/setup-qemu-action@v3
@@ -122,3 +122,9 @@ jobs:
122122
run: |
123123
echo "${VERSION}"
124124
make -f deployments/container/Makefile build-${{ matrix.dist }}
125+
126+
test:
127+
name: End-to-end Tests
128+
uses: ./.github/workflows/e2e.yaml
129+
secrets: inherit
130+
needs: image

deployments/container/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ DISTRIBUTIONS := ubuntu20.04 ubi8
4343

4444
META_TARGETS := packaging
4545

46+
IMAGE_TARGETS := $(patsubst %,image-%,$(DISTRIBUTIONS) $(META_TARGETS))
4647
BUILD_TARGETS := $(patsubst %,build-%,$(DISTRIBUTIONS) $(META_TARGETS))
4748
PUSH_TARGETS := $(patsubst %,push-%,$(DISTRIBUTIONS) $(META_TARGETS))
4849
TEST_TARGETS := $(patsubst %,test-%,$(DISTRIBUTIONS))
@@ -83,7 +84,7 @@ build-%: DOCKERFILE = $(CURDIR)/deployments/container/Dockerfile.$(DOCKERFILE_SU
8384
ARTIFACTS_ROOT ?= $(shell realpath --relative-to=$(CURDIR) $(DIST_DIR))
8485

8586
# Use a generic build target to build the relevant images
86-
$(BUILD_TARGETS): build-%: $(ARTIFACTS_ROOT)
87+
$(IMAGE_TARGETS): image-%: $(ARTIFACTS_ROOT)
8788
DOCKER_BUILDKIT=1 \
8889
$(DOCKER) $(BUILDX) build --pull \
8990
--provenance=false --sbom=false \
@@ -102,7 +103,6 @@ $(BUILD_TARGETS): build-%: $(ARTIFACTS_ROOT)
102103
-f $(DOCKERFILE) \
103104
$(CURDIR)
104105

105-
106106
build-ubuntu%: DOCKERFILE_SUFFIX := ubuntu
107107
build-ubuntu%: PACKAGE_DIST = ubuntu18.04
108108

@@ -116,6 +116,12 @@ build-packaging: PACKAGE_DIST = all
116116
# Test targets
117117
test-%: DIST = $(*)
118118

119+
# Handle the default build target.
120+
.PHONY: build
121+
build: $(DEFAULT_PUSH_TARGET)
122+
$(DEFAULT_PUSH_TARGET): build-$(DEFAULT_PUSH_TARGET)
123+
$(DEFAULT_PUSH_TARGET): DIST = $(DEFAULT_PUSH_TARGET)
124+
119125
TEST_CASES ?= docker crio containerd
120126
$(TEST_TARGETS): test-%:
121127
TEST_CASES="$(TEST_CASES)" bash -x $(CURDIR)/test/container/main.sh run \

deployments/container/multi-arch.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ PUSH_ON_BUILD ?= false
1616
DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD)
1717
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64,linux/arm64
1818

19-
# We only generate amd64 image for ubuntu18.04
20-
build-ubuntu18.04: DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64
19+
$(BUILD_TARGETS): build-%: image-%
2120

2221
# We only generate a single image for packaging targets
2322
build-packaging: DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64

deployments/container/native-only.mk

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,22 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64
15+
PUSH_ON_BUILD ?= false
16+
ARCH ?= $(shell uname -m)
17+
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/$(ARCH)
18+
19+
ifeq ($(PUSH_ON_BUILD),true)
20+
DOCKER_BUILD_OPTIONS = --output=type=image,push=$(PUSH_ON_BUILD)
21+
$(BUILD_TARGETS): build-%: image-%
22+
$(DOCKER) push "$(IMAGE)"
23+
else
24+
$(BUILD_TARGETS): build-%: image-%
25+
endif
26+
27+
# For the default distribution we also retag the image.
28+
# Note: This needs to be updated for multi-arch images.
29+
ifeq ($(IMAGE_TAG),$(VERSION)-$(DIST))
30+
$(DEFAULT_PUSH_TARGET):
31+
$(DOCKER) image inspect $(IMAGE) > /dev/null || $(DOCKER) pull $(IMAGE)
32+
$(DOCKER) tag $(IMAGE) $(subst :$(IMAGE_TAG),:$(VERSION),$(IMAGE))
33+
endif

0 commit comments

Comments
 (0)