Skip to content

Commit 5a6ee7c

Browse files
committed
allow container image to be built in project root or tests directory
1 parent 46fcf92 commit 5a6ee7c

File tree

2 files changed

+51
-14
lines changed

2 files changed

+51
-14
lines changed

tests/Dockerfile

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# syntax=docker/dockerfile:1.5
1+
# syntax=docker/dockerfile:1.11
22
# this is here so we can grab the latest version of kind and have dependabot keep it up to date
33
FROM kindest/node:v1.32.2@sha256:f226345927d7e348497136874b6d207e0b32cc52154ad8323129352923a3142f
44

@@ -8,27 +8,23 @@ FROM quay.io/skopeo/stable:v1.17.0
88
FROM python:3.13@sha256:08471c63c5fdf2644adc142a7fa8d0290eb405cda14c473fbe5b4cd0933af601
99

1010
RUN apt-get update \
11-
&& apt-get install -y curl git \
11+
&& apt-get install -y curl git apache2-utils \
1212
&& rm -rf /var/lib/apt/lists/*
1313

1414
WORKDIR /workspace/tests
1515

16-
COPY --link tests/requirements.txt /workspace/tests/
17-
RUN pip install --require-hashes -r requirements.txt --no-deps
18-
RUN playwright install --with-deps chromium
1916

17+
COPY --link tests/requirements.txt /workspace/tests/
2018
COPY --link deployments /workspace/deployments
2119
COPY --link config /workspace/config
20+
COPY --link tests /workspace/tests
21+
COPY --link pyproject.toml /workspace/pyproject.toml
2222

2323
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \
2424
&& install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl \
25-
&& apt-get update && apt-get install -y apache2-utils
25+
&& curl https://get.docker.com/builds/Linux/x86_64/docker-latest.tgz | tar xvz -C /tmp/ && mv /tmp/docker/docker /usr/bin/docker
2626

27-
RUN apt update -y \
28-
&& curl https://get.docker.com/builds/Linux/x86_64/docker-latest.tgz | tar xvz -C /tmp/ && mv /tmp/docker/docker /usr/bin/docker
29-
30-
COPY --link tests /workspace/tests
31-
32-
COPY --link pyproject.toml /workspace/
27+
RUN pip install --require-hashes -r requirements.txt --no-deps
28+
RUN playwright install --with-deps chromium
3329

3430
ENTRYPOINT ["python3", "-m", "pytest"]

tests/Makefile

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ KUBE_CONFIG_FOLDER = ${HOME}/.kube
1010
KIND_KUBE_CONFIG_FOLDER = $(KUBE_CONFIG_FOLDER)/kind
1111
MINIKUBE_KUBE_CONFIG_FOLDER = $(KUBE_CONFIG_FOLDER)/minikube
1212
DOCKERFILEPATH := ${ROOT_DIR}/tests/Dockerfile
13+
PYTHON ?= python3
1314
IP_FAMILY = dual
1415
IC_TYPE ?= nginx-ingress ## The Ingress Controller type to use, "nginx-ingress" or "nginx-plus-ingress". Defaults to "nginx-ingress"
1516
SHOW_IC_LOGS ?= no ## Should the tests show the Ingress Controller logs on failure, "yes" or "no". Defaults to "no"
@@ -36,7 +37,7 @@ help: ## Show available make targets
3637

3738
.PHONY: build
3839
build: ## Run build
39-
docker build -t $(TEST_PREFIX):$(TEST_TAG) -f $(DOCKERFILEPATH) ..
40+
docker build -t $(TEST_PREFIX):$(TEST_TAG) -f $(DOCKERFILEPATH) $(ROOT_DIR)
4041

4142

4243
$(KUBE_CONFIG_FOLDER):
@@ -51,9 +52,49 @@ $(MINIKUBE_KUBE_CONFIG_FOLDER): $(KUBE_CONFIG_FOLDER)
5152
@mkdir -p $@
5253

5354

55+
.PHONY: setup-venv
56+
setup-venv:
57+
$(PYTHON) -m venv $(ROOT_DIR)/tests/venv;
58+
source $(ROOT_DIR)/tests/venv/bin/activate \
59+
&& pip install --require-hashes -r requirements.txt --no-deps \
60+
&& playwright install --with-deps chromium
61+
62+
63+
.PHONY: clean-venv
64+
clean-venv:
65+
@rm -rf $(ROOT_DIR)/tests/venv
66+
67+
68+
.PHONY: run-local-tests
69+
run-local-tests: ## Run tests
70+
source $(ROOT_DIR)/tests/venv/bin/activate \
71+
&& pytest \
72+
--image=$(BUILD_IMAGE) \
73+
--image-pull-policy=$(PULL_POLICY) \
74+
--deployment-type=$(DEPLOYMENT_TYPE) \
75+
--ic-type=$(IC_TYPE) \
76+
--service=$(SERVICE) \
77+
--node-ip=$(NODE_IP) \
78+
--show-ic-logs=$(SHOW_IC_LOGS) \
79+
--plus-jwt=$(PLUS_JWT) \
80+
-sv \
81+
$(PYTEST_ARGS)
82+
83+
5484
.PHONY: run-tests
5585
run-tests: ## Run tests
56-
docker run --rm -v $(KUBE_CONFIG_FOLDER):/root/.kube $(TEST_PREFIX):$(TEST_TAG) --context=$(CONTEXT) --image=$(BUILD_IMAGE) --image-pull-policy=$(PULL_POLICY) --deployment-type=$(DEPLOYMENT_TYPE) --ic-type=$(IC_TYPE) --service=$(SERVICE) --node-ip=$(NODE_IP) --show-ic-logs=$(SHOW_IC_LOGS) $(PYTEST_ARGS)
86+
docker run --rm -v $(KUBE_CONFIG_FOLDER):/root/.kube \
87+
$(TEST_PREFIX):$(TEST_TAG) \
88+
--context=$(CONTEXT) \
89+
--image=$(BUILD_IMAGE) \
90+
--image-pull-policy=$(PULL_POLICY) \
91+
--deployment-type=$(DEPLOYMENT_TYPE) \
92+
--ic-type=$(IC_TYPE) \
93+
--service=$(SERVICE) \
94+
--node-ip=$(NODE_IP) \
95+
--show-ic-logs=$(SHOW_IC_LOGS) \
96+
--plus-jwt=$(PLUS_JWT) \
97+
$(PYTEST_ARGS)
5798

5899

59100
.PHONY: run-tests-in-kind

0 commit comments

Comments
 (0)