Skip to content

Commit

Permalink
Locally build runner image instead of pulling it (actions#473)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
ToMe25 authored May 1, 2021
1 parent 358146e commit ba17514
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 28 deletions.
45 changes: 27 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
NAME ?= summerwind/actions-runner-controller
ifdef DOCKER_USER
NAME ?= ${DOCKER_USER}/actions-runner-controller
else
NAME ?= summerwind/actions-runner-controller
endif
DOCKER_USER ?= $(shell echo ${NAME} | cut -d / -f1)
RUNNER_NAME ?= ${DOCKER_USER}/actions-runner
VERSION ?= latest
TEST_REPO ?= ${DOCKER_USER}/actions-runner-controller

# From https://github.com/VictoriaMetrics/operator/pull/44
YAML_DROP=$(YQ) delete --inplace
YAML_DROP_PREFIX=spec.validation.openAPIV3Schema.properties.spec.properties
Expand All @@ -24,8 +32,8 @@ endif
# if IMG_RESULT is unspecified, by default the image will be pushed to registry
ifeq (${IMG_RESULT}, load)
export PUSH_ARG="--load"
# if load is specified, image will be built only for the build machine architecture.
export PLATFORMS="local"
# if load is specified, image will be built only for the build machine architecture.
export PLATFORMS="local"
else ifeq (${IMG_RESULT}, cache)
# if cache is specified, image will only be available in the build cache, it won't be pushed or loaded
# therefore no PUSH_ARG will be specified
Expand Down Expand Up @@ -107,10 +115,7 @@ generate: controller-gen
# Build the docker image
docker-build: test
docker build . -t ${NAME}:${VERSION}

# Push the docker image
docker-push:
docker push ${NAME}:${VERSION}
docker build runner -t ${RUNNER_NAME}:${VERSION} --build-arg TARGETPLATFORM=$(shell arch)

docker-buildx:
export DOCKER_CLI_EXPERIMENTAL=enabled
Expand All @@ -124,6 +129,11 @@ docker-buildx:
-f Dockerfile \
. ${PUSH_ARG}

# Push the docker image
docker-push:
docker push ${NAME}:${VERSION}
docker push ${RUNNER_NAME}:${VERSION}

# Generate the release manifest file
release: manifests
cd config/manager && kustomize edit set image controller=${NAME}:${VERSION}
Expand All @@ -135,8 +145,7 @@ release/clean:
rm -rf release

.PHONY: acceptance
acceptance: release/clean docker-build release
make acceptance/pull
acceptance: release/clean acceptance/pull release
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_DEPLOYMENT_TOOL=helm ACCEPTANCE_TEST_SECRET_TYPE=token make acceptance/kind acceptance/setup acceptance/tests acceptance/teardown
Expand All @@ -146,20 +155,20 @@ acceptance/kind:
kind create cluster --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 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 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-webhook:v1.0.4 --name acceptance
kubectl cluster-info --context kind-acceptance

acceptance/pull:
docker pull quay.io/brancz/kube-rbac-proxy:v0.8.0
docker pull summerwind/actions-runner:latest
docker pull docker:dind
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-webhook:v1.0.4
# Pull the docker images for acceptance
acceptance/pull: docker-build
docker pull quay.io/brancz/kube-rbac-proxy:v0.8.0
docker pull docker:dind
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-webhook:v1.0.4

acceptance/setup:
kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v1.0.4/cert-manager.yaml #kubectl create namespace actions-runner-system
Expand All @@ -174,7 +183,7 @@ acceptance/teardown:
kind delete cluster --name acceptance

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

# Upload release file to GitHub.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -786,12 +786,12 @@ the acceptance test:
# This sets `VERSION` envvar to some appropriate value
. hack/make-env.sh

NAME=$DOCKER_USER/actions-runner-controller \
DOCKER_USER=*** \
GITHUB_TOKEN=*** \
APP_ID=*** \
PRIVATE_KEY_FILE_PATH=path/to/pem/file \
INSTALLATION_ID=*** \
make docker-build acceptance
make acceptance
```

Please follow the instructions explained in [Using Personal Access Token](#using-personal-access-token) to obtain
Expand All @@ -806,7 +806,7 @@ If you prefer to test in a non-kind cluster, you can instead run:

```shell script
KUBECONFIG=path/to/kubeconfig \
NAME=$DOCKER_USER/actions-runner-controller \
DOCKER_USER=*** \
GITHUB_TOKEN=*** \
APP_ID=*** \
PRIVATE_KEY_FILE_PATH=path/to/pem/file \
Expand Down
7 changes: 4 additions & 3 deletions acceptance/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ if [ "${tool}" == "helm" ]; then
-n actions-runner-system \
--create-namespace \
--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
else
kubectl apply \
Expand All @@ -39,5 +41,4 @@ fi
# Adhocly wait for some time until actions-runner-controller's admission webhook gets ready
sleep 20

kubectl apply \
-f acceptance/testdata/runnerdeploy.yaml
cat acceptance/testdata/runnerdeploy.yaml | envsubst | kubectl apply -f -
5 changes: 4 additions & 1 deletion acceptance/testdata/runnerdeploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ spec:
# replicas: 1
template:
spec:
repository: mumoshu/actions-runner-controller-ci
repository: ${TEST_REPO}
image: ${RUNNER_NAME}:${VERSION}
imagePullPolicy: IfNotPresent

#
# dockerd within runner container
#
Expand Down
2 changes: 1 addition & 1 deletion runner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ENV RUNNER_ASSETS_DIR=/runnertmp
# It is installed after installdependencies.sh and before removing /var/lib/apt/lists
# to avoid rerunning apt-update on its own.
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" \
&& 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 \
Expand Down
2 changes: 1 addition & 1 deletion runner/Dockerfile.dindrunner
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ENV RUNNER_ASSETS_DIR=/runnertmp
# It is installed after installdependencies.sh and before removing /var/lib/apt/lists
# to avoid rerunning apt-update on its own.
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" \
&& 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 \
Expand Down
2 changes: 1 addition & 1 deletion runner/Dockerfile.ubuntu.1804
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ENV RUNNER_ASSETS_DIR=/runnertmp
# It is installed after installdependencies.sh and before removing /var/lib/apt/lists
# to avoid rerunning apt-update on its own.
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" \
&& 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 \
Expand Down

0 comments on commit ba17514

Please sign in to comment.