From e29c152be00c887b788e8b1a1f7ee33088ac534d Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Thu, 7 Dec 2023 14:47:45 +0100 Subject: [PATCH 01/10] Initial e2e setup with default test --- .github/workflows/gha-e2e-tests.yaml | 24 +++ Makefile | 4 + hack/e2e-test.sh | 92 ++++++++++ test/actions.github.com/default-setup.test.sh | 75 ++++++++ test/actions.github.com/envrc.example | 3 + test/actions.github.com/helper.sh | 165 ++++++++++++++++++ 6 files changed, 363 insertions(+) create mode 100755 hack/e2e-test.sh create mode 100755 test/actions.github.com/default-setup.test.sh create mode 100644 test/actions.github.com/envrc.example create mode 100644 test/actions.github.com/helper.sh diff --git a/.github/workflows/gha-e2e-tests.yaml b/.github/workflows/gha-e2e-tests.yaml index ebc0f3ed..43c42c67 100644 --- a/.github/workflows/gha-e2e-tests.yaml +++ b/.github/workflows/gha-e2e-tests.yaml @@ -26,6 +26,30 @@ concurrency: cancel-in-progress: true jobs: + default-setup2: + runs-on: ubuntu-latest + timeout-minutes: 20 + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.id == github.repository_id + env: + TARGET_ORG: ${{ env.TARGET_ORG }} + TARGET_REPO: ${{ env.TARGET_REPO }} + steps: + - uses: actions/checkout@v3 + with: + ref: ${{github.head_ref}} + + - name: Get configure token + id: config-token + uses: peter-murray/workflow-application-token-action@8e1ba3bf1619726336414f1014e37f17fbadf1db + with: + application_id: ${{ secrets.E2E_TESTS_ACCESS_APP_ID }} + application_private_key: ${{ secrets.E2E_TESTS_ACCESS_PK }} + organization: ${{ env.TARGET_ORG }} + + - name: Run default setup test + run: hack/e2e-test.sh default-setup + shell: bash + default-setup: runs-on: ubuntu-latest timeout-minutes: 20 diff --git a/Makefile b/Makefile index a0a1a539..ecf4cb29 100644 --- a/Makefile +++ b/Makefile @@ -297,6 +297,10 @@ acceptance/runner/startup: e2e: go test -count=1 -v -timeout 600s -run '^TestE2E$$' ./test/e2e +.PHONY: gha-e2e +gha-e2e: + bash hack/e2e-test.sh + # Upload release file to GitHub. github-release: release ghr ${VERSION} release/ diff --git a/hack/e2e-test.sh b/hack/e2e-test.sh new file mode 100755 index 00000000..d532662e --- /dev/null +++ b/hack/e2e-test.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +DIR="$(dirname "${BASH_SOURCE[0]}")" + +DIR="$(realpath "${DIR}")" + +TEST_DIR="$(realpath "${DIR}/../test/actions.github.com")" + +export PLATFORMS="linux/amd64" + +TARGETS=() + +function set_targets() { + local cases="$(find "${TEST_DIR}" -name '*.test.sh' | sed "s#^${TEST_DIR}/##g" )" + + mapfile -t TARGETS < <(echo "${cases}") + + echo $TARGETS +} + +function env_test() { + if [[ -z "${GITHUB_TOKEN}" ]]; then + echo "Error: GITHUB_TOKEN is not set" + exit 1 + fi + + if [[ -z "${TARGET_ORG}" ]]; then + echo "Error: TARGET_ORG is not set" + exit 1 + fi + + if [[ -z "${TARGET_REPO}" ]]; then + echo "Error: TARGET_REPO is not set" + exit 1 + fi +} + +function usage() { + echo "Usage: $0 [test_name]" + echo " test_name: the name of the test to run" + echo " if not specified, all tests will be run" + echo " test_name should be the name of the test file without the .test.sh suffix" + echo "" + exit 1 +} + +function main() { + local failed=() + + env_test + + if [[ -z "${1}" ]]; then + echo "Running all tests" + set_targets + elif [[ -f "${TEST_DIR}/${1}.test.sh" ]]; then + echo "Running test ${1}" + TARGETS=("${1}.test.sh") + else + usage + fi + + for target in "${TARGETS[@]}"; do + echo "============================================================" + test="${TEST_DIR}/${target}" + if [[ ! -x "${test}" ]]; then + echo "Error: test ${test} is not executable or not found" + failed+=("${test}") + continue + fi + + echo "Running test ${target}" + if ! "${test}"; then + failed+=("${target}") + echo "---------------------------------" + echo "FAILED: ${target}" + else + echo "---------------------------------" + echo "PASSED: ${target}" + fi + echo "============================================================" + done + + if [[ "${#failed[@]}" -gt 0 ]]; then + echo "Failed tests:" + for fail in "${failed[@]}"; do + echo " ${fail}" + done + exit 1 + fi +} + +main $@ diff --git a/test/actions.github.com/default-setup.test.sh b/test/actions.github.com/default-setup.test.sh new file mode 100755 index 00000000..e09a6238 --- /dev/null +++ b/test/actions.github.com/default-setup.test.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +set -e + +DIR="$(dirname "${BASH_SOURCE[0]}")" + +DIR="$(realpath "${DIR}")" + +ROOT_DIR="$(realpath "${DIR}/../..")" + +source "${DIR}/helper.sh" + +SCALE_SET_NAME="default-$(date +'%M%S')$(((${RANDOM} + 100) % 100 + 1))" +SCALE_SET_NAMESPACE="arc-runners" +WORKFLOW_FILE="arc-test-workflow.yaml" +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}" \ + --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}" + 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}" \ + ${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 main() { + local failed=() + + build_image + create_cluster + + install_arc + install_scale_set + + WORKFLOW_FILE="${WORKFLOW_FILE}" SCALE_SET_NAME="${SCALE_SET_NAME}" run_workflow || failed+=("run_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/envrc.example b/test/actions.github.com/envrc.example new file mode 100644 index 00000000..5db64c18 --- /dev/null +++ b/test/actions.github.com/envrc.example @@ -0,0 +1,3 @@ +export TARGET_ORG="org" +export TARGET_REPO="repo" +export GITHUB_TOKEN="token" diff --git a/test/actions.github.com/helper.sh b/test/actions.github.com/helper.sh new file mode 100644 index 00000000..af1dc6ae --- /dev/null +++ b/test/actions.github.com/helper.sh @@ -0,0 +1,165 @@ +#!/bin/bash + +DIR="$(dirname "${BASH_SOURCE[0]}")" + +DIR="$(realpath "${DIR}")" + +ROOT_DIR="$(realpath "${DIR}/../..")" + +export TARGET_ORG="${TARGET_ORG:-actions-runner-controller}" +export TARGET_REPO="${TARGET_REPO:-arc_e2e_test_dummy}" +export IMAGE_NAME="${IMAGE_NAME:-arc-test-image}" +export VERSION="${VERSION:-$(yq .version < "${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")}" +export IMAGE_VERSION="${IMAGE_VERSION:-${VERSION}}" + +function build_image() { + echo "Building ARC image ${IMAGE_NAME}:${IMAGE_VERSION}" + + cd ${ROOT_DIR} + + export DOCKER_CLI_EXPERIMENTAL=enabled + export DOCKER_BUILDKIT=1 + docker buildx build --platform ${PLATFORMS} \ + --build-arg RUNNER_VERSION=${RUNNER_VERSION} \ + --build-arg DOCKER_VERSION=${DOCKER_VERSION} \ + --build-arg VERSION=${VERSION} \ + --build-arg COMMIT_SHA=${COMMIT_SHA} \ + -t "${IMAGE_NAME}:${IMAGE_VERSION}" \ + -f Dockerfile \ + . --load + + echo "Created image ${IMAGE_NAME}:${IMAGE_VERSION}" + cd - +} + +function create_cluster() { + echo "Deleting minikube cluster if exists" + minikube delete || true + + echo "Creating minikube cluster" + minikube start + + echo "Loading image into minikube cluster" + minikube image load "${IMAGE_NAME}:${IMAGE_VERSION}" +} + +function delete_cluster() { + echo "Deleting minikube cluster" + minikube delete +} + +function log_arc() { + echo "ARC logs" + kubectl logs -n "${NAMESPACE}" -l app.kubernetes.io/name=gha-rs-controller +} + +function wait_for_arc() { + echo "Waiting for ARC to be ready" + local count=0; + while true; do + POD_NAME=$(kubectl get pods -n ${NAMESPACE} -l app.kubernetes.io/name=gha-rs-controller -o name) + if [ -n "$POD_NAME" ]; then + echo "Pod found: $POD_NAME" + break + fi + if [ "$count" -ge 60 ]; then + echo "Timeout waiting for controller pod with label app.kubernetes.io/name=gha-rs-controller" + return 1 + fi + sleep 1 + count=$((count+1)) + done + + kubectl wait --timeout=30s --for=condition=ready pod -n "${NAMESPACE}" -l app.kubernetes.io/name=gha-rs-controller + kubectl get pod -n "${NAMESPACE}" + kubectl describe deployment "${NAME}" -n "${NAMESPACE}" +} + +function wait_for_scale_set() { + local count=0 + while true; do + POD_NAME=$(kubectl get pods -n ${NAMESPACE} -l actions.github.com/scale-set-name=${NAME} -o name) + if [ -n "$POD_NAME" ]; then + echo "Pod found: ${POD_NAME}" + break + fi + + if [ "$count" -ge 60 ]; then + echo "Timeout waiting for listener pod with label actions.github.com/scale-set-name=${NAME}" + return 1 + fi + + sleep 1 + count=$((count+1)) + done + kubectl wait --timeout=30s --for=condition=ready pod -n ${NAMESPACE} -l actions.github.com/scale-set-name=${NAME} + kubectl get pod -n ${NAMESPACE} +} + +function cleanup_scale_set() { + helm uninstall "${INSTALLATION_NAME}" --namespace "${NAMESPACE}" --debug + + kubectl wait --timeout=40s --for=delete autoscalingrunnersets -n "${NAMESPACE}" -l app.kubernetes.io/instance="${INSTALLATION_NAME}" +} + +function install_openebs() { + echo "Install openebs/dynamic-localpv-provisioner" + helm repo add openebs https://openebs.github.io/charts + helm repo update + helm install openebs openebs/openebs --namespace openebs --create-namespace +} + +function print_results() { + local failed=("$@") + + if [[ "${#failed[@]}" -ne 0 ]]; then + echo "----------------------------------" + echo "The following tests failed:" + for test in "${failed[@]}"; do + echo " - ${test}" + done + return 1 + else + echo "----------------------------------" + echo "All tests passed!" + fi +} + +function run_workflow() { + echo "Checking if the workflow file exists" + gh workflow view -R "${TARGET_ORG}/${TARGET_REPO}" "${WORKFLOW_FILE}" &> /dev/null || return 1 + + local queue_time="$(date -u +%FT%TZ)" + + echo "Running workflow ${workflow_file}" + gh workflow run -R "${TARGET_ORG}/${TARGET_REPO}" "${WORKFLOW_FILE}" --ref main -f arc_name="${SCALE_SET_NAME}" || return 1 + + echo "Waiting for run to start" + local count=0 + local run_id= + while true; do + if [[ "${count}" -ge 12 ]]; then + echo "Timeout waiting for run to start" + return 1 + fi + run_id=$(gh run list -R "${TARGET_ORG}/${TARGET_REPO}" --workflow "${WORKFLOW_FILE}" --created ">${queue_time}" --json "name,databaseId" --jq ".[] | select(.name | contains(\"${SCALE_SET_NAME}\")) | .databaseId") + echo "Run ID: ${run_id}" + if [ -n "$run_id" ]; then + echo "Run found!" + break + fi + + echo "Run not found yet, waiting 5 seconds" + sleep 5 + count=$((count+1)) + done + + echo "Waiting for run to complete" + local code=$(gh run watch "${run_id}" -R "${TARGET_ORG}/${TARGET_REPO}" --exit-status &> /dev/null) + if [[ "${code}" -ne 0 ]]; then + echo "Run failed with exit code ${code}" + return 1 + fi + + echo "Run completed successfully" +} From 8b2cfba0852a2f8b6cbd74676befd00adb67f4f8 Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Fri, 21 Jun 2024 13:06:33 +0200 Subject: [PATCH 02/10] Apply suggestions from code review Co-authored-by: Bassem Dghaidi <568794+Link-@users.noreply.github.com> --- .github/workflows/gha-e2e-tests.yaml | 2 +- test/actions.github.com/default-setup.test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gha-e2e-tests.yaml b/.github/workflows/gha-e2e-tests.yaml index 43c42c67..db457165 100644 --- a/.github/workflows/gha-e2e-tests.yaml +++ b/.github/workflows/gha-e2e-tests.yaml @@ -26,7 +26,7 @@ concurrency: cancel-in-progress: true jobs: - default-setup2: + default-setup-v2: runs-on: ubuntu-latest timeout-minutes: 20 if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.id == github.repository_id diff --git a/test/actions.github.com/default-setup.test.sh b/test/actions.github.com/default-setup.test.sh index e09a6238..52ce6bc7 100755 --- a/test/actions.github.com/default-setup.test.sh +++ b/test/actions.github.com/default-setup.test.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -euo pipefail DIR="$(dirname "${BASH_SOURCE[0]}")" From 4b9af378084fd6e4f73cfb945ffdec0314d65a06 Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Thu, 3 Apr 2025 14:58:07 +0200 Subject: [PATCH 03/10] migrating rest of the e2e tests --- test/actions.github.com/default-setup.test.sh | 4 +- .../dind-mode-setup.test.sh | 74 +++++++++++++++++++ .../single-namespace-setup.test.sh | 74 +++++++++++++++++++ 3 files changed, 149 insertions(+), 3 deletions(-) create mode 100755 test/actions.github.com/dind-mode-setup.test.sh create mode 100755 test/actions.github.com/single-namespace-setup.test.sh diff --git a/test/actions.github.com/default-setup.test.sh b/test/actions.github.com/default-setup.test.sh index 52ce6bc7..6eaeecaf 100755 --- a/test/actions.github.com/default-setup.test.sh +++ b/test/actions.github.com/default-setup.test.sh @@ -2,9 +2,7 @@ set -euo pipefail -DIR="$(dirname "${BASH_SOURCE[0]}")" - -DIR="$(realpath "${DIR}")" +DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" ROOT_DIR="$(realpath "${DIR}/../..")" diff --git a/test/actions.github.com/dind-mode-setup.test.sh b/test/actions.github.com/dind-mode-setup.test.sh new file mode 100755 index 00000000..dd14ff1b --- /dev/null +++ b/test/actions.github.com/dind-mode-setup.test.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -euo pipefail + +DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" + +ROOT_DIR="$(realpath "${DIR}/../..")" + +source "${DIR}/helper.sh" + +SCALE_SET_NAME="default-$(date +'%M%S')$(((${RANDOM} + 100) % 100 + 1))" +SCALE_SET_NAMESPACE="arc-runners" +WORKFLOW_FILE="arc-test-dind-workflow.yaml" +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}" \ + --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}" + 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 containerMode.type="dind" \ + ${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 main() { + local failed=() + + build_image + create_cluster + + install_arc + install_scale_set + + WORKFLOW_FILE="${WORKFLOW_FILE}" SCALE_SET_NAME="${SCALE_SET_NAME}" run_workflow || failed+=("run_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/single-namespace-setup.test.sh b/test/actions.github.com/single-namespace-setup.test.sh new file mode 100755 index 00000000..2e70375c --- /dev/null +++ b/test/actions.github.com/single-namespace-setup.test.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -euo pipefail + +DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" + +ROOT_DIR="$(realpath "${DIR}/../..")" + +source "${DIR}/helper.sh" + +SCALE_SET_NAME="default-$(date +'%M%S')$(((${RANDOM} + 100) % 100 + 1))" +SCALE_SET_NAMESPACE="arc-runners" +WORKFLOW_FILE="arc-test-workflow.yaml" +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}" \ + --create-namespace \ + --set image.repository="${IMAGE_NAME}" \ + --set image.tag="${IMAGE_TAG}" \ + --set flags.watchSingleNamespace="${ARC_NAMESPACE}" + ${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}" + 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}" \ + ${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 main() { + local failed=() + + build_image + create_cluster + + install_arc + install_scale_set + + WORKFLOW_FILE="${WORKFLOW_FILE}" SCALE_SET_NAME="${SCALE_SET_NAME}" run_workflow || failed+=("run_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 From 9f9e9b4c78be918805519ca10d1888c17465e17a Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Fri, 4 Apr 2025 20:20:06 +0200 Subject: [PATCH 04/10] continuing extracting tests --- .../anonymous-proxy-setup.test.sh | 83 ++++++++++++++++ .../auth-proxy-setup.test.sh | 99 +++++++++++++++++++ .../dind-mode-setup.test.sh | 2 +- test/actions.github.com/helper.sh | 24 ++--- .../kubernetes-mode-setup.test.sh | 82 +++++++++++++++ 5 files changed, 277 insertions(+), 13 deletions(-) create mode 100755 test/actions.github.com/anonymous-proxy-setup.test.sh create mode 100755 test/actions.github.com/auth-proxy-setup.test.sh create mode 100755 test/actions.github.com/kubernetes-mode-setup.test.sh diff --git a/test/actions.github.com/anonymous-proxy-setup.test.sh b/test/actions.github.com/anonymous-proxy-setup.test.sh new file mode 100755 index 00000000..9bec9d03 --- /dev/null +++ b/test/actions.github.com/anonymous-proxy-setup.test.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +set -euo pipefail + +DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" + +ROOT_DIR="$(realpath "${DIR}/../..")" + +source "${DIR}/helper.sh" + +SCALE_SET_NAME="default-$(date +'%M%S')$(((${RANDOM} + 100) % 100 + 1))" +SCALE_SET_NAMESPACE="arc-runners" +WORKFLOW_FILE="arc-test-workflow.yaml" +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}" \ + --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 start_squid_proxy() { + echo "Starting squid-proxy" + docker run -d \ + --name squid \ + --publish 3128:3128 \ + huangtingluo/squid-proxy:latest +} + +function install_scale_set() { + echo "Installing scale set ${SCALE_SET_NAMESPACE}/${SCALE_SET_NAME}" + 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 proxy.https.url="http://host.minikube.internal:3128" \ + --set "proxy.noProxy[0]=10.96.0.1:443" \ + "${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 main() { + local failed=() + + build_image + create_cluster + + install_arc + install_scale_set + + WORKFLOW_FILE="${WORKFLOW_FILE}" SCALE_SET_NAME="${SCALE_SET_NAME}" run_workflow || failed+=("run_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/auth-proxy-setup.test.sh b/test/actions.github.com/auth-proxy-setup.test.sh new file mode 100755 index 00000000..243160af --- /dev/null +++ b/test/actions.github.com/auth-proxy-setup.test.sh @@ -0,0 +1,99 @@ +#!/bin/bash + +set -euo pipefail + +DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" + +ROOT_DIR="$(realpath "${DIR}/../..")" + +source "${DIR}/helper.sh" + +SCALE_SET_NAME="default-$(date +'%M%S')$((($RANDOM + 100) % 100 + 1))" +SCALE_SET_NAMESPACE="arc-runners" +WORKFLOW_FILE="arc-test-workflow.yaml" +ARC_NAME="arc" +ARC_NAMESPACE="arc-systems" + +function install_arc() { + echo "Install openebs/dynamic-localpv-provisioner" + helm repo add openebs https://openebs.github.io/charts + helm repo update + helm install openebs openebs/openebs -n openebs --create-namespace + + echo "Creating namespace ${ARC_NAMESPACE}" + kubectl create namespace "${SCALE_SET_NAMESPACE}" + + 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 start_squid_proxy() { + echo "Starting squid-proxy" + docker run -d \ + --name squid \ + --publish 3128:3128 \ + huangtingluo/squid-proxy:latest + + echo "Creating scale set namespace" + kubectl create namespace "${SCALE_SET_NAMESPACE}" + + echo "Creating squid proxy secret" + kubectl create secret generic proxy-auth \ + --namespace=arc-runners \ + --from-literal=username=github \ + --from-literal=password='actions' +} + +function install_scale_set() { + echo "Installing scale set ${SCALE_SET_NAMESPACE}/${SCALE_SET_NAME}" + 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 proxy.https.url="http://host.minikube.internal:3128" \ + --set proxy.https.credentialSecretRef="proxy-auth" \ + --set "proxy.noProxy[0]=10.96.0.1:443" \ + "${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 main() { + local failed=() + + build_image + create_cluster + + install_arc + start_squid_proxy + install_scale_set + + WORKFLOW_FILE="${WORKFLOW_FILE}" SCALE_SET_NAME="${SCALE_SET_NAME}" run_workflow || failed+=("run_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/dind-mode-setup.test.sh b/test/actions.github.com/dind-mode-setup.test.sh index dd14ff1b..a958f95d 100755 --- a/test/actions.github.com/dind-mode-setup.test.sh +++ b/test/actions.github.com/dind-mode-setup.test.sh @@ -24,7 +24,7 @@ function install_arc() { --create-namespace \ --set image.repository="${IMAGE_NAME}" \ --set image.tag="${IMAGE_TAG}" \ - ${ROOT_DIR}/charts/gha-runner-scale-set-controller \ + "${ROOT_DIR}/charts/gha-runner-scale-set-controller" \ --debug if ! NAME="${ARC_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_arc; then diff --git a/test/actions.github.com/helper.sh b/test/actions.github.com/helper.sh index af1dc6ae..2439587c 100644 --- a/test/actions.github.com/helper.sh +++ b/test/actions.github.com/helper.sh @@ -15,21 +15,21 @@ export IMAGE_VERSION="${IMAGE_VERSION:-${VERSION}}" function build_image() { echo "Building ARC image ${IMAGE_NAME}:${IMAGE_VERSION}" - cd ${ROOT_DIR} + cd "${ROOT_DIR}" || exit 1 export DOCKER_CLI_EXPERIMENTAL=enabled export DOCKER_BUILDKIT=1 - docker buildx build --platform ${PLATFORMS} \ - --build-arg RUNNER_VERSION=${RUNNER_VERSION} \ - --build-arg DOCKER_VERSION=${DOCKER_VERSION} \ - --build-arg VERSION=${VERSION} \ - --build-arg COMMIT_SHA=${COMMIT_SHA} \ + docker buildx build --platform "${PLATFORMS}" \ + --build-arg RUNNER_VERSION="${RUNNER_VERSION}" \ + --build-arg DOCKER_VERSION="${DOCKER_VERSION}" \ + --build-arg VERSION="${VERSION}" \ + --build-arg COMMIT_SHA="${COMMIT_SHA}" \ -t "${IMAGE_NAME}:${IMAGE_VERSION}" \ -f Dockerfile \ . --load echo "Created image ${IMAGE_NAME}:${IMAGE_VERSION}" - cd - + cd - || exit 1 } function create_cluster() { @@ -57,7 +57,7 @@ function wait_for_arc() { echo "Waiting for ARC to be ready" local count=0; while true; do - POD_NAME=$(kubectl get pods -n ${NAMESPACE} -l app.kubernetes.io/name=gha-rs-controller -o name) + POD_NAME=$(kubectl get pods -n "${NAMESPACE}" -l app.kubernetes.io/name=gha-rs-controller -o name) if [ -n "$POD_NAME" ]; then echo "Pod found: $POD_NAME" break @@ -78,7 +78,7 @@ function wait_for_arc() { function wait_for_scale_set() { local count=0 while true; do - POD_NAME=$(kubectl get pods -n ${NAMESPACE} -l actions.github.com/scale-set-name=${NAME} -o name) + POD_NAME=$(kubectl get pods -n "${NAMESPACE}" -l "actions.github.com/scale-set-name=${NAME}" -o name) if [ -n "$POD_NAME" ]; then echo "Pod found: ${POD_NAME}" break @@ -92,8 +92,8 @@ function wait_for_scale_set() { sleep 1 count=$((count+1)) done - kubectl wait --timeout=30s --for=condition=ready pod -n ${NAMESPACE} -l actions.github.com/scale-set-name=${NAME} - kubectl get pod -n ${NAMESPACE} + kubectl wait --timeout=30s --for=condition=ready pod -n "${NAMESPACE}" -l "actions.github.com/scale-set-name=${NAME}" + kubectl get pod -n "${NAMESPACE}" } function cleanup_scale_set() { @@ -131,7 +131,7 @@ function run_workflow() { local queue_time="$(date -u +%FT%TZ)" - echo "Running workflow ${workflow_file}" + echo "Running workflow ${WORKFLOW_FILE}" gh workflow run -R "${TARGET_ORG}/${TARGET_REPO}" "${WORKFLOW_FILE}" --ref main -f arc_name="${SCALE_SET_NAME}" || return 1 echo "Waiting for run to start" diff --git a/test/actions.github.com/kubernetes-mode-setup.test.sh b/test/actions.github.com/kubernetes-mode-setup.test.sh new file mode 100755 index 00000000..7668c174 --- /dev/null +++ b/test/actions.github.com/kubernetes-mode-setup.test.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +set -euo pipefail + +DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" + +ROOT_DIR="$(realpath "${DIR}/../..")" + +source "${DIR}/helper.sh" + +SCALE_SET_NAME="default-$(date +'%M%S')$((($RANDOM + 100) % 100 + 1))" +SCALE_SET_NAMESPACE="arc-runners" +WORKFLOW_FILE="arc-test-kubernetes-workflow.yaml" +ARC_NAME="arc" +ARC_NAMESPACE="arc-systems" + +function install_arc() { + echo "Install openebs/dynamic-localpv-provisioner" + helm repo add openebs https://openebs.github.io/charts + helm repo update + helm install openebs openebs/openebs -n openebs --create-namespace + + echo "Creating namespace ${ARC_NAMESPACE}" + kubectl create namespace "${SCALE_SET_NAMESPACE}" + + 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}" + 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 containerMode.type="kubernetes" \ + --set containerMode.kubernetesModeWorkVolumeClaim.accessModes="{\"ReadWriteOnce\"}" \ + --set containerMode.kubernetesModeWorkVolumeClaim.storageClassName="openebs-hostpath" \ + --set containerMode.kubernetesModeWorkVolumeClaim.resources.requests.storage="1Gi" \ + "${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 main() { + local failed=() + + build_image + create_cluster + + install_arc + install_scale_set + + WORKFLOW_FILE="${WORKFLOW_FILE}" SCALE_SET_NAME="${SCALE_SET_NAME}" run_workflow || failed+=("run_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 From 593cee8d7ea91128330a842fce0bddf053cb666c Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Mon, 7 Apr 2025 10:25:54 +0200 Subject: [PATCH 05/10] include log --- test/actions.github.com/anonymous-proxy-setup.test.sh | 1 + test/actions.github.com/auth-proxy-setup.test.sh | 3 ++- test/actions.github.com/default-setup.test.sh | 1 + test/actions.github.com/dind-mode-setup.test.sh | 1 + test/actions.github.com/kubernetes-mode-setup.test.sh | 1 + test/actions.github.com/single-namespace-setup.test.sh | 1 + 6 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/actions.github.com/anonymous-proxy-setup.test.sh b/test/actions.github.com/anonymous-proxy-setup.test.sh index 9bec9d03..ea2f0ba4 100755 --- a/test/actions.github.com/anonymous-proxy-setup.test.sh +++ b/test/actions.github.com/anonymous-proxy-setup.test.sh @@ -61,6 +61,7 @@ function install_scale_set() { } function main() { + echo "[*] Running anonymous proxy setup" local failed=() build_image diff --git a/test/actions.github.com/auth-proxy-setup.test.sh b/test/actions.github.com/auth-proxy-setup.test.sh index 243160af..843d7541 100755 --- a/test/actions.github.com/auth-proxy-setup.test.sh +++ b/test/actions.github.com/auth-proxy-setup.test.sh @@ -8,7 +8,7 @@ ROOT_DIR="$(realpath "${DIR}/../..")" source "${DIR}/helper.sh" -SCALE_SET_NAME="default-$(date +'%M%S')$((($RANDOM + 100) % 100 + 1))" +SCALE_SET_NAME="default-$(date +'%M%S')$(((${RANDOM} + 100) % 100 + 1))" SCALE_SET_NAMESPACE="arc-runners" WORKFLOW_FILE="arc-test-workflow.yaml" ARC_NAME="arc" @@ -76,6 +76,7 @@ function install_scale_set() { } function main() { + echo "[*] Running auth proxy setup" local failed=() build_image diff --git a/test/actions.github.com/default-setup.test.sh b/test/actions.github.com/default-setup.test.sh index 6eaeecaf..33548740 100755 --- a/test/actions.github.com/default-setup.test.sh +++ b/test/actions.github.com/default-setup.test.sh @@ -51,6 +51,7 @@ function install_scale_set() { } function main() { + echo "[*] Running default setup" local failed=() build_image diff --git a/test/actions.github.com/dind-mode-setup.test.sh b/test/actions.github.com/dind-mode-setup.test.sh index a958f95d..e61a7470 100755 --- a/test/actions.github.com/dind-mode-setup.test.sh +++ b/test/actions.github.com/dind-mode-setup.test.sh @@ -52,6 +52,7 @@ function install_scale_set() { } function main() { + echo "[*] Running dind mode setup" local failed=() build_image diff --git a/test/actions.github.com/kubernetes-mode-setup.test.sh b/test/actions.github.com/kubernetes-mode-setup.test.sh index 7668c174..f98501ad 100755 --- a/test/actions.github.com/kubernetes-mode-setup.test.sh +++ b/test/actions.github.com/kubernetes-mode-setup.test.sh @@ -60,6 +60,7 @@ function install_scale_set() { } function main() { + echo "[*] Running kubernetes mode setup" local failed=() build_image diff --git a/test/actions.github.com/single-namespace-setup.test.sh b/test/actions.github.com/single-namespace-setup.test.sh index 2e70375c..2064fd8e 100755 --- a/test/actions.github.com/single-namespace-setup.test.sh +++ b/test/actions.github.com/single-namespace-setup.test.sh @@ -52,6 +52,7 @@ function install_scale_set() { } function main() { + echo "[*] Running single namespace setup" local failed=() build_image From 623e372a79240e7c7b32a2b767175b6444f6f33f Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Mon, 7 Apr 2025 13:27:24 +0200 Subject: [PATCH 06/10] fixing tests --- Makefile | 2 -- .../anonymous-proxy-setup.test.sh | 2 +- .../auth-proxy-setup.test.sh | 2 +- test/actions.github.com/default-setup.test.sh | 6 +++--- .../dind-mode-setup.test.sh | 4 ++-- test/actions.github.com/helper.sh | 21 +++++++++---------- .../kubernetes-mode-setup.test.sh | 2 +- .../single-namespace-setup.test.sh | 6 +++--- 8 files changed, 21 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index ecf4cb29..1b25ce3f 100644 --- a/Makefile +++ b/Makefile @@ -210,8 +210,6 @@ docker-buildx: docker buildx create --platform ${PLATFORMS} --name container-builder --use;\ fi docker buildx build --platform ${PLATFORMS} \ - --build-arg RUNNER_VERSION=${RUNNER_VERSION} \ - --build-arg DOCKER_VERSION=${DOCKER_VERSION} \ --build-arg VERSION=${VERSION} \ --build-arg COMMIT_SHA=${COMMIT_SHA} \ -t "${DOCKER_IMAGE_NAME}:${VERSION}" \ diff --git a/test/actions.github.com/anonymous-proxy-setup.test.sh b/test/actions.github.com/anonymous-proxy-setup.test.sh index ea2f0ba4..f4412ea7 100755 --- a/test/actions.github.com/anonymous-proxy-setup.test.sh +++ b/test/actions.github.com/anonymous-proxy-setup.test.sh @@ -51,7 +51,7 @@ function install_scale_set() { --set proxy.https.url="http://host.minikube.internal:3128" \ --set "proxy.noProxy[0]=10.96.0.1:443" \ "${ROOT_DIR}/charts/gha-runner-scale-set" \ - --version="${VERSION}" \ + --version="${IMAGE_VERSION}" \ --debug if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then diff --git a/test/actions.github.com/auth-proxy-setup.test.sh b/test/actions.github.com/auth-proxy-setup.test.sh index 843d7541..ff290f54 100755 --- a/test/actions.github.com/auth-proxy-setup.test.sh +++ b/test/actions.github.com/auth-proxy-setup.test.sh @@ -66,7 +66,7 @@ function install_scale_set() { --set proxy.https.credentialSecretRef="proxy-auth" \ --set "proxy.noProxy[0]=10.96.0.1:443" \ "${ROOT_DIR}/charts/gha-runner-scale-set" \ - --version="${VERSION}" \ + --version="${IMAGE_VERSION}" \ --debug if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then diff --git a/test/actions.github.com/default-setup.test.sh b/test/actions.github.com/default-setup.test.sh index 33548740..69ccfd38 100755 --- a/test/actions.github.com/default-setup.test.sh +++ b/test/actions.github.com/default-setup.test.sh @@ -24,7 +24,7 @@ function install_arc() { --create-namespace \ --set image.repository="${IMAGE_NAME}" \ --set image.tag="${IMAGE_TAG}" \ - ${ROOT_DIR}/charts/gha-runner-scale-set-controller \ + "${ROOT_DIR}/charts/gha-runner-scale-set-controller" \ --debug if ! NAME="${ARC_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_arc; then @@ -40,8 +40,8 @@ function install_scale_set() { --create-namespace \ --set githubConfigUrl="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \ --set githubConfigSecret.github_token="${GITHUB_TOKEN}" \ - ${ROOT_DIR}/charts/gha-runner-scale-set \ - --version="${VERSION}" \ + "${ROOT_DIR}/charts/gha-runner-scale-set" \ + --version="${IMAGE_VERSION}" \ --debug if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then diff --git a/test/actions.github.com/dind-mode-setup.test.sh b/test/actions.github.com/dind-mode-setup.test.sh index e61a7470..f047a05e 100755 --- a/test/actions.github.com/dind-mode-setup.test.sh +++ b/test/actions.github.com/dind-mode-setup.test.sh @@ -41,8 +41,8 @@ function install_scale_set() { --set githubConfigUrl="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \ --set githubConfigSecret.github_token="${GITHUB_TOKEN}" \ --set containerMode.type="dind" \ - ${ROOT_DIR}/charts/gha-runner-scale-set \ - --version="${VERSION}" \ + "${ROOT_DIR}/charts/gha-runner-scale-set" \ + --version="${IMAGE_VERSION}" \ --debug if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then diff --git a/test/actions.github.com/helper.sh b/test/actions.github.com/helper.sh index 2439587c..a7ffafbd 100644 --- a/test/actions.github.com/helper.sh +++ b/test/actions.github.com/helper.sh @@ -9,26 +9,25 @@ ROOT_DIR="$(realpath "${DIR}/../..")" export TARGET_ORG="${TARGET_ORG:-actions-runner-controller}" export TARGET_REPO="${TARGET_REPO:-arc_e2e_test_dummy}" export IMAGE_NAME="${IMAGE_NAME:-arc-test-image}" -export VERSION="${VERSION:-$(yq .version < "${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")}" -export IMAGE_VERSION="${IMAGE_VERSION:-${VERSION}}" +export IMAGE_VERSION="${VERSION:-$(yq .version < "${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")}" +export IMAGE_TAG="${IMAGE_NAME}:${IMAGE_VERSION}" + +export PLATFORMS="linux/amd64" +export COMMIT_SHA="$(git rev-parse HEAD)" function build_image() { - echo "Building ARC image ${IMAGE_NAME}:${IMAGE_VERSION}" + echo "Building ARC image ${IMAGE_TAG}" cd "${ROOT_DIR}" || exit 1 - export DOCKER_CLI_EXPERIMENTAL=enabled - export DOCKER_BUILDKIT=1 docker buildx build --platform "${PLATFORMS}" \ - --build-arg RUNNER_VERSION="${RUNNER_VERSION}" \ - --build-arg DOCKER_VERSION="${DOCKER_VERSION}" \ - --build-arg VERSION="${VERSION}" \ + --build-arg VERSION="${IMAGE_VERSION}" \ --build-arg COMMIT_SHA="${COMMIT_SHA}" \ - -t "${IMAGE_NAME}:${IMAGE_VERSION}" \ + -t "${IMAGE_TAG}" \ -f Dockerfile \ . --load - echo "Created image ${IMAGE_NAME}:${IMAGE_VERSION}" + echo "Created image ${IMAGE_TAG}" cd - || exit 1 } @@ -40,7 +39,7 @@ function create_cluster() { minikube start echo "Loading image into minikube cluster" - minikube image load "${IMAGE_NAME}:${IMAGE_VERSION}" + minikube image load "${IMAGE_TAG}" } function delete_cluster() { diff --git a/test/actions.github.com/kubernetes-mode-setup.test.sh b/test/actions.github.com/kubernetes-mode-setup.test.sh index f98501ad..43764f04 100755 --- a/test/actions.github.com/kubernetes-mode-setup.test.sh +++ b/test/actions.github.com/kubernetes-mode-setup.test.sh @@ -50,7 +50,7 @@ function install_scale_set() { --set containerMode.kubernetesModeWorkVolumeClaim.storageClassName="openebs-hostpath" \ --set containerMode.kubernetesModeWorkVolumeClaim.resources.requests.storage="1Gi" \ "${ROOT_DIR}/charts/gha-runner-scale-set" \ - --version="${VERSION}" \ + --version="${IMAGE_VERSION}" \ --debug if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then diff --git a/test/actions.github.com/single-namespace-setup.test.sh b/test/actions.github.com/single-namespace-setup.test.sh index 2064fd8e..c49e3a51 100755 --- a/test/actions.github.com/single-namespace-setup.test.sh +++ b/test/actions.github.com/single-namespace-setup.test.sh @@ -25,7 +25,7 @@ function install_arc() { --set image.repository="${IMAGE_NAME}" \ --set image.tag="${IMAGE_TAG}" \ --set flags.watchSingleNamespace="${ARC_NAMESPACE}" - ${ROOT_DIR}/charts/gha-runner-scale-set-controller \ + "${ROOT_DIR}/charts/gha-runner-scale-set-controller" \ --debug if ! NAME="${ARC_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_arc; then @@ -41,8 +41,8 @@ function install_scale_set() { --create-namespace \ --set githubConfigUrl="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \ --set githubConfigSecret.github_token="${GITHUB_TOKEN}" \ - ${ROOT_DIR}/charts/gha-runner-scale-set \ - --version="${VERSION}" \ + "${ROOT_DIR}/charts/gha-runner-scale-set" \ + --version="${IMAGE_VERSION}" \ --debug if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then From 690819e9b8d35e25a21967e2dd40066c7cebde6d Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Mon, 7 Apr 2025 14:00:48 +0200 Subject: [PATCH 07/10] rename --- .../anonymous-proxy-setup.test.sh | 2 +- test/actions.github.com/auth-proxy-setup.test.sh | 2 +- test/actions.github.com/default-setup.test.sh | 2 +- test/actions.github.com/dind-mode-setup.test.sh | 2 +- test/actions.github.com/helper.sh | 15 ++++++++------- .../kubernetes-mode-setup.test.sh | 2 +- .../single-namespace-setup.test.sh | 2 +- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/test/actions.github.com/anonymous-proxy-setup.test.sh b/test/actions.github.com/anonymous-proxy-setup.test.sh index f4412ea7..ea2f0ba4 100755 --- a/test/actions.github.com/anonymous-proxy-setup.test.sh +++ b/test/actions.github.com/anonymous-proxy-setup.test.sh @@ -51,7 +51,7 @@ function install_scale_set() { --set proxy.https.url="http://host.minikube.internal:3128" \ --set "proxy.noProxy[0]=10.96.0.1:443" \ "${ROOT_DIR}/charts/gha-runner-scale-set" \ - --version="${IMAGE_VERSION}" \ + --version="${VERSION}" \ --debug if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then diff --git a/test/actions.github.com/auth-proxy-setup.test.sh b/test/actions.github.com/auth-proxy-setup.test.sh index ff290f54..843d7541 100755 --- a/test/actions.github.com/auth-proxy-setup.test.sh +++ b/test/actions.github.com/auth-proxy-setup.test.sh @@ -66,7 +66,7 @@ function install_scale_set() { --set proxy.https.credentialSecretRef="proxy-auth" \ --set "proxy.noProxy[0]=10.96.0.1:443" \ "${ROOT_DIR}/charts/gha-runner-scale-set" \ - --version="${IMAGE_VERSION}" \ + --version="${VERSION}" \ --debug if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then diff --git a/test/actions.github.com/default-setup.test.sh b/test/actions.github.com/default-setup.test.sh index 69ccfd38..f653c610 100755 --- a/test/actions.github.com/default-setup.test.sh +++ b/test/actions.github.com/default-setup.test.sh @@ -41,7 +41,7 @@ function install_scale_set() { --set githubConfigUrl="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \ --set githubConfigSecret.github_token="${GITHUB_TOKEN}" \ "${ROOT_DIR}/charts/gha-runner-scale-set" \ - --version="${IMAGE_VERSION}" \ + --version="${VERSION}" \ --debug if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then diff --git a/test/actions.github.com/dind-mode-setup.test.sh b/test/actions.github.com/dind-mode-setup.test.sh index f047a05e..12d25086 100755 --- a/test/actions.github.com/dind-mode-setup.test.sh +++ b/test/actions.github.com/dind-mode-setup.test.sh @@ -42,7 +42,7 @@ function install_scale_set() { --set githubConfigSecret.github_token="${GITHUB_TOKEN}" \ --set containerMode.type="dind" \ "${ROOT_DIR}/charts/gha-runner-scale-set" \ - --version="${IMAGE_VERSION}" \ + --version="${VERSION}" \ --debug if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then diff --git a/test/actions.github.com/helper.sh b/test/actions.github.com/helper.sh index a7ffafbd..ea8768b7 100644 --- a/test/actions.github.com/helper.sh +++ b/test/actions.github.com/helper.sh @@ -9,25 +9,26 @@ ROOT_DIR="$(realpath "${DIR}/../..")" export TARGET_ORG="${TARGET_ORG:-actions-runner-controller}" export TARGET_REPO="${TARGET_REPO:-arc_e2e_test_dummy}" export IMAGE_NAME="${IMAGE_NAME:-arc-test-image}" -export IMAGE_VERSION="${VERSION:-$(yq .version < "${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")}" -export IMAGE_TAG="${IMAGE_NAME}:${IMAGE_VERSION}" +export VERSION="${VERSION:-$(yq .version < "${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")}" +export IMAGE_TAG="${VERSION}" +export IMAGE="${IMAGE_NAME}:${IMAGE_TAG}" export PLATFORMS="linux/amd64" export COMMIT_SHA="$(git rev-parse HEAD)" function build_image() { - echo "Building ARC image ${IMAGE_TAG}" + echo "Building ARC image ${IMAGE}" cd "${ROOT_DIR}" || exit 1 docker buildx build --platform "${PLATFORMS}" \ - --build-arg VERSION="${IMAGE_VERSION}" \ + --build-arg VERSION="${VERSION}" \ --build-arg COMMIT_SHA="${COMMIT_SHA}" \ - -t "${IMAGE_TAG}" \ + -t "${IMAGE}" \ -f Dockerfile \ . --load - echo "Created image ${IMAGE_TAG}" + echo "Created image ${IMAGE}" cd - || exit 1 } @@ -39,7 +40,7 @@ function create_cluster() { minikube start echo "Loading image into minikube cluster" - minikube image load "${IMAGE_TAG}" + minikube image load "${IMAGE}" } function delete_cluster() { diff --git a/test/actions.github.com/kubernetes-mode-setup.test.sh b/test/actions.github.com/kubernetes-mode-setup.test.sh index 43764f04..f98501ad 100755 --- a/test/actions.github.com/kubernetes-mode-setup.test.sh +++ b/test/actions.github.com/kubernetes-mode-setup.test.sh @@ -50,7 +50,7 @@ function install_scale_set() { --set containerMode.kubernetesModeWorkVolumeClaim.storageClassName="openebs-hostpath" \ --set containerMode.kubernetesModeWorkVolumeClaim.resources.requests.storage="1Gi" \ "${ROOT_DIR}/charts/gha-runner-scale-set" \ - --version="${IMAGE_VERSION}" \ + --version="${VERSION}" \ --debug if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then diff --git a/test/actions.github.com/single-namespace-setup.test.sh b/test/actions.github.com/single-namespace-setup.test.sh index c49e3a51..97cb9a71 100755 --- a/test/actions.github.com/single-namespace-setup.test.sh +++ b/test/actions.github.com/single-namespace-setup.test.sh @@ -42,7 +42,7 @@ function install_scale_set() { --set githubConfigUrl="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \ --set githubConfigSecret.github_token="${GITHUB_TOKEN}" \ "${ROOT_DIR}/charts/gha-runner-scale-set" \ - --version="${IMAGE_VERSION}" \ + --version="${VERSION}" \ --debug if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then From 90fb186d85b59b14ffb3d1833d49de5d49b5f3dc Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Mon, 7 Apr 2025 14:52:29 +0200 Subject: [PATCH 08/10] don't silence the workflow view un run_workflow --- test/actions.github.com/helper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/actions.github.com/helper.sh b/test/actions.github.com/helper.sh index ea8768b7..3a216697 100644 --- a/test/actions.github.com/helper.sh +++ b/test/actions.github.com/helper.sh @@ -127,7 +127,7 @@ function print_results() { function run_workflow() { echo "Checking if the workflow file exists" - gh workflow view -R "${TARGET_ORG}/${TARGET_REPO}" "${WORKFLOW_FILE}" &> /dev/null || return 1 + gh workflow view -R "${TARGET_ORG}/${TARGET_REPO}" "${WORKFLOW_FILE}" || return 1 local queue_time="$(date -u +%FT%TZ)" From 19134e3b0ce1d106fd781d56e46c7d8741bf71ab Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Tue, 8 Apr 2025 12:45:15 +0200 Subject: [PATCH 09/10] rename --- test/actions.github.com/anonymous-proxy-setup.test.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/actions.github.com/anonymous-proxy-setup.test.sh b/test/actions.github.com/anonymous-proxy-setup.test.sh index ea2f0ba4..b150df34 100755 --- a/test/actions.github.com/anonymous-proxy-setup.test.sh +++ b/test/actions.github.com/anonymous-proxy-setup.test.sh @@ -8,7 +8,7 @@ ROOT_DIR="$(realpath "${DIR}/../..")" source "${DIR}/helper.sh" -SCALE_SET_NAME="default-$(date +'%M%S')$(((${RANDOM} + 100) % 100 + 1))" +SCALE_SET_NAME="anonymous-proxy-$(date +'%M%S')$(((${RANDOM} + 100) % 100 + 1))" SCALE_SET_NAMESPACE="arc-runners" WORKFLOW_FILE="arc-test-workflow.yaml" ARC_NAME="arc" @@ -38,7 +38,7 @@ function start_squid_proxy() { docker run -d \ --name squid \ --publish 3128:3128 \ - huangtingluo/squid-proxy:latest + ubuntu/squid:latest } function install_scale_set() { @@ -68,6 +68,7 @@ function main() { create_cluster install_arc + start_squid_proxy install_scale_set WORKFLOW_FILE="${WORKFLOW_FILE}" SCALE_SET_NAME="${SCALE_SET_NAME}" run_workflow || failed+=("run_workflow") From 8b09e6c5a8494eeb1b808517671d5b2b19cd4f6c Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Mon, 9 Jun 2025 18:56:11 +0200 Subject: [PATCH 10/10] load runner image and stop squid on anonymous proxy --- test/actions.github.com/anonymous-proxy-setup.test.sh | 7 +++++++ test/actions.github.com/auth-proxy-setup.test.sh | 2 +- test/actions.github.com/helper.sh | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/test/actions.github.com/anonymous-proxy-setup.test.sh b/test/actions.github.com/anonymous-proxy-setup.test.sh index b150df34..856b7607 100755 --- a/test/actions.github.com/anonymous-proxy-setup.test.sh +++ b/test/actions.github.com/anonymous-proxy-setup.test.sh @@ -36,11 +36,17 @@ function install_arc() { function start_squid_proxy() { echo "Starting squid-proxy" docker run -d \ + --rm \ --name squid \ --publish 3128:3128 \ ubuntu/squid:latest } +function stop_squid_proxy() { + echo "Stopping squid-proxy" + docker stop squid +} + function install_scale_set() { echo "Installing scale set ${SCALE_SET_NAMESPACE}/${SCALE_SET_NAME}" helm install "${SCALE_SET_NAME}" \ @@ -78,6 +84,7 @@ function main() { NAMESPACE="${ARC_NAMESPACE}" log_arc || failed+=("log_arc") delete_cluster + stop_squid_proxy print_results "${failed[@]}" } diff --git a/test/actions.github.com/auth-proxy-setup.test.sh b/test/actions.github.com/auth-proxy-setup.test.sh index 843d7541..ff0ad8a4 100755 --- a/test/actions.github.com/auth-proxy-setup.test.sh +++ b/test/actions.github.com/auth-proxy-setup.test.sh @@ -46,7 +46,7 @@ function start_squid_proxy() { huangtingluo/squid-proxy:latest echo "Creating scale set namespace" - kubectl create namespace "${SCALE_SET_NAMESPACE}" + kubectl create namespace "${SCALE_SET_NAMESPACE}" || true echo "Creating squid proxy secret" kubectl create secret generic proxy-auth \ diff --git a/test/actions.github.com/helper.sh b/test/actions.github.com/helper.sh index 3a216697..0d4b2b09 100644 --- a/test/actions.github.com/helper.sh +++ b/test/actions.github.com/helper.sh @@ -41,6 +41,9 @@ function create_cluster() { echo "Loading image into minikube cluster" minikube image load "${IMAGE}" + + echo "Loading runner image into minikube cluster" + minikube image load "ghcr.io/actions/actions-runner:latest" } function delete_cluster() {