@@ -160,6 +160,52 @@ 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
+ if : github.event_name == 'pull_request'
168
+ steps :
169
+ - name : extract-branch-name
170
+ id : extract-branch-name
171
+ run : |
172
+ BRANCH_NAME="${{ github.head_ref }}"
173
+ echo "Branch name: $BRANCH_NAME"
174
+ echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
175
+
176
+ - name : enforce-jira-key
177
+ id : enforce-jira-key
178
+ run : |
179
+ BRANCH_NAME="${{ steps.extract-branch-name.outputs.branch_name }}"
180
+ echo $BRANCH_NAME
181
+ JIRA_PATTERN='[A-Z]{2,}-[0-9]+'
182
+
183
+ # List of exempt prefixes (case-insensitive)
184
+ EXEMPT_PREFIXES=("chore" "hotfix")
185
+
186
+ # Convert branch name to lowercase for comparison
187
+ BRANCH_LOWER=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]')
188
+
189
+ # Check if branch starts with any exempt prefix
190
+ for prefix in "${EXEMPT_PREFIXES[@]}"; do
191
+ if [[ "$BRANCH_LOWER" == $prefix* ]]; then
192
+ echo "ℹ️ Branch starts with '$prefix' - Jira key not required"
193
+ exit 0
194
+ fi
195
+ done
196
+
197
+ if [[ "$BRANCH_NAME" =~ $JIRA_PATTERN ]]; then
198
+ echo "✅ Jira key found in branch name: ${BASH_REMATCH[0]}"
199
+ else
200
+ echo "❌ No Jira key found in branch name, checking PR name as fallback"
201
+ if [[ "${{ github.event.pull_request.title }}" =~ $JIRA_PATTERN]]; then
202
+ echo "✅ Jira key found in PR-title: ${BASH_REMATCH[0]}"
203
+ else
204
+ echo "❌ No Jira key found in branch name and PR title"
205
+ exit 1
206
+ fi
207
+ fi
208
+
163
209
lint-commit-messages :
164
210
needs : determine-test-scope
165
211
runs-on : ubuntu-latest
@@ -515,7 +561,7 @@ jobs:
515
561
(( needs.determine-test-scope.outputs.pr_approval_state == 'true' ) &&
516
562
( needs.determine-test-scope.outputs.local_tests == 'true' ) ||
517
563
( needs.determine-test-scope.outputs.remote_tests == 'true' ))
518
- needs : [local-tests, remote-tests, lint, verify-schema-change, lint-commit-messages]
564
+ needs : [local-tests, remote-tests, lint, verify-schema-change, lint-commit-messages, lint-branch-name ]
519
565
runs-on : ubuntu-latest
520
566
steps :
521
567
- name : check-passing-remote-tests
@@ -540,5 +586,8 @@ jobs:
540
586
elif [[ github.event_name == 'merge_group' && "${{ needs.lint-commit-messages.result }}" != 'success' ]]; then
541
587
echo "❌ Linting of commit messages failed or was skipped."
542
588
exit 1
589
+ elif [[ "${{ github.event_name }}" == 'pull_request' && "${{ needs.lint-branch-name.result }}" != 'success' ]]; then
590
+ echo "❌ Linting of branch name failed."
591
+ exit 1
543
592
fi
544
593
echo "✅ All required test jobs passed!"
0 commit comments