Skip to content

Commit 243fb6c

Browse files
feat: 🎸 support hotfix suffixes (#93)
✅ Closes: CORE-2231
1 parent aa5cd22 commit 243fb6c

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎.github/actions/validate-pr/validate_pr.sh‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function compare_versions() {
6666

6767
SEMANTIC_PREFIXES="^(feat|fix|chore|docs|style|refactor|perf|test)[(:]"
6868
JIRA_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

7171
if [[ "$TARGET_BRANCH" == "develop" ]] || [[ "$TARGET_BRANCH" =~ ^release/v ]] || [[ "$TARGET_BRANCH" =~ ^hotfix/v ]]; then
7272
if [[ "$PR_BRANCH" =~ ^release/v ]] || [[ "$PR_BRANCH" =~ ^hotfix/v ]]; then
@@ -96,7 +96,8 @@ fi
9696

9797
if [[ "$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.
101102
Details:
102103
- PR Branch: $PR_BRANCH
@@ -125,7 +126,7 @@ Action: Only release or hotfix branches can be merged to main
125126
Expected 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
130131
Details:
131132
- Current branch: $PR_BRANCH

‎.github/actions/validate-pr/validate_pr_test.sh‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,19 @@ ACTUAL="$($SCRIPT_DIR/validate_pr.sh)"
263263

264264
# THEN
265265
expect "$?" "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"

0 commit comments

Comments
 (0)