Skip to content

Conversation

@dlabrecq
Copy link
Contributor

@dlabrecq dlabrecq commented Nov 19, 2025

Adds a prefix in tag workflow, helping to identify tags for each app

Summary by Sourcery

Update the GitHub tag release workflow to include an application-specific prefix in tag names by parsing the branch name, and correct branch reference and minor version extraction.

Enhancements:

  • Parse the application prefix from the branch name and include it in the release tag format.

CI:

  • Switch to using github.ref for branch detection.
  • Fix minor version extraction by echoing the previous release into cut.
  • Update git log invocation to use the parsed branch base.

@dlabrecq dlabrecq requested a review from a team as a code owner November 19, 2025 20:31
@gemini-code-assist
Copy link
Contributor

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 19, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Enhances the tag_release workflow to automatically extract an application-specific prefix from the branch name and incorporate it into the release tag, while refining branch resolution and version parsing.

Flow diagram for tag prefix extraction and tag creation

flowchart TD
    A["Get branch name from github.ref"]
    B["Extract branch base (3rd segment)"]
    C["Extract app prefix (2nd segment after '-')"]
    D["Get previous release tag"]
    E["Parse minor version"]
    F["Increment minor version if needed"]
    G["Build tag: r-<app_prefix>.<date>.<minor_version>"]
    H["Tag and push to origin"]
    A --> B --> C --> G
    D --> E --> F --> G
    G --> H
Loading

File-Level Changes

Change Details Files
Enhanced branch handling to derive application prefix
  • Switched BRANCH env var source from github.base_ref to github.ref
  • Parsed BRANCH_BASE from the full branch ref
  • Extracted APP_PREFIX from BRANCH_BASE
  • Updated git log range to use BRANCH_BASE instead of base_ref
.github/workflows/tag_release.yml
Refined version extraction and tag formatting
  • Changed MINOR_VERSION extraction to use command substitution
  • Modified TAG format to r-{app_prefix}.{date}.{minor_version}
  • Replaced original dot-only prefix with hyphen-separated app prefix
.github/workflows/tag_release.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@dlabrecq dlabrecq changed the title Adds a prefix to tag workflow Adds tag workflow prefix Nov 19, 2025
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Instead of manually parsing github.ref, consider using github.ref_name to get the branch name directly and avoid brittle split logic.
  • The APP_PREFIX extraction with cut -d'-' -f2 assumes a single hyphen in branch names—add validation or a fallback for branches that don’t follow that pattern.
  • Using git tag --list | tail -1 may not reliably pick the latest tag; consider sorting tags by version or date before selecting the most recent.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Instead of manually parsing github.ref, consider using github.ref_name to get the branch name directly and avoid brittle split logic.
- The APP_PREFIX extraction with cut -d'-' -f2 assumes a single hyphen in branch names—add validation or a fallback for branches that don’t follow that pattern.
- Using git tag --list | tail -1 may not reliably pick the latest tag; consider sorting tags by version or date before selecting the most recent.

## Individual Comments

### Comment 1
<location> `.github/workflows/tag_release.yml:28-29` </location>
<code_context>
           case $PREV_RELEASE in
             *"$DATE"*)
-              MINOR_VERSION="$PREV_RELEASE" | cut -d'.' -f5
+              MINOR_VERSION=$(echo "$PREV_RELEASE" | cut -d'.' -f5)
               MINOR_VERSION=$((MINOR_VERSION+1))
               ;;
             *)
</code_context>

<issue_to_address>
**suggestion:** Subshell assignment for MINOR_VERSION improves correctness, but check for empty or non-numeric values.

Add a check to ensure MINOR_VERSION is numeric before performing arithmetic expansion to prevent potential failures.

```suggestion
              MINOR_VERSION=$(echo "$PREV_RELEASE" | cut -d'.' -f5)
              # Ensure MINOR_VERSION is numeric and not empty
              if ! [[ "$MINOR_VERSION" =~ ^[0-9]+$ ]]; then
                MINOR_VERSION=0
              fi
              MINOR_VERSION=$((MINOR_VERSION+1))
```
</issue_to_address>

### Comment 2
<location> `.github/workflows/tag_release.yml:35-37` </location>
<code_context>
               ;;
           esac
-          TAG="r.$DATE.$MINOR_VERSION"
+          BRANCH_BASE=$( echo $BRANCH | cut -d'/' -f3)
+          APP_PREFIX=$(echo "$BRANCH_BASE" | cut -d'-' -f2)
+          TAG="r-$APP_PREFIX.$DATE.$MINOR_VERSION"
           git config --local user.email "[email protected]"
</code_context>

<issue_to_address>
**suggestion:** Parsing branch and app prefix assumes a specific branch naming convention.

This logic may fail if branch names deviate from the expected format. Please add validation or error handling for unexpected branch name structures.

```suggestion
          # Validate branch structure
          BRANCH_PARTS=$(echo "$BRANCH" | awk -F'/' '{print NF}')
          if [ "$BRANCH_PARTS" -lt 3 ]; then
            echo "Error: BRANCH variable '$BRANCH' does not have at least three '/'-separated components."
            exit 1
          fi
          BRANCH_BASE=$( echo $BRANCH | cut -d'/' -f3)
          APP_PREFIX_PARTS=$(echo "$BRANCH_BASE" | awk -F'-' '{print NF}')
          if [ "$APP_PREFIX_PARTS" -lt 2 ]; then
            echo "Error: BRANCH_BASE variable '$BRANCH_BASE' does not have at least two '-' separated components."
            exit 1
          fi
          APP_PREFIX=$(echo "$BRANCH_BASE" | cut -d'-' -f2)
          TAG="r-$APP_PREFIX.$DATE.$MINOR_VERSION"
```
</issue_to_address>

### Comment 3
<location> `.github/workflows/tag_release.yml:40` </location>
<code_context>
           git config --local user.email "[email protected]"
           git config --local user.name "Cost Management Release Action"
-          git log $(git tag --list | tail -1)..${{ env.BRANCH }} | git tag -a $TAG -F -
+          git log $(git tag --list | tail -1)..$BRANCH_BASE | git tag -a $TAG -F -
           git push origin $TAG
         shell: bash
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Using $BRANCH_BASE instead of full branch ref may cause issues if branch names are ambiguous.

If $BRANCH_BASE is not unique, git log and tag operations may yield incorrect results. Use the full branch ref or ensure $BRANCH_BASE is unique.

```suggestion
          git log $(git tag --list | tail -1)..$BRANCH | git tag -a $TAG -F -
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.07%. Comparing base (4e35c2c) to head (72ad5d4).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4691   +/-   ##
=======================================
  Coverage   87.07%   87.07%           
=======================================
  Files         480      480           
  Lines        9078     9078           
  Branches     2197     2195    -2     
=======================================
  Hits         7905     7905           
  Misses       1107     1107           
  Partials       66       66           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dlabrecq dlabrecq merged commit 89f6129 into project-koku:main Nov 19, 2025
9 checks passed
@dlabrecq dlabrecq deleted the tag branch November 19, 2025 21:04
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