Skip to content

Commit

Permalink
Randomize the id with GITHUB_RUN_NUMBER for scheduled test (radius-pr…
Browse files Browse the repository at this point in the history
…oject#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.

radius-project#7383
radius-project#7382
radius-project#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).

<!--

Please update the following to link the associated issue. This is
required for some kinds of changes (see above).

-->

Fixes: radius-project#7388

---------

Signed-off-by: Young Bu Park <[email protected]>
  • Loading branch information
youngbupark authored Mar 25, 2024
1 parent 28f73b7 commit 166d872
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/functional-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/long-running-azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/retry-functional-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 166d872

Please sign in to comment.