From 82d4ab8936d4cfcb7d332bf5b730ff78b38225ba Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Tue, 5 Dec 2023 14:11:12 +0100 Subject: [PATCH] Add env test --- hack/e2e-test.sh | 19 +++++++++++++++++++ .../anonymous-proxy-setup.test.sh | 2 +- .../auth-proxy-setup.test.sh | 2 +- test/actions.github.com/default_setup.test.sh | 2 +- test/actions.github.com/dind-setup.test.sh | 2 +- test/actions.github.com/envrc.example | 2 +- test/actions.github.com/helper.sh | 8 +++----- .../kubernetes-mode-setup.test.sh | 1 + .../self-signed-ca-setup.test.sh | 2 +- .../single-namespace-setup.test.sh | 2 +- .../update-strategy.test.sh | 4 ++-- 11 files changed, 32 insertions(+), 14 deletions(-) diff --git a/hack/e2e-test.sh b/hack/e2e-test.sh index e439f34b..3ee1b59d 100755 --- a/hack/e2e-test.sh +++ b/hack/e2e-test.sh @@ -18,6 +18,23 @@ function set_targets() { 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 main() { local failed=() @@ -53,4 +70,6 @@ function main() { set_targets +env_test + main diff --git a/test/actions.github.com/anonymous-proxy-setup.test.sh b/test/actions.github.com/anonymous-proxy-setup.test.sh index d65101b9..040f29c8 100755 --- a/test/actions.github.com/anonymous-proxy-setup.test.sh +++ b/test/actions.github.com/anonymous-proxy-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-rynner-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/auth-proxy-setup.test.sh b/test/actions.github.com/auth-proxy-setup.test.sh index 60dbf2b1..27b665f4 100755 --- a/test/actions.github.com/auth-proxy-setup.test.sh +++ b/test/actions.github.com/auth-proxy-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-rynner-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/default_setup.test.sh b/test/actions.github.com/default_setup.test.sh index c00f235b..72323f47 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-rynner-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/dind-setup.test.sh b/test/actions.github.com/dind-setup.test.sh index fd91bb35..9806c211 100755 --- a/test/actions.github.com/dind-setup.test.sh +++ b/test/actions.github.com/dind-setup.test.sh @@ -10,7 +10,7 @@ source "${DIR}/helper.sh" SCALE_SET_NAME="dind-$(date +'%M%S')$(((${RANDOM} + 100) % 100 + 1))" SCALE_SET_NAMESPACE="arc-runners" -WORKFLOW_FILE="example.yaml" +WORKFLOW_FILE="arc-test-dind-workflow.yaml" ARC_NAME="arc" ARC_NAMESPACE="arc-systems" diff --git a/test/actions.github.com/envrc.example b/test/actions.github.com/envrc.example index 4feaa63c..5db64c18 100644 --- a/test/actions.github.com/envrc.example +++ b/test/actions.github.com/envrc.example @@ -1,3 +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 index 06dd8cbb..081e06a0 100644 --- a/test/actions.github.com/helper.sh +++ b/test/actions.github.com/helper.sh @@ -126,18 +126,16 @@ function print_results() { } function run_workflow() { - local workflow_file="$1" - echo "Checking if the workflow file exists" gh workflow view -R "${TARGET_ORG}/${TARGET_REPO}" "${workflow_file}" || return 1 echo "Getting run count before a new run" - local target_run_count=$(($(gh run list -R "${TARGET_ORG}/${TARGET_REPO}" --workflow "${workflow_file}" --limit 1 --jq '. | length') + 1)) + local target_run_count=$(($(gh run list -R "${TARGET_ORG}/${TARGET_REPO}" --workflow "${WORKFLOW_FILE}" --limit 1 --jq '. | length') + 1)) local queue_time=$(date +%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 + 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 @@ -148,7 +146,7 @@ function run_workflow() { 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}"))'") + 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}"))'") if [ -n "$run_id" ]; then echo "Run found: $run_id" break diff --git a/test/actions.github.com/kubernetes-mode-setup.test.sh b/test/actions.github.com/kubernetes-mode-setup.test.sh index 1c4d4536..c63432c3 100755 --- a/test/actions.github.com/kubernetes-mode-setup.test.sh +++ b/test/actions.github.com/kubernetes-mode-setup.test.sh @@ -10,6 +10,7 @@ source "${DIR}/helper.sh" SCALE_SET_NAME="kube-mode-$(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" diff --git a/test/actions.github.com/self-signed-ca-setup.test.sh b/test/actions.github.com/self-signed-ca-setup.test.sh index b9f1c8a5..2938b214 100755 --- a/test/actions.github.com/self-signed-ca-setup.test.sh +++ b/test/actions.github.com/self-signed-ca-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-rynner-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/single-namespace-setup.test.sh b/test/actions.github.com/single-namespace-setup.test.sh index 0a32ede4..92d1ac39 100755 --- a/test/actions.github.com/single-namespace-setup.test.sh +++ b/test/actions.github.com/single-namespace-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-rynner-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/update-strategy.test.sh b/test/actions.github.com/update-strategy.test.sh index 68af2632..717dcc17 100755 --- a/test/actions.github.com/update-strategy.test.sh +++ b/test/actions.github.com/update-strategy.test.sh @@ -10,7 +10,7 @@ source "${DIR}/helper.sh" SCALE_SET_NAME="update-strategy-$(date '+%M%S')$((($RANDOM + 100) % 100 + 1))" SCALE_SET_NAMESPACE="arc-runners" -WORKFLOW_FILE="arc-test-workflow.yaml" +WORKFLOW_FILE="arc-test-sleepy-matrix.yaml" ARC_NAME="arc" ARC_NAMESPACE="arc-systems" @@ -23,7 +23,7 @@ function install_arc() { --set image.repository="${IMAGE_NAME}" \ --set image.tag="${IMAGE_TAG}" \ --set flags.updateStrategy="eventual" \ - ${ROOT_DIR}/charts/gha-rynner-scale-set-controller \ + ${ROOT_DIR}/charts/gha-runner-scale-set-controller \ --debug if ! NAME="${ARC_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_arc; then