@@ -160,6 +160,54 @@ jobs:
160
160
- name : Run ruff check
161
161
run : ruff check tidy3d
162
162
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")
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
+
163
211
lint-commit-messages :
164
212
needs : determine-test-scope
165
213
runs-on : ubuntu-latest
@@ -515,7 +563,7 @@ jobs:
515
563
(( needs.determine-test-scope.outputs.pr_approval_state == 'true' ) &&
516
564
( needs.determine-test-scope.outputs.local_tests == 'true' ) ||
517
565
( 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 ]
519
567
runs-on : ubuntu-latest
520
568
steps :
521
569
- name : check-passing-remote-tests
@@ -540,5 +588,8 @@ jobs:
540
588
elif [[ github.event_name == 'merge_group' && "${{ needs.lint-commit-messages.result }}" != 'success' ]]; then
541
589
echo "❌ Linting of commit messages failed or was skipped."
542
590
exit 1
591
+ elif [[ "${{ github.event_name }}" == 'pull_request' && "${{ needs.lint-branch-name.result }}" != 'success' ]]; then
592
+ echo "❌ Linting of branch name failed."
593
+ exit 1
543
594
fi
544
595
echo "✅ All required test jobs passed!"
0 commit comments