Locally build runner image instead of pulling it (#473)

* Fix acceptance helm test not using newly built controller image

* Locally build runner image instead of pulling it

* Revert runner controller image pull policy to always

and add a line to the test deployment to use IfNotPresent

* Change runner repository from summerwind/action-runner to the owner of actions-runner-controller.

Also fix some Makefile formatting.

* Undo renaming acceptance/pull to docker-pull

* Some env var cleanup

Rename USERNAME to DOCKER_USER(is still used for github too tho)
Add RUNNER_NAME var(defaults to $DOCKER_USER/actions-runner)
Add TEST_REPO(defaults to $DOCKER_USER/actions-runner-controller)
This commit is contained in:
ToMe25 2021-05-01 08:10:57 +02:00 committed by GitHub
parent 358146ee54
commit ba175148c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 28 deletions

View File

@ -1,5 +1,13 @@
ifdef DOCKER_USER
NAME ?= ${DOCKER_USER}/actions-runner-controller
else
NAME ?= summerwind/actions-runner-controller NAME ?= summerwind/actions-runner-controller
endif
DOCKER_USER ?= $(shell echo ${NAME} | cut -d / -f1)
RUNNER_NAME ?= ${DOCKER_USER}/actions-runner
VERSION ?= latest VERSION ?= latest
TEST_REPO ?= ${DOCKER_USER}/actions-runner-controller
# From https://github.com/VictoriaMetrics/operator/pull/44 # From https://github.com/VictoriaMetrics/operator/pull/44
YAML_DROP=$(YQ) delete --inplace YAML_DROP=$(YQ) delete --inplace
YAML_DROP_PREFIX=spec.validation.openAPIV3Schema.properties.spec.properties YAML_DROP_PREFIX=spec.validation.openAPIV3Schema.properties.spec.properties
@ -107,10 +115,7 @@ generate: controller-gen
# Build the docker image # Build the docker image
docker-build: test docker-build: test
docker build . -t ${NAME}:${VERSION} docker build . -t ${NAME}:${VERSION}
docker build runner -t ${RUNNER_NAME}:${VERSION} --build-arg TARGETPLATFORM=$(shell arch)
# Push the docker image
docker-push:
docker push ${NAME}:${VERSION}
docker-buildx: docker-buildx:
export DOCKER_CLI_EXPERIMENTAL=enabled export DOCKER_CLI_EXPERIMENTAL=enabled
@ -124,6 +129,11 @@ docker-buildx:
-f Dockerfile \ -f Dockerfile \
. ${PUSH_ARG} . ${PUSH_ARG}
# Push the docker image
docker-push:
docker push ${NAME}:${VERSION}
docker push ${RUNNER_NAME}:${VERSION}
# Generate the release manifest file # Generate the release manifest file
release: manifests release: manifests
cd config/manager && kustomize edit set image controller=${NAME}:${VERSION} cd config/manager && kustomize edit set image controller=${NAME}:${VERSION}
@ -135,8 +145,7 @@ release/clean:
rm -rf release rm -rf release
.PHONY: acceptance .PHONY: acceptance
acceptance: release/clean docker-build release acceptance: release/clean acceptance/pull release
make acceptance/pull
ACCEPTANCE_TEST_SECRET_TYPE=token make acceptance/kind acceptance/setup acceptance/tests acceptance/teardown ACCEPTANCE_TEST_SECRET_TYPE=token make acceptance/kind acceptance/setup acceptance/tests acceptance/teardown
ACCEPTANCE_TEST_SECRET_TYPE=app make acceptance/kind acceptance/setup acceptance/tests acceptance/teardown ACCEPTANCE_TEST_SECRET_TYPE=app make acceptance/kind acceptance/setup acceptance/tests acceptance/teardown
ACCEPTANCE_TEST_DEPLOYMENT_TOOL=helm ACCEPTANCE_TEST_SECRET_TYPE=token make acceptance/kind acceptance/setup acceptance/tests acceptance/teardown ACCEPTANCE_TEST_DEPLOYMENT_TOOL=helm ACCEPTANCE_TEST_SECRET_TYPE=token make acceptance/kind acceptance/setup acceptance/tests acceptance/teardown
@ -146,16 +155,16 @@ acceptance/kind:
kind create cluster --name acceptance kind create cluster --name acceptance
kind load docker-image ${NAME}:${VERSION} --name acceptance kind load docker-image ${NAME}:${VERSION} --name acceptance
kind load docker-image quay.io/brancz/kube-rbac-proxy:v0.8.0 --name acceptance kind load docker-image quay.io/brancz/kube-rbac-proxy:v0.8.0 --name acceptance
kind load docker-image summerwind/actions-runner:latest --name acceptance kind load docker-image ${RUNNER_NAME}:${VERSION} --name acceptance
kind load docker-image docker:dind --name acceptance kind load docker-image docker:dind --name acceptance
kind load docker-image quay.io/jetstack/cert-manager-controller:v1.0.4 --name acceptance kind load docker-image quay.io/jetstack/cert-manager-controller:v1.0.4 --name acceptance
kind load docker-image quay.io/jetstack/cert-manager-cainjector:v1.0.4 --name acceptance kind load docker-image quay.io/jetstack/cert-manager-cainjector:v1.0.4 --name acceptance
kind load docker-image quay.io/jetstack/cert-manager-webhook:v1.0.4 --name acceptance kind load docker-image quay.io/jetstack/cert-manager-webhook:v1.0.4 --name acceptance
kubectl cluster-info --context kind-acceptance kubectl cluster-info --context kind-acceptance
acceptance/pull: # Pull the docker images for acceptance
acceptance/pull: docker-build
docker pull quay.io/brancz/kube-rbac-proxy:v0.8.0 docker pull quay.io/brancz/kube-rbac-proxy:v0.8.0
docker pull summerwind/actions-runner:latest
docker pull docker:dind docker pull docker:dind
docker pull quay.io/jetstack/cert-manager-controller:v1.0.4 docker pull quay.io/jetstack/cert-manager-controller:v1.0.4
docker pull quay.io/jetstack/cert-manager-cainjector:v1.0.4 docker pull quay.io/jetstack/cert-manager-cainjector:v1.0.4
@ -174,7 +183,7 @@ acceptance/teardown:
kind delete cluster --name acceptance kind delete cluster --name acceptance
acceptance/tests: acceptance/tests:
acceptance/deploy.sh NAME=${NAME} RUNNER_NAME=${RUNNER_NAME} DOCKER_USER=${DOCKER_USER} VERSION=${VERSION} TEST_REPO=${TEST_REPO} acceptance/deploy.sh
acceptance/checks.sh acceptance/checks.sh
# Upload release file to GitHub. # Upload release file to GitHub.

View File

@ -786,12 +786,12 @@ the acceptance test:
# This sets `VERSION` envvar to some appropriate value # This sets `VERSION` envvar to some appropriate value
. hack/make-env.sh . hack/make-env.sh
NAME=$DOCKER_USER/actions-runner-controller \ DOCKER_USER=*** \
GITHUB_TOKEN=*** \ GITHUB_TOKEN=*** \
APP_ID=*** \ APP_ID=*** \
PRIVATE_KEY_FILE_PATH=path/to/pem/file \ PRIVATE_KEY_FILE_PATH=path/to/pem/file \
INSTALLATION_ID=*** \ INSTALLATION_ID=*** \
make docker-build acceptance make acceptance
``` ```
Please follow the instructions explained in [Using Personal Access Token](#using-personal-access-token) to obtain Please follow the instructions explained in [Using Personal Access Token](#using-personal-access-token) to obtain
@ -806,7 +806,7 @@ If you prefer to test in a non-kind cluster, you can instead run:
```shell script ```shell script
KUBECONFIG=path/to/kubeconfig \ KUBECONFIG=path/to/kubeconfig \
NAME=$DOCKER_USER/actions-runner-controller \ DOCKER_USER=*** \
GITHUB_TOKEN=*** \ GITHUB_TOKEN=*** \
APP_ID=*** \ APP_ID=*** \
PRIVATE_KEY_FILE_PATH=path/to/pem/file \ PRIVATE_KEY_FILE_PATH=path/to/pem/file \

View File

@ -27,7 +27,9 @@ if [ "${tool}" == "helm" ]; then
-n actions-runner-system \ -n actions-runner-system \
--create-namespace \ --create-namespace \
--set syncPeriod=5m \ --set syncPeriod=5m \
--set authSecret.create=false --set authSecret.create=false \
--set image.repository=${NAME} \
--set image.tag=${VERSION}
kubectl -n actions-runner-system wait deploy/actions-runner-controller --for condition=available --timeout 60s kubectl -n actions-runner-system wait deploy/actions-runner-controller --for condition=available --timeout 60s
else else
kubectl apply \ kubectl apply \
@ -39,5 +41,4 @@ fi
# Adhocly wait for some time until actions-runner-controller's admission webhook gets ready # Adhocly wait for some time until actions-runner-controller's admission webhook gets ready
sleep 20 sleep 20
kubectl apply \ cat acceptance/testdata/runnerdeploy.yaml | envsubst | kubectl apply -f -
-f acceptance/testdata/runnerdeploy.yaml

View File

@ -6,7 +6,10 @@ spec:
# replicas: 1 # replicas: 1
template: template:
spec: spec:
repository: mumoshu/actions-runner-controller-ci repository: ${TEST_REPO}
image: ${RUNNER_NAME}:${VERSION}
imagePullPolicy: IfNotPresent
# #
# dockerd within runner container # dockerd within runner container
# #

View File

@ -67,7 +67,7 @@ ENV RUNNER_ASSETS_DIR=/runnertmp
# It is installed after installdependencies.sh and before removing /var/lib/apt/lists # It is installed after installdependencies.sh and before removing /var/lib/apt/lists
# to avoid rerunning apt-update on its own. # to avoid rerunning apt-update on its own.
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& if [ "$ARCH" = "amd64" ]; then export ARCH=x64 ; fi \ && if [ "$ARCH" = "amd64" -o "$ARCH" = "x86_64" ]; then export ARCH=x64 ; fi \
&& mkdir -p "$RUNNER_ASSETS_DIR" \ && mkdir -p "$RUNNER_ASSETS_DIR" \
&& cd "$RUNNER_ASSETS_DIR" \ && cd "$RUNNER_ASSETS_DIR" \
&& curl -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \ && curl -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \

View File

@ -78,7 +78,7 @@ ENV RUNNER_ASSETS_DIR=/runnertmp
# It is installed after installdependencies.sh and before removing /var/lib/apt/lists # It is installed after installdependencies.sh and before removing /var/lib/apt/lists
# to avoid rerunning apt-update on its own. # to avoid rerunning apt-update on its own.
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& if [ "$ARCH" = "amd64" ]; then export ARCH=x64 ; fi \ && if [ "$ARCH" = "amd64" -o "$ARCH" = "x86_64" ]; then export ARCH=x64 ; fi \
&& mkdir -p "$RUNNER_ASSETS_DIR" \ && mkdir -p "$RUNNER_ASSETS_DIR" \
&& cd "$RUNNER_ASSETS_DIR" \ && cd "$RUNNER_ASSETS_DIR" \
&& curl -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \ && curl -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \

View File

@ -67,7 +67,7 @@ ENV RUNNER_ASSETS_DIR=/runnertmp
# It is installed after installdependencies.sh and before removing /var/lib/apt/lists # It is installed after installdependencies.sh and before removing /var/lib/apt/lists
# to avoid rerunning apt-update on its own. # to avoid rerunning apt-update on its own.
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& if [ "$ARCH" = "amd64" ]; then export ARCH=x64 ; fi \ && if [ "$ARCH" = "amd64" -o "$ARCH" = "x86_64" ]; then export ARCH=x64 ; fi \
&& mkdir -p "$RUNNER_ASSETS_DIR" \ && mkdir -p "$RUNNER_ASSETS_DIR" \
&& cd "$RUNNER_ASSETS_DIR" \ && cd "$RUNNER_ASSETS_DIR" \
&& curl -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \ && curl -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \