@@ -160,6 +160,49 @@ 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: ${BASH_REMATCH[0]}"
199
+ else
200
+ echo "❌ No Jira key found"
201
+ exit 1
202
+ fi
203
+
204
+
205
+
163
206
lint-commit-messages :
164
207
needs : determine-test-scope
165
208
runs-on : ubuntu-latest
@@ -515,7 +558,7 @@ jobs:
515
558
(( needs.determine-test-scope.outputs.pr_approval_state == 'true' ) &&
516
559
( needs.determine-test-scope.outputs.local_tests == 'true' ) ||
517
560
( needs.determine-test-scope.outputs.remote_tests == 'true' ))
518
- needs : [local-tests, remote-tests, lint, verify-schema-change, lint-commit-messages]
561
+ needs : [local-tests, remote-tests, lint, verify-schema-change, lint-commit-messages, lint-branch-name ]
519
562
runs-on : ubuntu-latest
520
563
steps :
521
564
- name : check-passing-remote-tests
@@ -540,5 +583,8 @@ jobs:
540
583
elif [[ github.event_name == 'merge_group' && "${{ needs.lint-commit-messages.result }}" != 'success' ]]; then
541
584
echo "❌ Linting of commit messages failed or was skipped."
542
585
exit 1
586
+ elif [[ github.event_name == 'pull_request' && "${{ needs.lint-branch-name.result }}" != 'success' ]]; then
587
+ echo "❌ Linting of branch name failed."
588
+ exit 1
543
589
fi
544
590
echo "✅ All required test jobs passed!"
0 commit comments