@@ -160,6 +160,54 @@ jobs:
160160 - name : Run ruff check
161161 run : ruff check tidy3d
162162
163+ lint-branch-name :
164+ needs : determine-test-scope
165+ runs-on : ubuntu-latest
166+ name : lint-branch-name
167+ env :
168+ PR_TITLE : ${{ github.event.pull_request.title }}
169+ if : github.event_name == 'pull_request'
170+ steps :
171+ - name : extract-branch-name
172+ id : extract-branch-name
173+ run : |
174+ BRANCH_NAME="${{ github.head_ref }}"
175+ echo "Branch name: $BRANCH_NAME"
176+ echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
177+
178+ - name : enforce-jira-key
179+ id : enforce-jira-key
180+ run : |
181+ BRANCH_NAME="${{ steps.extract-branch-name.outputs.branch_name }}"
182+ echo $BRANCH_NAME
183+ JIRA_PATTERN='[A-Z]{2,}-[0-9]+'
184+
185+ # List of exempt prefixes (case-insensitive)
186+ EXEMPT_PREFIXES=("chore" "hotfix" "daily-chore")
187+
188+ # Convert branch name to lowercase for comparison
189+ BRANCH_LOWER=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]')
190+
191+ # Check if branch starts with any exempt prefix
192+ for prefix in "${EXEMPT_PREFIXES[@]}"; do
193+ if [[ "$BRANCH_LOWER" == $prefix* ]]; then
194+ echo "ℹ️ Branch starts with '$prefix' - Jira key not required"
195+ exit 0
196+ fi
197+ done
198+
199+ if [[ "$BRANCH_NAME" =~ $JIRA_PATTERN ]]; then
200+ echo "✅ Jira key found in branch name: ${BASH_REMATCH[0]}"
201+ else
202+ echo "❌ No Jira key found in branch name, checking PR name as fallback"
203+ if [[ "$PR_TITLE" =~ $JIRA_PATTERN ]]; then
204+ echo "✅ Jira key found in PR-title: ${BASH_REMATCH[0]}"
205+ else
206+ echo "❌ No Jira key found in branch name and PR title"
207+ exit 1
208+ fi
209+ fi
210+
163211 lint-commit-messages :
164212 needs : determine-test-scope
165213 runs-on : ubuntu-latest
@@ -515,7 +563,7 @@ jobs:
515563 (( needs.determine-test-scope.outputs.pr_approval_state == 'true' ) &&
516564 ( needs.determine-test-scope.outputs.local_tests == 'true' ) ||
517565 ( needs.determine-test-scope.outputs.remote_tests == 'true' ))
518- needs : [local-tests, remote-tests, lint, verify-schema-change, lint-commit-messages]
566+ needs : [local-tests, remote-tests, lint, verify-schema-change, lint-commit-messages, lint-branch-name ]
519567 runs-on : ubuntu-latest
520568 steps :
521569 - name : check-passing-remote-tests
@@ -537,5 +585,8 @@ jobs:
537585 elif [[ "${{ github.event_name }}" == 'merge_group' && "${{ needs.lint-commit-messages.result }}" != 'success' ]]; then
538586 echo "❌ Linting of commit messages failed or was skipped."
539587 exit 1
588+ elif [[ "${{ github.event_name }}" == 'pull_request' && "${{ needs.lint-branch-name.result }}" != 'success' ]]; then
589+ echo "❌ Linting of branch name failed."
590+ exit 1
540591 fi
541592 echo "✅ All required test jobs passed!"
0 commit comments