File tree Expand file tree Collapse file tree
.github/actions/validate-pr Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ function compare_versions() {
6666
6767SEMANTIC_PREFIXES=" ^(feat|fix|chore|ci|docs|style|refactor|perf|test)[(:]"
6868JIRA_TICKET=" ([A-Z]+-[0-9]+)"
69- VERSION_REGEX=" ^ v([0-9]+)\.([0-9]+)\.([0-9]+)$ "
69+ VERSION_REGEX=" v([0-9]+)\.([0-9]+)\.([0-9]+)"
7070
7171if [[ " $TARGET_BRANCH " == " develop" ]] || [[ " $TARGET_BRANCH " =~ ^release/v ]] || [[ " $TARGET_BRANCH " =~ ^hotfix/v ]]; then
7272 if [[ " $PR_BRANCH " =~ ^release/v ]] || [[ " $PR_BRANCH " =~ ^hotfix/v ]]; then
9696
9797if [[ " $TARGET_BRANCH " == " main" ]]; then
9898 if [[ " $PR_BRANCH " =~ ^release/v ]] || [[ " $PR_BRANCH " =~ ^hotfix/v ]]; then
99- if [[ ! " $PR_BRANCH " =~ ^release/v$PACKAGE_VERSION ]] && [[ ! " $PR_BRANCH " =~ ^hotfix/v$PACKAGE_VERSION ]]; then
99+ BASE_BRANCH_VERSION=$( echo " $PR_BRANCH " | grep -oE " v[0-9]+\.[0-9]+\.[0-9]+" )
100+ if [[ ! " $BASE_BRANCH_VERSION " =~ ^v$PACKAGE_VERSION ]] && [[ ! " $BASE_BRANCH_VERSION " =~ ^v$PACKAGE_VERSION ]]; then
100101 echo " Error: Mismatch between the pull request branch and the package version.
101102Details:
102103- PR Branch: $PR_BRANCH
@@ -125,7 +126,7 @@ Action: Only release or hotfix branches can be merged to main
125126Expected format: release/v$PACKAGE_VERSION or hotfix/v$PACKAGE_VERSION "
126127 exit 1
127128 fi
128- if [[ ! " $PR_BRANCH " =~ ^release/ v$PACKAGE_VERSION ]] && [[ ! " $PR_BRANCH " =~ ^hotfix/ v$PACKAGE_VERSION ]]; then
129+ if [[ ! " $BASE_BRANCH_VERSION " =~ ^v$PACKAGE_VERSION ]] && [[ ! " $BASE_BRANCH_BRANCH " =~ ^v$PACKAGE_VERSION ]]; then
129130 echo " Error: Branch name does not match package version
130131Details:
131132- Current branch: $PR_BRANCH
Original file line number Diff line number Diff line change @@ -263,3 +263,19 @@ ACTUAL="$($SCRIPT_DIR/validate_pr.sh)"
263263
264264# THEN
265265expect " $? " " 0"
266+
267+ echo Scenario: Valid hotfix branch with suffix to main branch
268+ beforeEach
269+
270+ # GIVEN
271+ export PR_BRANCH=" hotfix/v1.2.3-ar"
272+ export TARGET_BRANCH=" main"
273+ export PACKAGE_VERSION=" 1.2.3"
274+ export LATEST_RELEASE=" 1.2.2"
275+ export PR_TITLE=" hotfix v1.2.3 to main"
276+
277+ # WHEN
278+ ACTUAL=" $( $SCRIPT_DIR /validate_pr.sh) "
279+
280+ # THEN
281+ expect " $? " " 0"
Original file line number Diff line number Diff line change 11{
22 "name" : " github-actions" ,
3- "version" : " 2.14.1 " ,
3+ "version" : " 2.16.0 " ,
44 "description" : " Used to store GitHub actions for use across the enterprise" ,
55 "scripts" : {
66 "test" : " ./tooling/scripts/run_tests.sh" ,
You can’t perform that action at this time.
0 commit comments