From 166d8724411540bf1d5989bf37f6b2846ea92157 Mon Sep 17 00:00:00 2001 From: Young Bu Park Date: Mon, 25 Mar 2024 14:44:09 -0700 Subject: [PATCH] Randomize the id with GITHUB_RUN_NUMBER for scheduled test (#7392) # Description We generate unique id by concatenating GitHub Actions' system variables, hashing the string, and taking 10 characters. This way will reduce the chance to create multiple resource for the same PR. In scheduled test, the most of variables are same, so there is a little chance to face the conflicts. particularly, when resource group is being in progress triggered by the previous action runs like below failures. This change 1) adds GITHUB_RUN_NUMBER, which is updated for each action run, to the raw id before hashing and 2) adds the prefix to each hashed string to avoid the conflicts between different workflows. https://github.com/radius-project/radius/issues/7383 https://github.com/radius-project/radius/issues/7382 https://github.com/radius-project/radius/issues/7380 ## Type of change - This pull request is a minor refactor, code cleanup, test improvement, or other maintenance task and doesn't change the functionality of Radius (issue link optional). Fixes: #7388 --------- Signed-off-by: Young Bu Park --- .github/workflows/functional-test.yaml | 6 +++++- .github/workflows/long-running-azure.yaml | 6 +++++- .github/workflows/retry-functional-test.yaml | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/functional-test.yaml b/.github/workflows/functional-test.yaml index d7f2700d97..fcd8d6c11f 100644 --- a/.github/workflows/functional-test.yaml +++ b/.github/workflows/functional-test.yaml @@ -165,7 +165,11 @@ jobs: id: gen-id run: | BASE_STR="RADIUS|${GITHUB_SHA}|${GITHUB_SERVER_URL}|${GITHUB_REPOSITORY}|${GITHUB_RUN_ID}|${GITHUB_RUN_ATTEMPT}" - UNIQUE_ID=$(echo $BASE_STR | sha1sum | head -c 10) + if [ "$GITHUB_EVENT_NAME" == "schedule" ]; then + # Add run number to randomize unique id for scheduled runs. + BASE_STR="${GITHUB_RUN_NUMBER}|${BASE_STR}" + fi + UNIQUE_ID=func$(echo $BASE_STR | sha1sum | head -c 10) echo "REL_VERSION=pr-${UNIQUE_ID}" >> $GITHUB_ENV # Set output variables to be used in the other jobs diff --git a/.github/workflows/long-running-azure.yaml b/.github/workflows/long-running-azure.yaml index b633255c1c..797f8b7994 100644 --- a/.github/workflows/long-running-azure.yaml +++ b/.github/workflows/long-running-azure.yaml @@ -145,7 +145,11 @@ jobs: run: | if [ -z "${{ steps.skip-build.outputs.SKIP_BUILD }}" ]; then BASE_STR="RADIUS|${GITHUB_SHA}|${GITHUB_SERVER_URL}|${GITHUB_REPOSITORY}|${GITHUB_RUN_ID}|${GITHUB_RUN_ATTEMPT}" - UNIQUE_ID=$(echo $BASE_STR | sha1sum | head -c 10) + if [ "$GITHUB_EVENT_NAME" == "schedule" ]; then + # Add run number to randomize unique id for scheduled runs. + BASE_STR="${GITHUB_RUN_NUMBER}|${BASE_STR}" + fi + UNIQUE_ID=longr$(echo $BASE_STR | sha1sum | head -c 10) echo "REL_VERSION=pr-${UNIQUE_ID}" >> $GITHUB_ENV # Set output variables to be used in the other jobs diff --git a/.github/workflows/retry-functional-test.yaml b/.github/workflows/retry-functional-test.yaml index 8ea3d89188..dc624b7683 100644 --- a/.github/workflows/retry-functional-test.yaml +++ b/.github/workflows/retry-functional-test.yaml @@ -112,7 +112,11 @@ jobs: id: gen-id run: | BASE_STR="RADIUS|${GITHUB_SHA}|${GITHUB_SERVER_URL}|${GITHUB_REPOSITORY}|${GITHUB_RUN_ID}|${GITHUB_RUN_ATTEMPT}" - UNIQUE_ID=$(echo $BASE_STR | sha1sum | head -c 10) + if [ "$GITHUB_EVENT_NAME" == "schedule" ]; then + # Add run number to randomize unique id for scheduled runs. + BASE_STR="${GITHUB_RUN_NUMBER}|${BASE_STR}" + fi + UNIQUE_ID=retry$(echo $BASE_STR | sha1sum | head -c 10) echo "REL_VERSION=pr-${UNIQUE_ID}" >> $GITHUB_ENV # Set output variables to be used in the other jobs