From e39bada44fc8d1a7fe7baf80413a4473be450215 Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Thu, 9 Apr 2026 08:50:19 +0000 Subject: [PATCH 1/2] fix: add fallback to master for test-controller action --- .github/actions/tests/test-controller/action.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/actions/tests/test-controller/action.yaml b/.github/actions/tests/test-controller/action.yaml index 1b076789..06407fdd 100644 --- a/.github/actions/tests/test-controller/action.yaml +++ b/.github/actions/tests/test-controller/action.yaml @@ -35,7 +35,16 @@ runs: TRIGGER: ${{ github.event_name }} run: | set -eo pipefail - curl -s --retry 5 --retry-delay 10 --fail-with-body "http://tui.internal.dev.tyk.technology/v2/$VARIATION/$REPO_NAME/$BASE_REF/$TRIGGER/$TEST_TYPE.gho" | tee -a "$GITHUB_OUTPUT" + URL="http://tui.internal.dev.tyk.technology/v2/$VARIATION/$REPO_NAME/$BASE_REF/$TRIGGER/$TEST_TYPE.gho" + FALLBACK_URL="http://tui.internal.dev.tyk.technology/v2/$VARIATION/$REPO_NAME/master/$TRIGGER/$TEST_TYPE.gho" + + TMP_OUT=$(mktemp) + if curl -s --retry 5 --retry-delay 10 --fail "$URL" > "$TMP_OUT"; then + cat "$TMP_OUT" | tee -a "$GITHUB_OUTPUT" + else + echo "Failed to fetch configuration for branch $BASE_REF. Retrying with master branch as fallback..." + curl -s --retry 5 --retry-delay 10 --fail-with-body "$FALLBACK_URL" | tee -a "$GITHUB_OUTPUT" + fi if ! [[ $VARIATION =~ prod ]] ;then echo "::warning file=.github/workflows/release.yml,line=24,col=1,endColumn=8::Using non-prod variation" echo "### :warning: You are using VARIATION=${VARIATION} in test-controller-{{ .test }}" >> $GITHUB_STEP_SUMMARY From ae368f67cd7d34397f45ef58418c0c62a9e3606a Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Thu, 9 Apr 2026 08:52:41 +0000 Subject: [PATCH 2/2] fix: implement client-side fallback for TUI configuration fetching based on HTTP 404 status --- .../actions/tests/test-controller/action.yaml | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/actions/tests/test-controller/action.yaml b/.github/actions/tests/test-controller/action.yaml index 06407fdd..a542e052 100644 --- a/.github/actions/tests/test-controller/action.yaml +++ b/.github/actions/tests/test-controller/action.yaml @@ -35,17 +35,30 @@ runs: TRIGGER: ${{ github.event_name }} run: | set -eo pipefail + URL="http://tui.internal.dev.tyk.technology/v2/$VARIATION/$REPO_NAME/$BASE_REF/$TRIGGER/$TEST_TYPE.gho" - FALLBACK_URL="http://tui.internal.dev.tyk.technology/v2/$VARIATION/$REPO_NAME/master/$TRIGGER/$TEST_TYPE.gho" - TMP_OUT=$(mktemp) - if curl -s --retry 5 --retry-delay 10 --fail "$URL" > "$TMP_OUT"; then - cat "$TMP_OUT" | tee -a "$GITHUB_OUTPUT" - else - echo "Failed to fetch configuration for branch $BASE_REF. Retrying with master branch as fallback..." - curl -s --retry 5 --retry-delay 10 --fail-with-body "$FALLBACK_URL" | tee -a "$GITHUB_OUTPUT" + # Fetch the configuration and capture the HTTP status code + HTTP_CODE=$(curl -s -o response.txt -w "%{http_code}" --retry 5 --retry-delay 10 "$URL") + + # If 404, fallback to master branch + if [ "$HTTP_CODE" -eq 404 ]; then + echo "Configuration not found for base_ref '$BASE_REF'. Falling back to 'master' branch." + FALLBACK_URL="http://tui.internal.dev.tyk.technology/v2/$VARIATION/$REPO_NAME/master/$TRIGGER/$TEST_TYPE.gho" + HTTP_CODE=$(curl -s -o response.txt -w "%{http_code}" --retry 5 --retry-delay 10 "$FALLBACK_URL") + fi + + # If still an error (>= 400), fail the step and output the body + if [ "$HTTP_CODE" -ge 400 ]; then + echo "Failed to fetch configuration: HTTP $HTTP_CODE" + cat response.txt + exit 1 fi + + # Write the successful response to GITHUB_OUTPUT + cat response.txt | tee -a "$GITHUB_OUTPUT" + if ! [[ $VARIATION =~ prod ]] ;then echo "::warning file=.github/workflows/release.yml,line=24,col=1,endColumn=8::Using non-prod variation" - echo "### :warning: You are using VARIATION=${VARIATION} in test-controller-{{ .test }}" >> $GITHUB_STEP_SUMMARY + echo "### :warning: You are using VARIATION=${VARIATION} in test-controller-" >> $GITHUB_STEP_SUMMARY fi