diff --git a/apis/actions.github.com/v1alpha1/autoscalingrunnerset_types.go b/apis/actions.github.com/v1alpha1/autoscalingrunnerset_types.go index 8cff49c8..24ccc8e3 100644 --- a/apis/actions.github.com/v1alpha1/autoscalingrunnerset_types.go +++ b/apis/actions.github.com/v1alpha1/autoscalingrunnerset_types.go @@ -66,6 +66,9 @@ type AutoscalingRunnerSetSpec struct { // +optional RunnerScaleSetName string `json:"runnerScaleSetName,omitempty"` + // +optional + RunnerScaleSetLabels []string `json:"runnerScaleSetLabels,omitempty"` + // +optional Proxy *ProxyConfig `json:"proxy,omitempty"` diff --git a/apis/actions.github.com/v1alpha1/zz_generated.deepcopy.go b/apis/actions.github.com/v1alpha1/zz_generated.deepcopy.go index 232d6f86..df2dabc8 100644 --- a/apis/actions.github.com/v1alpha1/zz_generated.deepcopy.go +++ b/apis/actions.github.com/v1alpha1/zz_generated.deepcopy.go @@ -227,6 +227,11 @@ func (in *AutoscalingRunnerSetList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AutoscalingRunnerSetSpec) DeepCopyInto(out *AutoscalingRunnerSetSpec) { *out = *in + if in.RunnerScaleSetLabels != nil { + in, out := &in.RunnerScaleSetLabels, &out.RunnerScaleSetLabels + *out = make([]string, len(*in)) + copy(*out, *in) + } if in.Proxy != nil { in, out := &in.Proxy, &out.Proxy *out = new(ProxyConfig) diff --git a/charts/gha-runner-scale-set-controller-experimental/crds/actions.github.com_autoscalingrunnersets.yaml b/charts/gha-runner-scale-set-controller-experimental/crds/actions.github.com_autoscalingrunnersets.yaml index a24d52bf..26f76125 100644 --- a/charts/gha-runner-scale-set-controller-experimental/crds/actions.github.com_autoscalingrunnersets.yaml +++ b/charts/gha-runner-scale-set-controller-experimental/crds/actions.github.com_autoscalingrunnersets.yaml @@ -8385,6 +8385,10 @@ spec: type: object runnerGroup: type: string + runnerScaleSetLabels: + items: + type: string + type: array runnerScaleSetName: type: string template: diff --git a/charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalingrunnersets.yaml b/charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalingrunnersets.yaml index a24d52bf..26f76125 100644 --- a/charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalingrunnersets.yaml +++ b/charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalingrunnersets.yaml @@ -8385,6 +8385,10 @@ spec: type: object runnerGroup: type: string + runnerScaleSetLabels: + items: + type: string + type: array runnerScaleSetName: type: string template: diff --git a/charts/gha-runner-scale-set-experimental/templates/autoscalingrunnserset.yaml b/charts/gha-runner-scale-set-experimental/templates/autoscalingrunnserset.yaml index 3eb031cd..4fbba467 100644 --- a/charts/gha-runner-scale-set-experimental/templates/autoscalingrunnserset.yaml +++ b/charts/gha-runner-scale-set-experimental/templates/autoscalingrunnserset.yaml @@ -83,6 +83,18 @@ spec: githubConfigSecret: {{ include "github-secret.name" . | quote }} runnerGroup: {{ .Values.scaleset.runnerGroup | quote }} runnerScaleSetName: {{ .Values.scaleset.name | quote }} + {{- if and .Values.scaleset.labels (kindIs "slice" .Values.scaleset.labels) }} + {{- range .Values.scaleset.labels }} + {{- if empty . }} + {{- fail "scaleset.labels contains an empty string, each label must be a non-empty string of less than 256 characters" }} + {{- end }} + {{- if ge (len .) 256 }} + {{- fail "scaleset.labels contains a label that is 256 characters or more, each label must be a non-empty string of less than 256 characters" }} + {{- end }} + {{- end }} + runnerScaleSetLabels: + {{- toYaml .Values.scaleset.labels | nindent 4 }} + {{- end }} {{- if .Values.githubServerTLS }} githubServerTLS: diff --git a/charts/gha-runner-scale-set-experimental/tests/autoscaling_runner_set_scale_set_labels_test.yaml b/charts/gha-runner-scale-set-experimental/tests/autoscaling_runner_set_scale_set_labels_test.yaml new file mode 100644 index 00000000..b8fb8d9e --- /dev/null +++ b/charts/gha-runner-scale-set-experimental/tests/autoscaling_runner_set_scale_set_labels_test.yaml @@ -0,0 +1,58 @@ +suite: "AutoscalingRunnerSet scale set labels" +templates: + - autoscalingrunnserset.yaml +tests: + - it: should apply scaleset labels slice as runnerScaleSetLabels + set: + scaleset.name: "test" + scaleset.labels: + - "linux" + - "x64" + auth.url: "https://github.com/org" + auth.githubToken: "gh_token12345" + controllerServiceAccount.name: "arc" + controllerServiceAccount.namespace: "arc-system" + release: + name: "test-name" + namespace: "test-namespace" + asserts: + - equal: + path: spec.runnerScaleSetLabels[0] + value: "linux" + - equal: + path: spec.runnerScaleSetLabels[1] + value: "x64" + + - it: should fail when a scaleset label is empty + set: + scaleset.name: "test" + scaleset.labels: + - "linux" + - "" + auth.url: "https://github.com/org" + auth.githubToken: "gh_token12345" + controllerServiceAccount.name: "arc" + controllerServiceAccount.namespace: "arc-system" + release: + name: "test-name" + namespace: "test-namespace" + asserts: + - failedTemplate: + errorMessage: "scaleset.labels contains an empty string, each label must be a non-empty string of less than 256 characters" + + - it: should fail when a scaleset label is 256 characters or more + set: + scaleset.name: "test" + scaleset.labels: + - "linux" + - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + auth.url: "https://github.com/org" + auth.githubToken: "gh_token12345" + controllerServiceAccount.name: "arc" + controllerServiceAccount.namespace: "arc-system" + release: + name: "test-name" + namespace: "test-namespace" + asserts: + - failedTemplate: + errorMessage: "scaleset.labels contains a label that is 256 characters or more, each label must be a non-empty string of less than 256 characters" \ No newline at end of file diff --git a/charts/gha-runner-scale-set-experimental/values.yaml b/charts/gha-runner-scale-set-experimental/values.yaml index 669230e2..4984251d 100644 --- a/charts/gha-runner-scale-set-experimental/values.yaml +++ b/charts/gha-runner-scale-set-experimental/values.yaml @@ -5,6 +5,10 @@ scaleset: # Name of the scaleset name: "" runnerGroup: "default" + # Labels are optional list of strings that will be applied to the scaleset + # allowing scaleset to be selected by the listener based on the labels specified in the workflow. + # https://docs.github.com/en/actions/how-tos/manage-runners/self-hosted-runners/apply-labels + labels: [] ## minRunners is the min number of idle runners. The target number of runners created will be ## calculated as a sum of minRunners and the number of jobs assigned to the scale set. # minRunners: 0 diff --git a/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml b/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml index a194e570..1a466d5b 100644 --- a/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml +++ b/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml @@ -75,6 +75,18 @@ spec: {{- with .Values.runnerScaleSetName }} runnerScaleSetName: {{ . }} {{- end }} + {{- if and .Values.scaleSetLabels (kindIs "slice" .Values.scaleSetLabels) }} + {{- range .Values.scaleSetLabels }} + {{- if empty . }} + {{- fail "scaleSetLabels contains an empty string, each label must be a non-empty string of less than 256 characters" }} + {{- end }} + {{- if ge (len .) 256 }} + {{- fail "scaleSetLabels contains a label that is 256 characters or more, each label must be a non-empty string of less than 256 characters" }} + {{- end }} + {{- end }} + runnerScaleSetLabels: + {{- toYaml .Values.scaleSetLabels | nindent 4 }} + {{- end }} {{- if .Values.githubServerTLS }} githubServerTLS: diff --git a/charts/gha-runner-scale-set/tests/template_test.go b/charts/gha-runner-scale-set/tests/template_test.go index 0e166f05..806b3c6f 100644 --- a/charts/gha-runner-scale-set/tests/template_test.go +++ b/charts/gha-runner-scale-set/tests/template_test.go @@ -474,6 +474,37 @@ func TestTemplateRenderedAutoScalingRunnerSet_RunnerScaleSetName(t *testing.T) { assert.Equal(t, "ghcr.io/actions/actions-runner:latest", ars.Spec.Template.Spec.Containers[0].Image) } +func TestTemplateRenderedAutoScalingRunnerSet_ScaleSetLabels(t *testing.T) { + t.Parallel() + + // Path to the helm chart we will test + helmChartPath, err := filepath.Abs("../../gha-runner-scale-set") + require.NoError(t, err) + + releaseName := "test-runners" + namespaceName := "test-" + strings.ToLower(random.UniqueId()) + + options := &helm.Options{ + Logger: logger.Discard, + SetValues: map[string]string{ + "githubConfigUrl": "https://github.com/actions", + "githubConfigSecret.github_token": "gh_token12345", + "scaleSetLabels[0]": "linux", + "scaleSetLabels[1]": "x64", + "controllerServiceAccount.name": "arc", + "controllerServiceAccount.namespace": "arc-system", + }, + KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName), + } + + output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/autoscalingrunnerset.yaml"}) + + var ars v1alpha1.AutoscalingRunnerSet + helm.UnmarshalK8SYaml(t, output, &ars) + + assert.Equal(t, []string{"linux", "x64"}, ars.Spec.RunnerScaleSetLabels) +} + func TestTemplateRenderedAutoScalingRunnerSet_ProvideMetadata(t *testing.T) { t.Parallel() diff --git a/charts/gha-runner-scale-set/values.yaml b/charts/gha-runner-scale-set/values.yaml index 0a78935b..4b4640cf 100644 --- a/charts/gha-runner-scale-set/values.yaml +++ b/charts/gha-runner-scale-set/values.yaml @@ -2,6 +2,8 @@ ## ex: https://github.com/myorg/myrepo or https://github.com/myorg or https://github.com/enterprises/myenterprise githubConfigUrl: "" +scaleSetLabels: [] + ## githubConfigSecret is the k8s secret information to use when authenticating via the GitHub API. ## You can choose to supply: ## A) a PAT token, diff --git a/config/crd/bases/actions.github.com_autoscalingrunnersets.yaml b/config/crd/bases/actions.github.com_autoscalingrunnersets.yaml index a24d52bf..26f76125 100644 --- a/config/crd/bases/actions.github.com_autoscalingrunnersets.yaml +++ b/config/crd/bases/actions.github.com_autoscalingrunnersets.yaml @@ -8385,6 +8385,10 @@ spec: type: object runnerGroup: type: string + runnerScaleSetLabels: + items: + type: string + type: array runnerScaleSetName: type: string template: diff --git a/controllers/actions.github.com/autoscalingrunnerset_controller.go b/controllers/actions.github.com/autoscalingrunnerset_controller.go index d32aa93b..3509de91 100644 --- a/controllers/actions.github.com/autoscalingrunnerset_controller.go +++ b/controllers/actions.github.com/autoscalingrunnerset_controller.go @@ -505,17 +505,35 @@ func (r *AutoscalingRunnerSetReconciler) createRunnerScaleSet(ctx context.Contex } if runnerScaleSet == nil { + labels := []scaleset.Label{ + { + Name: autoscalingRunnerSet.Spec.RunnerScaleSetName, + Type: "System", + }, + } + + if labelCount := len(autoscalingRunnerSet.Spec.RunnerScaleSetLabels); labelCount > 0 { + unique := make(map[string]bool, labelCount+1) + unique[autoscalingRunnerSet.Spec.RunnerScaleSetName] = true + + for _, label := range autoscalingRunnerSet.Spec.RunnerScaleSetLabels { + if _, exists := unique[label]; exists { + logger.Info("Duplicate label found. Skipping adding duplicate label to runner scale set", "label", label) + continue + } + labels = append(labels, scaleset.Label{ + Name: label, + Type: "System", + }) + unique[label] = true + } + } runnerScaleSet, err = actionsClient.CreateRunnerScaleSet( ctx, &scaleset.RunnerScaleSet{ Name: autoscalingRunnerSet.Spec.RunnerScaleSetName, RunnerGroupID: runnerGroupID, - Labels: []scaleset.Label{ - { - Name: autoscalingRunnerSet.Spec.RunnerScaleSetName, - Type: "System", - }, - }, + Labels: labels, RunnerSetting: scaleset.RunnerSetting{ DisableUpdate: true, }, diff --git a/test/actions.github.com/anonymous-proxy-setup-v2.test.sh b/test/actions.github.com/anonymous-proxy-setup-v2.test.sh index d8516ce4..696e1017 100755 --- a/test/actions.github.com/anonymous-proxy-setup-v2.test.sh +++ b/test/actions.github.com/anonymous-proxy-setup-v2.test.sh @@ -17,9 +17,6 @@ ARC_NAME="arc" ARC_NAMESPACE="arc-systems" function install_arc() { - echo "Creating namespace ${ARC_NAMESPACE}" - kubectl create namespace "${SCALE_SET_NAMESPACE}" - echo "Installing ARC" helm install "${ARC_NAME}" \ --namespace "${ARC_NAMESPACE}" \ diff --git a/test/actions.github.com/anonymous-proxy-setup.test.sh b/test/actions.github.com/anonymous-proxy-setup.test.sh index 5c5cce34..ff45710c 100755 --- a/test/actions.github.com/anonymous-proxy-setup.test.sh +++ b/test/actions.github.com/anonymous-proxy-setup.test.sh @@ -17,9 +17,6 @@ ARC_NAME="arc" ARC_NAMESPACE="arc-systems" function install_arc() { - echo "Creating namespace ${ARC_NAMESPACE}" - kubectl create namespace "${SCALE_SET_NAMESPACE}" - echo "Installing ARC" helm install "${ARC_NAME}" \ --namespace "${ARC_NAMESPACE}" \ diff --git a/test/actions.github.com/auth-proxy-setup-v2.test.sh b/test/actions.github.com/auth-proxy-setup-v2.test.sh index 2c8b0e7d..630c5954 100755 --- a/test/actions.github.com/auth-proxy-setup-v2.test.sh +++ b/test/actions.github.com/auth-proxy-setup-v2.test.sh @@ -22,9 +22,6 @@ function install_arc() { return 1 } - echo "Creating namespace ${ARC_NAMESPACE}" - kubectl create namespace "${SCALE_SET_NAMESPACE}" - echo "Installing ARC" helm install "${ARC_NAME}" \ --namespace "${ARC_NAMESPACE}" \ diff --git a/test/actions.github.com/auth-proxy-setup.test.sh b/test/actions.github.com/auth-proxy-setup.test.sh index f52a065d..179748de 100755 --- a/test/actions.github.com/auth-proxy-setup.test.sh +++ b/test/actions.github.com/auth-proxy-setup.test.sh @@ -22,9 +22,6 @@ function install_arc() { return 1 } - echo "Creating namespace ${ARC_NAMESPACE}" - kubectl create namespace "${SCALE_SET_NAMESPACE}" - echo "Installing ARC" helm install "${ARC_NAME}" \ --namespace "${ARC_NAMESPACE}" \ diff --git a/test/actions.github.com/custom-label-setup-v2.test.sh b/test/actions.github.com/custom-label-setup-v2.test.sh new file mode 100755 index 00000000..c6485520 --- /dev/null +++ b/test/actions.github.com/custom-label-setup-v2.test.sh @@ -0,0 +1,113 @@ +#!/bin/bash + +set -euo pipefail + +DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" + +ROOT_DIR="$(realpath "${DIR}/../..")" + +source "${DIR}/helper.sh" + +VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental/Chart.yaml")" || exit 1 +export VERSION + +SCALE_SET_NAME="custom-label-$(date +'%M%S')$(((RANDOM + 100) % 100 + 1))" +SCALE_SET_NAMESPACE="arc-runners" +SCALE_SET_LABEL="custom-$(date +'%s')${RANDOM}" +WORKFLOW_FILE="arc-custom-label.yaml" +ARC_NAME="arc" +ARC_NAMESPACE="arc-systems" + +function install_arc() { + echo "Installing ARC" + helm install "${ARC_NAME}" \ + --namespace "${ARC_NAMESPACE}" \ + --create-namespace \ + --set controller.manager.container.image="${IMAGE_NAME}:${IMAGE_TAG}" \ + "${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental" \ + --debug + + if ! NAME="${ARC_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_arc; then + NAMESPACE="${ARC_NAMESPACE}" log_arc + return 1 + fi +} + +function install_scale_set() { + echo "Installing scale set ${SCALE_SET_NAMESPACE}/${SCALE_SET_NAME} with label ${SCALE_SET_LABEL}" + helm install "${SCALE_SET_NAME}" \ + --namespace "${SCALE_SET_NAMESPACE}" \ + --create-namespace \ + --set controllerServiceAccount.name="${ARC_NAME}-gha-rs-controller" \ + --set controllerServiceAccount.namespace="${ARC_NAMESPACE}" \ + --set auth.url="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \ + --set auth.githubToken="${GITHUB_TOKEN}" \ + --set scaleset.labels[0]="${SCALE_SET_LABEL}" \ + "${ROOT_DIR}/charts/gha-runner-scale-set-experimental" \ + --version="${VERSION}" + + if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then + NAMESPACE="${ARC_NAMESPACE}" log_arc + return 1 + fi +} + +function verify_scale_set_label() { + local actual_label + actual_label="$(kubectl get autoscalingrunnersets.actions.github.com -n "${SCALE_SET_NAMESPACE}" -l app.kubernetes.io/instance="${SCALE_SET_NAME}" -o jsonpath='{.items[0].spec.runnerScaleSetLabels[0]}')" + if [[ "${actual_label}" != "${SCALE_SET_LABEL}" ]]; then + echo "Expected scale set label '${SCALE_SET_LABEL}', got '${actual_label}'" >&2 + return 1 + fi +} + +function run_custom_label_workflow() { + local repo="${TARGET_ORG}/${TARGET_REPO}" + local queue_time + queue_time="$(date -u +%FT%TZ)" + + gh workflow run -R "${repo}" "${WORKFLOW_FILE}" \ + -f scaleset-label="${SCALE_SET_LABEL}" || return 1 + + local count=0 + local run_id= + while true; do + if [[ "${count}" -ge 12 ]]; then + echo "Timeout waiting for custom label workflow to start" >&2 + return 1 + fi + + run_id="$(gh run list -R "${repo}" --workflow "${WORKFLOW_FILE}" --created ">${queue_time}" --json databaseId --jq '.[0].databaseId' | head -n1)" + if [[ -n "${run_id}" ]]; then + break + fi + + sleep 5 + count=$((count + 1)) + done + + gh run watch "${run_id}" -R "${repo}" --exit-status +} + +function main() { + local failed=() + + build_image + create_cluster + + install_arc + install_scale_set + verify_scale_set_label || failed+=("verify_scale_set_label") + + run_custom_label_workflow || failed+=("run_custom_label_workflow") + + INSTALLATION_NAME="${SCALE_SET_NAME}" NAMESPACE="${SCALE_SET_NAMESPACE}" cleanup_scale_set || failed+=("cleanup_scale_set") + + NAMESPACE="${ARC_NAMESPACE}" log_arc || failed+=("log_arc") + + delete_cluster + + print_results "${failed[@]}" +} + +main diff --git a/test/actions.github.com/custom-label-setup.test.sh b/test/actions.github.com/custom-label-setup.test.sh new file mode 100755 index 00000000..8295ec3e --- /dev/null +++ b/test/actions.github.com/custom-label-setup.test.sh @@ -0,0 +1,112 @@ +#!/bin/bash + +set -euo pipefail + +DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" + +ROOT_DIR="$(realpath "${DIR}/../..")" + +source "${DIR}/helper.sh" + +export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")" + +SCALE_SET_NAME="custom-label-$(date +'%M%S')$(((RANDOM + 100) % 100 + 1))" +SCALE_SET_NAMESPACE="arc-runners" +SCALE_SET_LABEL="custom-$(date +'%s')${RANDOM}" +WORKFLOW_FILE="arc-custom-label.yaml" +ARC_NAME="arc" +ARC_NAMESPACE="arc-systems" + +function install_arc() { + echo "Installing ARC" + helm install "${ARC_NAME}" \ + --namespace "${ARC_NAMESPACE}" \ + --create-namespace \ + --set image.repository="${IMAGE_NAME}" \ + --set image.tag="${IMAGE_TAG}" \ + "${ROOT_DIR}/charts/gha-runner-scale-set-controller" \ + --debug + + if ! NAME="${ARC_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_arc; then + NAMESPACE="${ARC_NAMESPACE}" log_arc + return 1 + fi +} + +function install_scale_set() { + echo "Installing scale set ${SCALE_SET_NAMESPACE}/${SCALE_SET_NAME} with label ${SCALE_SET_LABEL}" + helm install "${SCALE_SET_NAME}" \ + --namespace "${SCALE_SET_NAMESPACE}" \ + --create-namespace \ + --set githubConfigUrl="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \ + --set githubConfigSecret.github_token="${GITHUB_TOKEN}" \ + --set scaleSetLabels[0]="${SCALE_SET_LABEL}" \ + "${ROOT_DIR}/charts/gha-runner-scale-set" \ + --version="${VERSION}" \ + --debug + + if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then + NAMESPACE="${ARC_NAMESPACE}" log_arc + return 1 + fi +} + +function verify_scale_set_label() { + local actual_label + actual_label="$(kubectl get autoscalingrunnersets.actions.github.com -n "${SCALE_SET_NAMESPACE}" -l app.kubernetes.io/instance="${SCALE_SET_NAME}" -o jsonpath='{.items[0].spec.runnerScaleSetLabels[0]}')" + if [[ "${actual_label}" != "${SCALE_SET_LABEL}" ]]; then + echo "Expected scale set label '${SCALE_SET_LABEL}', got '${actual_label}'" >&2 + return 1 + fi +} + +function run_custom_label_workflow() { + local repo="${TARGET_ORG}/${TARGET_REPO}" + local queue_time + queue_time="$(date -u +%FT%TZ)" + + gh workflow run -R "${repo}" "${WORKFLOW_FILE}" \ + -f scaleset-label="${SCALE_SET_LABEL}" || return 1 + + local count=0 + local run_id= + while true; do + if [[ "${count}" -ge 12 ]]; then + echo "Timeout waiting for custom label workflow to start" >&2 + return 1 + fi + + run_id="$(gh run list -R "${repo}" --workflow "${WORKFLOW_FILE}" --created ">${queue_time}" --json databaseId --jq '.[0].databaseId' | head -n1)" + if [[ -n "${run_id}" ]]; then + break + fi + + sleep 5 + count=$((count + 1)) + done + + gh run watch "${run_id}" -R "${repo}" --exit-status +} + +function main() { + local failed=() + + build_image + create_cluster + + install_arc + install_scale_set + verify_scale_set_label || failed+=("verify_scale_set_label") + + run_custom_label_workflow || failed+=("run_custom_label_workflow") + + INSTALLATION_NAME="${SCALE_SET_NAME}" NAMESPACE="${SCALE_SET_NAMESPACE}" cleanup_scale_set || failed+=("cleanup_scale_set") + + NAMESPACE="${ARC_NAMESPACE}" log_arc || failed+=("log_arc") + + delete_cluster + + print_results "${failed[@]}" +} + +main diff --git a/test/actions.github.com/default-setup-v2.test.sh b/test/actions.github.com/default-setup-v2.test.sh index a07dfd93..921165fd 100755 --- a/test/actions.github.com/default-setup-v2.test.sh +++ b/test/actions.github.com/default-setup-v2.test.sh @@ -18,9 +18,6 @@ ARC_NAME="arc" ARC_NAMESPACE="arc-systems" function install_arc() { - echo "Creating namespace ${ARC_NAMESPACE}" - kubectl create namespace "${SCALE_SET_NAMESPACE}" - echo "Installing ARC" helm install "${ARC_NAME}" \ --namespace "${ARC_NAMESPACE}" \ diff --git a/test/actions.github.com/default-setup.test.sh b/test/actions.github.com/default-setup.test.sh index 7d8b24e3..9a92a260 100755 --- a/test/actions.github.com/default-setup.test.sh +++ b/test/actions.github.com/default-setup.test.sh @@ -17,9 +17,6 @@ ARC_NAME="arc" ARC_NAMESPACE="arc-systems" function install_arc() { - echo "Creating namespace ${ARC_NAMESPACE}" - kubectl create namespace "${SCALE_SET_NAMESPACE}" - echo "Installing ARC" helm install "${ARC_NAME}" \ --namespace "${ARC_NAMESPACE}" \ diff --git a/test/actions.github.com/dind-mode-setup-v2.test.sh b/test/actions.github.com/dind-mode-setup-v2.test.sh index 7b2b800f..0e1a9ff6 100755 --- a/test/actions.github.com/dind-mode-setup-v2.test.sh +++ b/test/actions.github.com/dind-mode-setup-v2.test.sh @@ -17,9 +17,6 @@ ARC_NAME="arc" ARC_NAMESPACE="arc-systems" function install_arc() { - echo "Creating namespace ${ARC_NAMESPACE}" - kubectl create namespace "${SCALE_SET_NAMESPACE}" - echo "Installing ARC" helm install "${ARC_NAME}" \ --namespace "${ARC_NAMESPACE}" \ diff --git a/test/actions.github.com/dind-mode-setup.test.sh b/test/actions.github.com/dind-mode-setup.test.sh index 19cf04a7..deb9b75d 100755 --- a/test/actions.github.com/dind-mode-setup.test.sh +++ b/test/actions.github.com/dind-mode-setup.test.sh @@ -17,9 +17,6 @@ ARC_NAME="arc" ARC_NAMESPACE="arc-systems" function install_arc() { - echo "Creating namespace ${ARC_NAMESPACE}" - kubectl create namespace "${SCALE_SET_NAMESPACE}" - echo "Installing ARC" helm install "${ARC_NAME}" \ --namespace "${ARC_NAMESPACE}" \ diff --git a/test/actions.github.com/kubernetes-mode-setup-v2.test.sh b/test/actions.github.com/kubernetes-mode-setup-v2.test.sh index 0fa2a3c7..7a388296 100755 --- a/test/actions.github.com/kubernetes-mode-setup-v2.test.sh +++ b/test/actions.github.com/kubernetes-mode-setup-v2.test.sh @@ -22,9 +22,6 @@ function install_arc() { return 1 } - echo "Creating namespace ${ARC_NAMESPACE}" - kubectl create namespace "${SCALE_SET_NAMESPACE}" - echo "Installing ARC" helm install "${ARC_NAME}" \ --namespace "${ARC_NAMESPACE}" \ diff --git a/test/actions.github.com/kubernetes-mode-setup.test.sh b/test/actions.github.com/kubernetes-mode-setup.test.sh index 42697156..aa9b52b3 100755 --- a/test/actions.github.com/kubernetes-mode-setup.test.sh +++ b/test/actions.github.com/kubernetes-mode-setup.test.sh @@ -22,9 +22,6 @@ function install_arc() { return 1 } - echo "Creating namespace ${ARC_NAMESPACE}" - kubectl create namespace "${SCALE_SET_NAMESPACE}" - echo "Installing ARC" helm install "${ARC_NAME}" \ --namespace "${ARC_NAMESPACE}" \ diff --git a/test/actions.github.com/single-namespace-setup-v2.test.sh b/test/actions.github.com/single-namespace-setup-v2.test.sh index bdd8aa65..382953bd 100755 --- a/test/actions.github.com/single-namespace-setup-v2.test.sh +++ b/test/actions.github.com/single-namespace-setup-v2.test.sh @@ -17,9 +17,6 @@ ARC_NAME="arc" ARC_NAMESPACE="${SCALE_SET_NAMESPACE}" function install_arc() { - echo "Creating namespace ${ARC_NAMESPACE}" - kubectl create namespace "${SCALE_SET_NAMESPACE}" - echo "Installing ARC" helm install "${ARC_NAME}" \ --namespace "${ARC_NAMESPACE}" \ diff --git a/test/actions.github.com/single-namespace-setup.test.sh b/test/actions.github.com/single-namespace-setup.test.sh index 0a28f525..836dfe74 100755 --- a/test/actions.github.com/single-namespace-setup.test.sh +++ b/test/actions.github.com/single-namespace-setup.test.sh @@ -17,9 +17,6 @@ ARC_NAME="arc" ARC_NAMESPACE="${SCALE_SET_NAMESPACE}" function install_arc() { - echo "Creating namespace ${ARC_NAMESPACE}" - kubectl create namespace "${SCALE_SET_NAMESPACE}" - echo "Installing ARC" helm install "${ARC_NAME}" \ --namespace "${ARC_NAMESPACE}" \ diff --git a/test/actions.github.com/update-strategy-v2.test.sh b/test/actions.github.com/update-strategy-v2.test.sh index 2ac2f2ad..8d27a645 100755 --- a/test/actions.github.com/update-strategy-v2.test.sh +++ b/test/actions.github.com/update-strategy-v2.test.sh @@ -21,7 +21,6 @@ ARC_NAMESPACE="arc-systems" function install_arc() { echo "Installing ARC" - helm install "${ARC_NAME}" \ --namespace "${ARC_NAMESPACE}" \ --create-namespace \ diff --git a/test/actions.github.com/update-strategy.test.sh b/test/actions.github.com/update-strategy.test.sh index 2e966a67..7ddff6e9 100755 --- a/test/actions.github.com/update-strategy.test.sh +++ b/test/actions.github.com/update-strategy.test.sh @@ -21,7 +21,6 @@ ARC_NAMESPACE="arc-systems" function install_arc() { echo "Installing ARC" - helm install "${ARC_NAME}" \ --namespace "${ARC_NAMESPACE}" \ --create-namespace \