Skip to content

TECH_DEBT: Normalize branch names in pipelines#1485

Open
seanmcilvenna wants to merge 1 commit intodevfrom
tech_debt/azure-pipelines-release-branch-fix
Open

TECH_DEBT: Normalize branch names in pipelines#1485
seanmcilvenna wants to merge 1 commit intodevfrom
tech_debt/azure-pipelines-release-branch-fix

Conversation

@seanmcilvenna
Copy link
Copy Markdown
Contributor

@seanmcilvenna seanmcilvenna commented Mar 5, 2026

🛠️ Description of Changes

Normalize branch names in pipelines by replacing forward slashes with hyphens for consistency in tags and image names. Update list-deploy-changes.py to include per-service version comparisons and warnings for non-incremented versions.

🧪 Testing Performed

Please describe the testing that was performed on the changes included in this PR.

🧑‍🔬 Unit Testing

  • I have written or updated unit tests to cover my changes
  • Coverage: 0.0%

📓 Documentation Updated

Please update any relevant sections in the project documentation that were impacted by the changes in the PR.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added service versioning tracking to deployment change reports, including per-service version-increment warnings.
  • Chores

    • Updated container image tagging across all deployment pipelines to use sanitized branch names (slashes replaced with dashes) for improved container registry compatibility.

@seanmcilvenna seanmcilvenna requested a review from kissalk March 5, 2026 21:45
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 5, 2026

📝 Walkthrough

Walkthrough

Standardizes image tagging across 17 Azure Pipeline deployment files by introducing a CLEANED_BRANCH_NAME variable that sanitizes Git branch names by replacing slashes with dashes, ensuring Docker image tags contain no path separators. Enhances a Python deployment script with version extraction and comparison logic to report service versioning changes.

Changes

Cohort / File(s) Summary
Azure Pipeline CD Files (Branch Name Sanitization)
Azure_Pipelines/azure-pipelines.account.cd.yaml, azure-pipelines.admin-ui.cd.yaml, azure-pipelines.admin.cd.yaml, azure-pipelines.audit.cd.yaml, azure-pipelines.census.cd.yaml, azure-pipelines.dataacquisition-worker.cd.yaml, azure-pipelines.dataacquisition.cd.yaml, azure-pipelines.ec.cd.yaml, azure-pipelines.measureeval.cd.yaml, azure-pipelines.normalization.cd.yaml, azure-pipelines.querydispatch.cd.yaml, azure-pipelines.report.cd.yaml, azure-pipelines.submission.cd.yaml, azure-pipelines.tenant.cd.yaml, azure-pipelines.terminology.cd.yaml, azure-pipelines.validation.cd.yaml
Each file adds Bash script to derive CLEANED_BRANCH_NAME by replacing slashes with dashes in Build.SourceBranchName, exports as pipeline variable, and updates subsequent PowerShell tag generation logic to use the cleaned variable in both release and non-release branches for MyTag construction.
Additional Azure Pipeline Files
Azure_Pipelines/_deploy_all_services.yml, deploy_tags_all.yml
Apply the same CLEANED_BRANCH_NAME sanitization and tag generation pattern; _deploy_all_services.yml updates Kubernetes image-push command to use cleaned branch name in image tag; deploy_tags_all.yml applies pattern across multiple job definitions.
Deployment Analysis Script
Scripts/list-deploy-changes.py
Adds version extraction functions (get_file_version, version_to_tuple) to read and parse version info from CSProj and Maven POM files at specified git references. Integrates version-aware analysis into deployment diff flow, computing per-service versions and emitting warnings when service versions do not increment between git references.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested labels

config-change

Suggested reviewers

  • michael-misiaszek

Poem

🐰 A rabbit hops through branches clean,
Slashes transformed to dashes keen!
Version tales now sing so sweet,
Tagged and tracked, the flow complete!
Sanitized names in pipelines gleam. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'TECH_DEBT: Normalize branch names in pipelines' accurately summarizes the main change across the PR: normalizing branch names by replacing slashes with hyphens in pipeline files.
Description check ✅ Passed The PR description covers the main changes and follows the template structure. However, the 'Testing Performed' section is incomplete (contains placeholder text), and 'Documentation Updated' section is also incomplete with no actual documentation updates described.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tech_debt/azure-pipelines-release-branch-fix

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

… hyphens for consistency in tags and image names. Update `list-deploy-changes.py` to include per-service version comparisons and warnings for non-incremented versions.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (4)
Azure_Pipelines/azure-pipelines.terminology.cd.yaml (1)

95-102: Duplicate MyTag assignment — consider consolidating.

Both PowerShell blocks (lines 66-77 and 91-102) set MyTag with identical logic. The second block overwrites the first. This is pre-existing, but worth consolidating in a future cleanup to avoid confusion.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Azure_Pipelines/azure-pipelines.terminology.cd.yaml` around lines 95 - 102,
The MyTag variable is being set twice with identical logic (based on
Build.SourceBranch, CLEANED_BRANCH_NAME and GIT_COMMIT), causing the second
assignment to overwrite the first; remove the duplicate block and keep a single
consolidated PowerShell block that computes $myTag1 using the conditional on
"$(Build.SourceBranch)" -like "*release/*" and then sets the pipeline variable
via Write-Host "##vso[task.setvariable variable=MyTag]$myTag1" and logs "Set
MyTag to: $myTag1" so the logic for MyTag (references: MyTag, $myTag1,
CLEANED_BRANCH_NAME, GIT_COMMIT, Build.SourceBranch) exists only once.
Scripts/list-deploy-changes.py (3)

74-117: Consider narrowing exception handlers for better debuggability.

The broad except Exception blocks (lines 89, 110) will silently swallow unexpected errors during XML parsing. While the fallback to regex is a good safety net, catching more specific exceptions (e.g., ET.ParseError, AttributeError) would help surface unexpected issues during development.

Additionally, static analysis flags that xml.etree.ElementTree can be vulnerable to XML attacks (S314). Since the content comes from git refs within the repository, the risk is low, but consider using defusedxml if this script ever processes external input.

🔧 Optional: Narrow exception handling
             try:
                 root = ET.fromstring(content)
                 # In .csproj, Version is usually in a PropertyGroup
                 v = root.find(".//Version")
                 if v is not None and v.text:
                     return v.text.strip()
-            except Exception:
+            except (ET.ParseError, AttributeError):
                 # Fallback to regex
                 match = re.search(r"<Version>(.*?)</Version>", content)
                 if match:
                     return match.group(1).strip()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Scripts/list-deploy-changes.py` around lines 74 - 117, The get_file_version
function currently uses broad "except Exception" handlers around XML parsing;
narrow these to catch specific parsing errors (e.g.,
xml.etree.ElementTree.ParseError) and any attribute-related errors (e.g.,
AttributeError) instead of Exception for both the .csproj and pom.xml branches,
so genuine unexpected errors aren't silently swallowed; optionally, if you want
safer XML parsing for external inputs, switch to defusedxml.ElementTree (or
parse via defusedxml) and update the exception types accordingly (reference the
function get_file_version and the try/except blocks surrounding ET.fromstring
and the subsequent XML find logic).

232-232: Use proper type annotation instead of comment.

The inline comment # Dict[str, List[str]] should be a type annotation for consistency with the type hints elsewhere in this file.

🔧 Suggested fix
-    version_to_services = {} # Dict[str, List[str]]
+    version_to_services: dict[str, list[str]] = {}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Scripts/list-deploy-changes.py` at line 232, The variable version_to_services
is using a comment for its type; replace the inline comment with a proper type
annotation (e.g., version_to_services: Dict[str, List[str]] = {} or, if the file
uses modern annotations, version_to_services: dict[str, list[str]] = {}) and
ensure the corresponding typing imports are present (add from typing import
Dict, List if using Dict/List form) so the annotation matches the style used
elsewhere in the file.

119-124: Add more specific type hint for clarity.

The return type Tuple is generic. Consider specifying the content type for better IDE support and documentation.

🔧 Suggested type hint improvement
-def version_to_tuple(v: str) -> Tuple:
+def version_to_tuple(v: str) -> Tuple[int, ...]:
     """Convert version string to a tuple of integers for comparison."""
     try:
         return tuple(int(p) for p in re.findall(r'\d+', v))
-    except Exception:
+    except (ValueError, TypeError):
         return (v,)

Note: If keeping the string fallback (v,), the return type would need to be Tuple[int, ...] | Tuple[str] or tuple to be accurate.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Scripts/list-deploy-changes.py` around lines 119 - 124, The return type of
version_to_tuple is currently the generic Tuple; update its type hint to reflect
that it returns either a tuple of ints or a single-string tuple (e.g., change to
Tuple[int, ...] | Tuple[str] or the equivalent tuple[int, ...] | tuple[str]
depending on your Python typing target) and update the function signature of
version_to_tuple(v: str) accordingly so IDEs and linters can infer the correct
element types when it returns the parsed int tuple or the fallback (v,) string
tuple.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Azure_Pipelines/azure-pipelines.terminology.cd.yaml`:
- Around line 95-102: The MyTag variable is being set twice with identical logic
(based on Build.SourceBranch, CLEANED_BRANCH_NAME and GIT_COMMIT), causing the
second assignment to overwrite the first; remove the duplicate block and keep a
single consolidated PowerShell block that computes $myTag1 using the conditional
on "$(Build.SourceBranch)" -like "*release/*" and then sets the pipeline
variable via Write-Host "##vso[task.setvariable variable=MyTag]$myTag1" and logs
"Set MyTag to: $myTag1" so the logic for MyTag (references: MyTag, $myTag1,
CLEANED_BRANCH_NAME, GIT_COMMIT, Build.SourceBranch) exists only once.

In `@Scripts/list-deploy-changes.py`:
- Around line 74-117: The get_file_version function currently uses broad "except
Exception" handlers around XML parsing; narrow these to catch specific parsing
errors (e.g., xml.etree.ElementTree.ParseError) and any attribute-related errors
(e.g., AttributeError) instead of Exception for both the .csproj and pom.xml
branches, so genuine unexpected errors aren't silently swallowed; optionally, if
you want safer XML parsing for external inputs, switch to defusedxml.ElementTree
(or parse via defusedxml) and update the exception types accordingly (reference
the function get_file_version and the try/except blocks surrounding
ET.fromstring and the subsequent XML find logic).
- Line 232: The variable version_to_services is using a comment for its type;
replace the inline comment with a proper type annotation (e.g.,
version_to_services: Dict[str, List[str]] = {} or, if the file uses modern
annotations, version_to_services: dict[str, list[str]] = {}) and ensure the
corresponding typing imports are present (add from typing import Dict, List if
using Dict/List form) so the annotation matches the style used elsewhere in the
file.
- Around line 119-124: The return type of version_to_tuple is currently the
generic Tuple; update its type hint to reflect that it returns either a tuple of
ints or a single-string tuple (e.g., change to Tuple[int, ...] | Tuple[str] or
the equivalent tuple[int, ...] | tuple[str] depending on your Python typing
target) and update the function signature of version_to_tuple(v: str)
accordingly so IDEs and linters can infer the correct element types when it
returns the parsed int tuple or the fallback (v,) string tuple.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 38fbd908-4d4d-4616-a66a-fd8fd87d202d

📥 Commits

Reviewing files that changed from the base of the PR and between 3042640 and 7865f01.

📒 Files selected for processing (19)
  • Azure_Pipelines/_deploy_all_services.yml
  • Azure_Pipelines/azure-pipelines.account.cd.yaml
  • Azure_Pipelines/azure-pipelines.admin-ui.cd.yaml
  • Azure_Pipelines/azure-pipelines.admin.cd.yaml
  • Azure_Pipelines/azure-pipelines.audit.cd.yaml
  • Azure_Pipelines/azure-pipelines.census.cd.yaml
  • Azure_Pipelines/azure-pipelines.dataacquisition-worker.cd.yaml
  • Azure_Pipelines/azure-pipelines.dataacquisition.cd.yaml
  • Azure_Pipelines/azure-pipelines.ec.cd.yaml
  • Azure_Pipelines/azure-pipelines.measureeval.cd.yaml
  • Azure_Pipelines/azure-pipelines.normalization.cd.yaml
  • Azure_Pipelines/azure-pipelines.querydispatch.cd.yaml
  • Azure_Pipelines/azure-pipelines.report.cd.yaml
  • Azure_Pipelines/azure-pipelines.submission.cd.yaml
  • Azure_Pipelines/azure-pipelines.tenant.cd.yaml
  • Azure_Pipelines/azure-pipelines.terminology.cd.yaml
  • Azure_Pipelines/azure-pipelines.validation.cd.yaml
  • Azure_Pipelines/deploy_tags_all.yml
  • Scripts/list-deploy-changes.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant