Add env test

This commit is contained in:
Nikola Jokic 2023-12-05 14:11:12 +01:00
parent 20c8c49046
commit 82d4ab8936
No known key found for this signature in database
GPG Key ID: 1115F751E6A09850
11 changed files with 32 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -1,3 +1,3 @@
export TARGET_ORG="org"
export TARGET_REPO="repo"
export GITHUB_TOKEN="token"

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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