Add acceptance test (#168)
To ease verifying the controller to work before submitting/merging PRs and releasing a new version of the controller.
This commit is contained in:
parent
8ccf64080c
commit
bbfe03f02b
|
|
@ -23,3 +23,6 @@ bin
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
*~
|
*~
|
||||||
|
|
||||||
|
.envrc
|
||||||
|
*.pem
|
||||||
|
|
|
||||||
23
Makefile
23
Makefile
|
|
@ -118,6 +118,29 @@ release: manifests
|
||||||
mkdir -p release
|
mkdir -p release
|
||||||
kustomize build config/default > release/actions-runner-controller.yaml
|
kustomize build config/default > release/actions-runner-controller.yaml
|
||||||
|
|
||||||
|
.PHONY: acceptance
|
||||||
|
acceptance: release
|
||||||
|
ACCEPTANCE_TEST_SECRET_TYPE=token make acceptance/setup acceptance/tests acceptance/teardown
|
||||||
|
ACCEPTANCE_TEST_SECRET_TYPE=app make acceptance/setup acceptance/tests acceptance/teardown
|
||||||
|
|
||||||
|
acceptance/setup:
|
||||||
|
kind create cluster --name acceptance
|
||||||
|
kubectl cluster-info --context kind-acceptance
|
||||||
|
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
|
||||||
|
kubectl -n cert-manager wait deploy/cert-manager-cainjector --for condition=available --timeout 60s
|
||||||
|
kubectl -n cert-manager wait deploy/cert-manager-webhook --for condition=available --timeout 60s
|
||||||
|
kubectl -n cert-manager wait deploy/cert-manager --for condition=available --timeout 60s
|
||||||
|
kubectl create namespace actions-runner-system
|
||||||
|
# Adhocly wait for some time until cert-manager's admission webhook gets ready
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
acceptance/teardown:
|
||||||
|
kind delete cluster --name acceptance
|
||||||
|
|
||||||
|
acceptance/tests:
|
||||||
|
acceptance/deploy.sh
|
||||||
|
acceptance/checks.sh
|
||||||
|
|
||||||
# Upload release file to GitHub.
|
# Upload release file to GitHub.
|
||||||
github-release: release
|
github-release: release
|
||||||
ghr ${VERSION} release/
|
ghr ${VERSION} release/
|
||||||
|
|
|
||||||
22
README.md
22
README.md
|
|
@ -446,6 +446,28 @@ Your base64'ed PAT token has a new line at the end, it needs to be created witho
|
||||||
* `echo -n $TOKEN | base64`
|
* `echo -n $TOKEN | base64`
|
||||||
* Create the secret as described in the docs using the shell and documeneted flags
|
* Create the secret as described in the docs using the shell and documeneted flags
|
||||||
|
|
||||||
|
# Developing
|
||||||
|
|
||||||
|
If you'd like to modify the controller to fork or contribute, I'd suggest using the following snippet for running
|
||||||
|
the acceptance test:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
NAME=$DOCKER_USER/actions-runner-controller VERSION=dev \
|
||||||
|
GITHUB_TOKEN=*** \
|
||||||
|
APP_ID=*** \
|
||||||
|
PRIVATE_KEY_FILE_PATH=path/to/pem/file \
|
||||||
|
INSTALLATION_ID=*** \
|
||||||
|
make docker-build docker-push acceptance
|
||||||
|
```
|
||||||
|
|
||||||
|
Please follow the instructions explained in [Using Personal Access Token](#using-personal-access-token) to obtain
|
||||||
|
`GITHUB_TOKEN`, and those in [Using GitHub App](#using-github-app) to obtain `APP_ID`, `INSTALLATION_ID`, and
|
||||||
|
`PRIAVTE_KEY_FILE_PATH`.
|
||||||
|
|
||||||
|
The test creates a one-off `kind` cluster, deploys `cert-manager` and `actions-runner-controller`,
|
||||||
|
creates a `RunnerDeployment` custom resource for a public Git repository to confirm that the
|
||||||
|
controller is able to bring up a runner pod with the actions runner registration token installed.
|
||||||
|
|
||||||
# Alternatives
|
# Alternatives
|
||||||
|
|
||||||
The following is a list of alternative solutions that may better fit you depending on your use-case:
|
The following is a list of alternative solutions that may better fit you depending on your use-case:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
runner_name=
|
||||||
|
|
||||||
|
while [ -z "${runner_name}" ]; do
|
||||||
|
echo Finding the runner... 1>&2
|
||||||
|
sleep 1
|
||||||
|
runner_name=$(kubectl get runner --output=jsonpath="{.items[*].metadata.name}")
|
||||||
|
done
|
||||||
|
|
||||||
|
echo Found runner ${runner_name}.
|
||||||
|
|
||||||
|
pod_name=
|
||||||
|
|
||||||
|
while [ -z "${pod_name}" ]; do
|
||||||
|
echo Finding the runner pod... 1>&2
|
||||||
|
sleep 1
|
||||||
|
pod_name=$(kubectl get pod --output=jsonpath="{.items[*].metadata.name}" | grep ${runner_name})
|
||||||
|
done
|
||||||
|
|
||||||
|
echo Found pod ${pod_name}.
|
||||||
|
|
||||||
|
echo Waiting for pod ${runner_name} to become ready... 1>&2
|
||||||
|
|
||||||
|
kubectl wait pod/${runner_name} --for condition=ready --timeout 120s
|
||||||
|
|
||||||
|
echo All tests passed. 1>&2
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
tpe=${ACCEPTANCE_TEST_SECRET_TYPE}
|
||||||
|
|
||||||
|
if [ "${tpe}" == "token" ]; then
|
||||||
|
kubectl create secret generic controller-manager \
|
||||||
|
-n actions-runner-system \
|
||||||
|
--from-literal=github_token=${GITHUB_TOKEN:?GITHUB_TOKEN must not be empty}
|
||||||
|
elif [ "${tpe}" == "app" ]; then
|
||||||
|
kubectl create secret generic controller-manager \
|
||||||
|
-n actions-runner-system \
|
||||||
|
--from-literal=github_app_id=${APP_ID:?must not be empty} \
|
||||||
|
--from-literal=github_app_installation_id=${INSTALLATION_ID:?must not be empty} \
|
||||||
|
--from-file=github_app_private_key=${PRIVATE_KEY_FILE_PATH:?must not be empty}
|
||||||
|
else
|
||||||
|
echo "ACCEPTANCE_TEST_SECRET_TYPE must be set to either \"token\" or \"app\"" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
kubectl apply \
|
||||||
|
-n actions-runner-system \
|
||||||
|
-f release/actions-runner-controller.yaml
|
||||||
|
|
||||||
|
kubectl -n actions-runner-system wait deploy/controller-manager --for condition=available
|
||||||
|
|
||||||
|
# Adhocly wait for some time until actions-runner-controller's admission webhook gets ready
|
||||||
|
sleep 20
|
||||||
|
|
||||||
|
kubectl apply \
|
||||||
|
-f acceptance/testdata/runnerdeploy.yaml
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
apiVersion: actions.summerwind.dev/v1alpha1
|
||||||
|
kind: RunnerDeployment
|
||||||
|
metadata:
|
||||||
|
name: example-runnerdeploy
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
repository: mumoshu/actions-runner-controller-ci
|
||||||
Loading…
Reference in New Issue