From 6c938ce388df618d7ddf2c9186635de1a8cfa4ec Mon Sep 17 00:00:00 2001 From: despire Date: Fri, 22 Nov 2024 12:43:20 +0100 Subject: [PATCH] CI changes --- .github/workflows/CI-pipeline.yml | 62 ++++++++++++++++--------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/.github/workflows/CI-pipeline.yml b/.github/workflows/CI-pipeline.yml index 05551cfb1..840dafd5d 100644 --- a/.github/workflows/CI-pipeline.yml +++ b/.github/workflows/CI-pipeline.yml @@ -273,6 +273,36 @@ jobs: ref: ${{ github.head_ref }} repository: ${{ github.event.pull_request.head.repo.full_name }} + - name: Determine which test sets to run + run: | + sudo apt update && sudo apt install -y wget tar + wget -q https://github.com/mikefarah/yq/releases/download/v4.27.2/yq_linux_amd64.tar.gz -O - |\ + tar xz && mv yq_linux_amd64 yq + + test_sets=$(./yq '.secretGenerator[].name' kustomization.yaml) + selected=() + + for set in $test_sets; do + mnt="/go/services/testing-framework/test-sets/$set" + + if [ -n "$GITHUB_PR_LABEL_TEST_SET_AUTOSCALING" ] && [[ "$set" == *"autoscaling"* ]]; then + ./yq -i "select(di ==0).spec.template.spec.volumes += [{\"name\": \"$set\", \"secret\": {\"secretName\": \"$set\"}}]" testing-framework.yaml + ./yq -i "select(di ==0).spec.template.spec.containers[].volumeMounts += [{\"name\": \"$set\", \"mountPath\": \"$mnt\"}]" testing-framework.yaml + selected+=("$set") + fi + + if [ -n "$GITHUB_PR_LABEL_TEST_SET_FAIL_UNTIL_LAST" ] && [[ "$set" == *"on-last"* ]]; then + ./yq -i "select(di ==0).spec.template.spec.volumes += [{\"name\": \"$set\", \"secret\": {\"secretName\": \"$set\"}}]" testing-framework.yaml + ./yq -i "select(di ==0).spec.template.spec.containers[].volumeMounts += [{\"name\": \"$set\", \"mountPath\": \"$mnt\"}]" testing-framework.yaml + selected+=("$set") + fi + done + + if [ ${#selected[@]} -eq 0 ]; then + echo "No test sets were selected." + exit 0 + fi + - name: Install terraform run: | sudo apt-get update && sudo apt-get install -y wget @@ -343,10 +373,6 @@ jobs: - name: Insert random test hostnames to loadbalancer test set working-directory: ./manifests/testing-framework/test-sets run: | - sudo apt update && sudo apt install -y wget tar - wget -q https://github.com/mikefarah/yq/releases/download/v4.27.2/yq_linux_amd64.tar.gz -O - |\ - tar xz && mv yq_linux_amd64 yq - HOSTNAME=$(echo $RANDOM | md5sum | head -c 20; echo;) ./yq e '.spec.loadBalancers.clusters.[1].dns.hostname = strenv(HOSTNAME)' test-set2/1.yaml -i HOSTNAME=$(echo $RANDOM | md5sum | head -c 20; echo;) ./yq e '.spec.loadBalancers.clusters.[0].dns.hostname = strenv(HOSTNAME)' test-set2/3.yaml -i @@ -398,34 +424,9 @@ jobs: fi done - #Clean up - rm -f yq - rm -f yq.1 - rm -f install-man-page.sh - - name: Start the E2E tests working-directory: ./manifests run: | - sudo apt update && sudo apt install -y wget tar - wget -q https://github.com/mikefarah/yq/releases/download/v4.27.2/yq_linux_amd64.tar.gz -O - |\ - tar xz && mv yq_linux_amd64 yq - - test_sets=$(./yq '.secretGenerator[].name' ./testing-framework/kustomization.yaml) - - for set in $test_sets; do - mnt="/go/services/testing-framework/test-sets/$set" - - if [ -n "$GITHUB_PR_LABEL_TEST_SET_AUTOSCALING" ] && [[ "$set" == *"autoscaling"* ]]; then - ./yq -i "select(di ==0).spec.template.spec.volumes += [{\"name\": \"$set\", \"secret\": {\"secretName\": \"$set\"}}]" ./testing-framework/testing-framework.yaml - ./yq -i "select(di ==0).spec.template.spec.containers[].volumeMounts += [{\"name\": \"$set\", \"mountPath\": \"$mnt\"}]" ./testing-framework/testing-framework.yaml - fi - - if [ -n "$GITHUB_PR_LABEL_TEST_SET_FAIL_UNTIL_LAST" ] && [[ "$set" == *"on-last"* ]]; then - ./yq -i "select(di ==0).spec.template.spec.volumes += [{\"name\": \"$set\", \"secret\": {\"secretName\": \"$set\"}}]" testing-framework.yaml - ./yq -i "select(di ==0).spec.template.spec.containers[].volumeMounts += [{\"name\": \"$set\", \"mountPath\": \"$mnt\"}]" testing-framework.yaml - fi - done - NAME_HASH="testing-framework-${SHORT_GITHUB_SHA}-${GITHUB_RUN_NUMBER}" ./yq e -i '(select(.kind == "ClusterRoleBinding").metadata.name = strenv(NAME_HASH))' ./testing-framework/testing-framework.yaml cat ./testing-framework/testing-framework.yaml @@ -433,7 +434,10 @@ jobs: kustomize edit set namespace claudie-${SHORT_GITHUB_SHA}-${GITHUB_RUN_NUMBER} kustomize build . | kubectl apply -f - + #Clean up rm -f yq + rm -f yq.1 + rm -f install-man-page.sh - name: Monitor E2E test run: |