2021-05-01 08:10:57 +02:00
i f d e f D O C K E R _ U S E R
2023-02-20 18:27:14 -05:00
DOCKER_IMAGE_NAME ?= ${ DOCKER_USER } /actions-runner-controller
2021-05-01 08:10:57 +02:00
e l s e
2023-02-20 18:27:14 -05:00
DOCKER_IMAGE_NAME ?= summerwind/actions-runner-controller
2021-05-01 08:10:57 +02:00
e n d i f
2023-02-20 18:27:14 -05:00
DOCKER_USER ?= $( shell echo ${ DOCKER_IMAGE_NAME } | cut -d / -f1)
2022-08-23 06:40:16 +02:00
VERSION ?= dev
2023-09-14 20:10:49 +02:00
COMMIT_SHA = $( shell git rev-parse HEAD)
2026-04-22 17:26:50 +02:00
RUNNER_VERSION ?= 2.334.0
2021-12-29 01:23:35 +00:00
TARGETPLATFORM ?= $( shell arch)
2021-05-03 13:03:17 +09:00
RUNNER_NAME ?= ${ DOCKER_USER } /actions-runner
RUNNER_TAG ?= ${ VERSION }
2021-05-01 08:10:57 +02:00
TEST_REPO ?= ${ DOCKER_USER } /actions-runner-controller
2021-05-11 06:30:57 +00:00
TEST_ORG ?=
TEST_ORG_REPO ?=
2021-08-11 09:52:04 +09:00
TEST_EPHEMERAL ?= false
2022-04-24 02:47:00 +01:00
SYNC_PERIOD ?= 1m
2021-06-22 17:10:09 +09:00
USE_RUNNERSET ?=
KUBECONTEXT ?= kind-acceptance
CLUSTER ?= acceptance
CERT_MANAGER_VERSION ?= v1.1.1
2021-12-08 22:53:50 +00:00
KUBE_RBAC_PROXY_VERSION ?= v0.11.0
2025-04-17 12:19:15 +02:00
SHELLCHECK_VERSION ?= 0.10.0
2021-05-01 08:10:57 +02:00
2020-01-28 15:03:23 +09:00
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
2025-03-24 15:27:42 +01:00
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true,allowDangerousTypes=true"
2020-01-28 15:03:23 +09:00
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
i f e q ( , $( shell go env GOBIN ) )
GOBIN = $( shell go env GOPATH) /bin
e l s e
GOBIN = $( shell go env GOBIN)
e n d i f
2022-10-04 20:30:43 +09:00
TOOLS_PATH = $( PWD) /.tools
2021-03-31 09:23:16 +09:00
2022-11-03 05:57:04 -06:00
OS_NAME := $( shell uname -s | tr A-Z a-z)
2026-02-24 13:36:01 +01:00
# ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script
ENVTEST_VERSION ?= $( shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}' )
# ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries
ENVTEST_K8S_VERSION ?= $( shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}' )
ENVTEST ?= $( GOBIN) /setup-envtest
2022-11-25 21:08:24 -07:00
2020-10-05 11:26:46 +11:00
# default list of platforms for which multiarch image is built
i f e q ( $ { P L A T F O R M S } , )
export PLATFORMS = "linux/amd64,linux/arm64"
e n d i f
# if IMG_RESULT is unspecified, by default the image will be pushed to registry
i f e q ( $ { I M G _ R E S U L T } , l o a d )
export PUSH_ARG = "--load"
2021-05-01 08:10:57 +02:00
# if load is specified, image will be built only for the build machine architecture.
export PLATFORMS = "local"
2020-10-05 11:26:46 +11:00
e l s e i f e q ( $ { I M G _ R E S U L T } , c a c h e )
# 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
e l s e
export PUSH_ARG = "--push"
e n d i f
2020-01-28 15:03:23 +09:00
all : manager
2022-09-20 20:08:22 -04:00
lint :
2026-03-11 10:24:20 +01:00
docker run --rm -v $( PWD) :/app -w /app golangci/golangci-lint:v2.11.2 golangci-lint run
2022-09-20 20:08:22 -04:00
2021-06-27 16:28:07 +09:00
GO_TEST_ARGS ?= -short
2026-02-24 13:36:01 +01:00
2020-01-28 15:03:23 +09:00
# Run tests
2026-02-24 13:36:01 +01:00
test : generate fmt vet manifests shellcheck setup -envtest
KUBEBUILDER_ASSETS = " $$ ( $( ENVTEST) use $( ENVTEST_K8S_VERSION) --bin-dir $( GOBIN) -p path) " \
go test $( GO_TEST_ARGS) ` go list ./... | grep -v ./test_e2e_arc` -coverprofile cover.out
KUBEBUILDER_ASSETS = " $$ ( $( ENVTEST) use $( ENVTEST_K8S_VERSION) --bin-dir $( GOBIN) -p path) " \
go test -fuzz= Fuzz -fuzztime= 10s -run= Fuzz* ./controllers/actions.summerwind.net
test-with-deps : setup -envtest
KUBEBUILDER_ASSETS = " $$ ( $( ENVTEST) use $( ENVTEST_K8S_VERSION) --bin-dir $( GOBIN) -p path) " \
2021-03-31 09:23:16 +09:00
make test
2026-02-24 13:36:01 +01:00
2020-01-28 15:03:23 +09:00
# Build manager binary
manager : generate fmt vet
go build -o bin/manager main.go
2025-03-07 11:58:16 +01:00
go build -o bin/github-runnerscaleset-listener ./cmd/ghalistener
2020-01-28 15:03:23 +09:00
# Run against the configured Kubernetes cluster in ~/.kube/config
run : generate fmt vet manifests
go run ./main.go
2023-03-10 18:05:51 +01:00
run-scaleset : generate fmt vet
CONTROLLER_MANAGER_POD_NAMESPACE = default \
CONTROLLER_MANAGER_CONTAINER_IMAGE = " ${ DOCKER_IMAGE_NAME } : ${ VERSION } " \
2023-07-03 18:52:04 +09:00
go run -ldflags= " -s -w -X 'github.com/actions/actions-runner-controller/build.Version= $( VERSION) ' " \
./main.go --auto-scaling-runner-set-only
2023-03-10 18:05:51 +01:00
2020-01-28 15:03:23 +09:00
# Install CRDs into a cluster
install : manifests
2023-03-10 18:05:51 +01:00
kustomize build config/crd | kubectl apply --server-side -f -
2020-01-28 15:03:23 +09:00
# Uninstall CRDs from a cluster
uninstall : manifests
kustomize build config/crd | kubectl delete -f -
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy : manifests
2023-02-20 18:27:14 -05:00
cd config/manager && kustomize edit set image controller = ${ DOCKER_IMAGE_NAME } :${ VERSION }
2023-03-10 18:05:51 +01:00
kustomize build config/default | kubectl apply --server-side -f -
2020-01-28 15:03:23 +09:00
# Generate manifests e.g. CRD, RBAC etc.
2021-09-10 10:07:04 +01:00
manifests : manifests -gen -crds chart -crds
2020-10-15 02:39:46 +03:00
2021-09-23 18:03:35 +01:00
manifests-gen-crds : controller -gen yq
2020-01-28 15:03:23 +09:00
$( CONTROLLER_GEN) $( CRD_OPTIONS) rbac:roleName= manager-role webhook paths = "./..." output:crd:artifacts:config= config/crd/bases
2023-03-01 07:19:47 +09:00
make manifests-gen-crds-fix DELETE_KEY = x-kubernetes-list-type
make manifests-gen-crds-fix DELETE_KEY = x-kubernetes-list-map-keys
manifests-gen-crds-fix : DELETE_KEY ?=
manifests-gen-crds-fix :
2023-01-27 09:23:28 +09:00
#runners
2023-03-01 07:19:47 +09:00
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runners.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.ephemeralContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runners.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.initContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runners.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.containers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runners.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.sidecarContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runners.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.dockerdContainerResources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runners.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.volumes.items.properties.ephemeral.properties.volumeClaimTemplate.properties.spec.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runners.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.workVolumeClaimTemplate.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runners.yaml
2023-01-27 09:23:28 +09:00
#runnerreplicasets
2023-03-01 07:19:47 +09:00
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerreplicasets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.sidecarContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerreplicasets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.dockerdContainerResources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerreplicasets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.ephemeralContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerreplicasets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.containers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerreplicasets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.initContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerreplicasets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.volumes.items.properties.ephemeral.properties.volumeClaimTemplate.properties.spec.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerreplicasets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.workVolumeClaimTemplate.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerreplicasets.yaml
2023-01-27 09:23:28 +09:00
#runnerdeployments
2023-03-01 07:19:47 +09:00
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.initContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.sidecarContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.dockerdContainerResources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.ephemeralContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.containers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.volumes.items.properties.ephemeral.properties.volumeClaimTemplate.properties.spec.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.workVolumeClaimTemplate.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml
2023-01-27 09:23:28 +09:00
#runnersets
2023-03-01 07:19:47 +09:00
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnersets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.volumeClaimTemplates.items.properties.spec.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnersets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.workVolumeClaimTemplate.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnersets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.ephemeralContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnersets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.containers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnersets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.initContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnersets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.volumes.items.properties.ephemeral.properties.volumeClaimTemplate.properties.spec.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.summerwind.dev_runnersets.yaml
2023-01-27 09:23:28 +09:00
#autoscalingrunnersets
2023-03-01 07:19:47 +09:00
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.github.com_autoscalingrunnersets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.containers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.github.com_autoscalingrunnersets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.ephemeralContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.github.com_autoscalingrunnersets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.initContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.github.com_autoscalingrunnersets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.volumes.items.properties.ephemeral.properties.volumeClaimTemplate.properties.spec.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.github.com_autoscalingrunnersets.yaml
2023-01-27 09:23:28 +09:00
#ehemeralrunnersets
2023-03-01 07:19:47 +09:00
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.properties.spec.properties.initContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.github.com_ephemeralrunnersets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.github.com_ephemeralrunnersets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.ephemeralRunnerSpec.properties.spec.properties.initContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.github.com_ephemeralrunnersets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.ephemeralRunnerSpec.properties.spec.properties.containers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.github.com_ephemeralrunnersets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.ephemeralRunnerSpec.properties.spec.properties.ephemeralContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.github.com_ephemeralrunnersets.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.ephemeralRunnerSpec.properties.spec.properties.volumes.items.properties.ephemeral.properties.volumeClaimTemplate.properties.spec.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.github.com_ephemeralrunnersets.yaml
2023-01-27 09:23:28 +09:00
# ephemeralrunners
2023-03-01 07:19:47 +09:00
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.spec.properties.ephemeralContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.github.com_ephemeralrunners.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.spec.properties.containers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.github.com_ephemeralrunners.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.spec.properties.initContainers.items.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.github.com_ephemeralrunners.yaml
$( YQ) 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.spec.properties.volumes.items.properties.ephemeral.properties.volumeClaimTemplate.properties.spec.properties.resources.properties.claims.$(DELETE_KEY))' --inplace config/crd/bases/actions.github.com_ephemeralrunners.yaml
2020-01-28 15:03:23 +09:00
2020-11-14 20:31:21 +09:00
chart-crds :
cp config/crd/bases/*.yaml charts/actions-runner-controller/crds/
2023-03-01 13:16:03 +01:00
cp config/crd/bases/actions.github.com_autoscalingrunnersets.yaml charts/gha-runner-scale-set-controller/crds/
cp config/crd/bases/actions.github.com_autoscalinglisteners.yaml charts/gha-runner-scale-set-controller/crds/
cp config/crd/bases/actions.github.com_ephemeralrunnersets.yaml charts/gha-runner-scale-set-controller/crds/
cp config/crd/bases/actions.github.com_ephemeralrunners.yaml charts/gha-runner-scale-set-controller/crds/
2026-03-16 10:09:05 +01:00
cp config/crd/bases/actions.github.com_autoscalingrunnersets.yaml charts/gha-runner-scale-set-controller-experimental/crds/
cp config/crd/bases/actions.github.com_autoscalinglisteners.yaml charts/gha-runner-scale-set-controller-experimental/crds/
cp config/crd/bases/actions.github.com_ephemeralrunnersets.yaml charts/gha-runner-scale-set-controller-experimental/crds/
cp config/crd/bases/actions.github.com_ephemeralrunners.yaml charts/gha-runner-scale-set-controller-experimental/crds/
2023-01-17 12:06:20 -05:00
rm charts/actions-runner-controller/crds/actions.github.com_autoscalingrunnersets.yaml
rm charts/actions-runner-controller/crds/actions.github.com_autoscalinglisteners.yaml
rm charts/actions-runner-controller/crds/actions.github.com_ephemeralrunnersets.yaml
rm charts/actions-runner-controller/crds/actions.github.com_ephemeralrunners.yaml
2020-11-14 20:31:21 +09:00
2020-01-28 15:03:23 +09:00
# Run go fmt against code
fmt :
go fmt ./...
# Run go vet against code
vet :
go vet ./...
# Generate code
2020-10-20 02:48:28 +03:00
generate : controller -gen
2020-01-28 15:03:23 +09:00
$( CONTROLLER_GEN) object:headerFile= ./hack/boilerplate.go.txt paths = "./..."
2022-10-04 20:30:43 +09:00
# Run shellcheck on runner scripts
shellcheck : shellcheck -install
2025-04-17 12:19:15 +02:00
$( TOOLS_PATH) /shellcheck --shell bash --source-path runner runner/*.sh runner/update-status hack/*.sh
2022-10-04 20:30:43 +09:00
2020-10-05 11:26:46 +11:00
docker-buildx :
2022-04-27 08:21:02 +01:00
export DOCKER_CLI_EXPERIMENTAL = enabled ; \
export DOCKER_BUILDKIT = 1
2020-10-05 11:26:46 +11:00
@if ! docker buildx ls | grep -q container-builder; then \
docker buildx create --platform ${ PLATFORMS } --name container-builder --use; \
fi
docker buildx build --platform ${ PLATFORMS } \
2022-08-23 06:40:16 +02:00
--build-arg VERSION = ${ VERSION } \
2023-09-14 20:10:49 +02:00
--build-arg COMMIT_SHA = ${ COMMIT_SHA } \
2023-02-20 18:27:14 -05:00
-t " ${ DOCKER_IMAGE_NAME } : ${ VERSION } " \
2020-10-05 11:26:46 +11:00
-f Dockerfile \
. ${ PUSH_ARG }
2021-05-01 08:10:57 +02:00
# Push the docker image
docker-push :
2023-02-20 18:27:14 -05:00
docker push ${ DOCKER_IMAGE_NAME } :${ VERSION }
2021-05-03 13:03:17 +09:00
docker push ${ RUNNER_NAME } :${ RUNNER_TAG }
2021-05-01 08:10:57 +02:00
2020-02-03 10:28:50 +09:00
# Generate the release manifest file
2020-02-03 12:06:34 +09:00
release : manifests
2023-02-20 18:27:14 -05:00
cd config/manager && kustomize edit set image controller = ${ DOCKER_IMAGE_NAME } :${ VERSION }
2020-02-03 10:28:50 +09:00
mkdir -p release
kustomize build config/default > release/actions-runner-controller.yaml
2020-12-06 11:53:38 +09:00
.PHONY : release /clean
release/clean :
rm -rf release
2020-11-14 20:07:14 +09:00
.PHONY : acceptance
2021-05-02 16:31:07 +09:00
acceptance : release /clean acceptance /pull docker -build release
ACCEPTANCE_TEST_SECRET_TYPE = token make acceptance/run
ACCEPTANCE_TEST_SECRET_TYPE = app make acceptance/run
ACCEPTANCE_TEST_DEPLOYMENT_TOOL = helm ACCEPTANCE_TEST_SECRET_TYPE = token make acceptance/run
ACCEPTANCE_TEST_DEPLOYMENT_TOOL = helm ACCEPTANCE_TEST_SECRET_TYPE = app make acceptance/run
acceptance/run : acceptance /kind acceptance /load acceptance /setup acceptance /deploy acceptance /tests acceptance /teardown
2020-11-14 20:07:14 +09:00
2020-12-08 17:56:06 +09:00
acceptance/kind :
2021-06-22 17:10:09 +09:00
kind create cluster --name ${ CLUSTER } --config acceptance/kind.yaml
2021-05-02 16:31:07 +09:00
# Set TMPDIR to somewhere under $HOME when you use docker installed with Ubuntu snap
# Otherwise `load docker-image` fail while running `docker save`.
# See https://kind.sigs.k8s.io/docs/user/known-issues/#docker-installed-with-snap
acceptance/load :
2023-02-20 18:27:14 -05:00
kind load docker-image ${ DOCKER_IMAGE_NAME } :${ VERSION } --name ${ CLUSTER }
2021-12-08 22:53:50 +00:00
kind load docker-image quay.io/brancz/kube-rbac-proxy:$( KUBE_RBAC_PROXY_VERSION) --name ${ CLUSTER }
2021-06-22 17:10:09 +09:00
kind load docker-image ${ RUNNER_NAME } :${ RUNNER_TAG } --name ${ CLUSTER }
kind load docker-image docker:dind --name ${ CLUSTER }
kind load docker-image quay.io/jetstack/cert-manager-controller:$( CERT_MANAGER_VERSION) --name ${ CLUSTER }
kind load docker-image quay.io/jetstack/cert-manager-cainjector:$( CERT_MANAGER_VERSION) --name ${ CLUSTER }
kind load docker-image quay.io/jetstack/cert-manager-webhook:$( CERT_MANAGER_VERSION) --name ${ CLUSTER }
kubectl cluster-info --context ${ KUBECONTEXT }
2020-12-08 17:56:06 +09:00
2021-05-01 08:10:57 +02:00
# Pull the docker images for acceptance
2021-05-02 16:31:07 +09:00
acceptance/pull :
2021-12-08 22:53:50 +00:00
docker pull quay.io/brancz/kube-rbac-proxy:$( KUBE_RBAC_PROXY_VERSION)
2021-05-02 16:31:07 +09:00
docker pull docker:dind
2021-06-22 17:10:09 +09:00
docker pull quay.io/jetstack/cert-manager-controller:$( CERT_MANAGER_VERSION)
docker pull quay.io/jetstack/cert-manager-cainjector:$( CERT_MANAGER_VERSION)
docker pull quay.io/jetstack/cert-manager-webhook:$( CERT_MANAGER_VERSION)
2021-04-18 02:44:59 +02:00
2020-12-08 17:56:06 +09:00
acceptance/setup :
2021-06-22 17:10:09 +09:00
kubectl apply --validate= false -f https://github.com/jetstack/cert-manager/releases/download/$( CERT_MANAGER_VERSION) /cert-manager.yaml #kubectl create namespace actions-runner-system
2021-05-02 16:11:36 +09:00
kubectl -n cert-manager wait deploy/cert-manager-cainjector --for condition = available --timeout 90s
2020-11-14 20:07:14 +09:00
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
2020-12-08 17:56:06 +09:00
kubectl create namespace actions-runner-system || true
2020-11-14 20:07:14 +09:00
# Adhocly wait for some time until cert-manager's admission webhook gets ready
sleep 5
acceptance/teardown :
2021-06-22 17:10:09 +09:00
kind delete cluster --name ${ CLUSTER }
2020-11-14 20:07:14 +09:00
2021-05-02 16:31:07 +09:00
acceptance/deploy :
2023-02-20 18:27:14 -05:00
DOCKER_IMAGE_NAME = ${ DOCKER_IMAGE_NAME } DOCKER_USER = ${ DOCKER_USER } VERSION = ${ VERSION } RUNNER_NAME = ${ RUNNER_NAME } RUNNER_TAG = ${ RUNNER_TAG } TEST_REPO = ${ TEST_REPO } \
2021-05-11 13:30:34 +02:00
TEST_ORG = ${ TEST_ORG } TEST_ORG_REPO = ${ TEST_ORG_REPO } SYNC_PERIOD = ${ SYNC_PERIOD } \
2021-06-22 17:10:09 +09:00
USE_RUNNERSET = ${ USE_RUNNERSET } \
2021-08-11 09:52:04 +09:00
TEST_EPHEMERAL = ${ TEST_EPHEMERAL } \
2021-05-11 06:30:57 +00:00
acceptance/deploy.sh
2021-05-02 16:31:07 +09:00
acceptance/tests :
2020-11-14 20:07:14 +09:00
acceptance/checks.sh
2022-11-01 20:30:10 +09:00
acceptance/runner/startup :
cd test/startup/ && bash test.sh
2022-03-22 19:02:51 +00:00
2021-06-29 17:52:43 +09:00
# We use -count=1 instead of `go clean -testcache`
# See https://terratest.gruntwork.io/docs/testing-best-practices/avoid-test-caching/
2021-06-28 08:30:32 +09:00
.PHONY : e 2e
e2e :
2021-06-29 17:52:43 +09:00
go test -count= 1 -v -timeout 600s -run '^TestE2E$$' ./test/e2e
2021-06-28 08:30:32 +09:00
2025-11-19 16:25:58 +01:00
.PHONY : gha -e 2e
gha-e2e :
bash hack/e2e-test.sh
2020-02-03 10:28:50 +09:00
# Upload release file to GitHub.
github-release : release
ghr ${ VERSION } release/
2021-06-22 17:10:09 +09:00
# Find or download controller-gen
#
# Note that controller-gen newer than 0.4.1 is needed for https://github.com/kubernetes-sigs/controller-tools/issues/444#issuecomment-680168439
# Otherwise we get errors like the below:
# Error: failed to install CRD crds/actions.summerwind.dev_runnersets.yaml: CustomResourceDefinition.apiextensions.k8s.io "runnersets.actions.summerwind.dev" is invalid: [spec.validation.openAPIV3Schema.properties[spec].properties[template].properties[spec].properties[containers].items.properties[ports].items.properties[protocol].default: Required value: this property is in x-kubernetes-list-map-keys, so it must have a default or be a required property, spec.validation.openAPIV3Schema.properties[spec].properties[template].properties[spec].properties[initContainers].items.properties[ports].items.properties[protocol].default: Required value: this property is in x-kubernetes-list-map-keys, so it must have a default or be a required property]
#
2026-03-03 01:02:40 +01:00
# Note that controller-gen newer than 0.8.1 is needed due to https://github.com/kubernetes-sigs/controller-tools/issues/448
2021-06-22 17:10:09 +09:00
# Otherwise ObjectMeta embedded in Spec results in empty on the storage.
2020-01-28 15:03:23 +09:00
controller-gen :
i f e q ( , $( shell which controller -gen ) )
2020-10-20 02:48:28 +03:00
i f e q ( , $( wildcard $ ( GOBIN ) /controller -gen ) )
2020-01-28 15:03:23 +09:00
@ { \
s e t - e ; \
CONTROLLER_GEN_TMP_DIR = $$ ( mktemp -d) ; \
cd $$ CONTROLLER_GEN_TMP_DIR ; \
go mod init tmp ; \
2026-03-16 10:09:36 +01:00
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.20.1 ; \
2020-01-28 15:03:23 +09:00
rm -rf $$ CONTROLLER_GEN_TMP_DIR ; \
}
2020-10-20 02:48:28 +03:00
e n d i f
2020-01-28 15:03:23 +09:00
CONTROLLER_GEN = $( GOBIN) /controller-gen
e l s e
CONTROLLER_GEN = $( shell which controller-gen)
e n d i f
2020-10-15 02:39:46 +03:00
2021-09-23 18:03:35 +01:00
# find or download yq
# download yq if necessary
# Use always go-version to get consistent line wraps etc.
yq :
i f e q ( , $( wildcard $ ( GOBIN ) /yq ) )
e c h o "Downloading yq"
@ { \
s e t - e ; \
YQ_TMP_DIR = $$ ( mktemp -d) ; \
cd $$ YQ_TMP_DIR ; \
go mod init tmp ; \
2022-07-14 21:59:13 -04:00
go install github.com/mikefarah/yq/v4@v4.25.3 ; \
2021-09-23 18:03:35 +01:00
rm -rf $$ YQ_TMP_DIR ; \
}
e n d i f
YQ = $( GOBIN) /yq
2022-10-04 20:30:43 +09:00
# find or download shellcheck
# download shellcheck if necessary
shellcheck-install :
i f e q ( , $( wildcard $ ( TOOLS_PATH ) /shellcheck ) )
e c h o "Downloading shellcheck"
@ { \
s e t - e ; \
SHELLCHECK_TMP_DIR = $$ ( mktemp -d) ; \
cd $$ SHELLCHECK_TMP_DIR ; \
2022-11-03 05:57:04 -06:00
curl -LO https://github.com/koalaman/shellcheck/releases/download/v$( SHELLCHECK_VERSION) /shellcheck-v$( SHELLCHECK_VERSION) .$( OS_NAME) .x86_64.tar.xz ; \
tar Jxvf shellcheck-v$( SHELLCHECK_VERSION) .$( OS_NAME) .x86_64.tar.xz ; \
2022-10-04 20:30:43 +09:00
cd $( CURDIR) ; \
mkdir -p $( TOOLS_PATH) ; \
mv $$ SHELLCHECK_TMP_DIR/shellcheck-v$( SHELLCHECK_VERSION) /shellcheck $( TOOLS_PATH) / ; \
rm -rf $$ SHELLCHECK_TMP_DIR ; \
}
e n d i f
SHELLCHECK = $( TOOLS_PATH) /shellcheck
2026-02-24 13:36:01 +01:00
# find or download envtest
envtest :
i f e q ( , $( shell which setup -envtest ) )
i f e q ( , $( wildcard $ ( GOBIN ) /setup -envtest ) )
2021-03-31 09:23:16 +09:00
@ { \
2026-02-24 13:36:01 +01:00
s e t - e ; \
ENVTEST_TMP_DIR = $$ ( mktemp -d) ; \
cd $$ ENVTEST_TMP_DIR ; \
go mod init tmp ; \
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@$( ENVTEST_VERSION) ; \
rm -rf $$ ENVTEST_TMP_DIR ; \
2021-03-31 09:23:16 +09:00
}
e n d i f
2026-02-24 13:36:01 +01:00
ENVTEST = $( GOBIN) /setup-envtest
2021-05-02 16:11:36 +09:00
e l s e
2026-02-24 13:36:01 +01:00
ENVTEST = $( shell which setup-envtest)
2021-05-02 16:11:36 +09:00
e n d i f
2021-03-31 09:23:16 +09:00
2026-02-24 13:36:01 +01:00
.PHONY : setup -envtest
setup-envtest : envtest
@echo " Setting up envtest binaries for Kubernetes version $( ENVTEST_K8S_VERSION) ... "
@$( ENVTEST) use $( ENVTEST_K8S_VERSION) --bin-dir $( GOBIN) -p path || { \
echo " Error: Failed to set up envtest binaries for version $( ENVTEST_K8S_VERSION) . " ; \
exit 1; \
2021-03-31 09:23:16 +09:00
}