Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release-latest option #6213

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

Add release-latest option #6213

wants to merge 7 commits into from

Conversation

letzya
Copy link
Collaborator

@letzya letzya commented Mar 25, 2025

User description

Preview Link

Checklist

  • Added a preview link
  • Reviewed AI PR Agent suggestions
  • For Tyk Members - Added Jira DX PR ticket to the subject
  • For Tyk Members - Added the appropriate release labels (for fixes add the latest release)

New Contributors


PR Type

  • Enhancement

Description

  • Added env var to simulate latest release branch.

  • Introduced special handling for "latest-release" label.

  • Updated if condition for release label detection.

  • Commented out GitHub create comment command.


Changes walkthrough 📝

Relevant files
Enhancement
release-to-branches-in-label.yml
Enhance workflow for special release label handling           

.github/workflows/release-to-branches-in-label.yml

  • Added TYK_LATEST_RELEASE_BRANCH env var for testing.
  • Introduced latest-release label variable.
  • Modified release label condition to include special case.
  • Added conditional comment creation with env variable.
  • +30/-8   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Syntax Error

    The conditional checking the release label appears to have a syntax error and a reference to an undeclared variable. It seems intended to compare against "latest-release" but mistakenly uses "releaseNowLabel". Please review and correct the logic.

    // Check if it's a regular release label or the special "latest-release" label
    if (labelRegex.test(label.name)) || label.name === releaseNowLabel) {
    Template Literal

    The log message uses '$commentBody' inside a template string, which will not interpolate as intended. Consider using "${commentBody}" for proper variable substitution.

    console.log(`Creating comment for label '$commentBody' on PR #${pullRequestNumber} by user '${userWhoAddedLabel}'.`);

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Fix condition syntax

    Replace the invalid syntax and undefined variable; combine the conditions and use
    the correct variable latestReleaseLabel.

    .github/workflows/release-to-branches-in-label.yml [66]

    -if (labelRegex.test(label.name)) || label.name === releaseNowLabel) {
    +if (labelRegex.test(label.name) || label.name === latestReleaseLabel) {
    Suggestion importance[1-10]: 9

    __

    Why: This suggestion fixes a clear syntax error by removing the extra parenthesis and replacing the undefined variable with the correct one, which is critical for the control flow.

    High
    Correct string interpolation

    Update the template literal to correctly interpolate commentBody using
    ${commentBody}.

    .github/workflows/release-to-branches-in-label.yml [113]

    -console.log(`Creating comment for label '$commentBody' on PR #${pullRequestNumber} by user '${userWhoAddedLabel}'.`);
    +console.log(`Creating comment for label '${commentBody}' on PR #${pullRequestNumber} by user '${userWhoAddedLabel}'.`);
    Suggestion importance[1-10]: 7

    __

    Why: The change corrects the templated string to properly interpolate the variable, ensuring accurate and informative logging.

    Medium
    General
    Correct comment syntax

    Replace hash comments with proper JavaScript comment markers or uncomment the code
    to enable the API call.

    .github/workflows/release-to-branches-in-label.yml [114-119]

    -# await github.rest.issues.createComment({
    -#   owner: context.repo.owner,
    -#   repo: context.repo.repo,
    -#   issue_number: pullRequestNumber,
    -#   body: commentBody
    -# });
    +// await github.rest.issues.createComment({
    +//   owner: context.repo.owner,
    +//   repo: context.repo.repo,
    +//   issue_number: pullRequestNumber,
    +//   body: commentBody
    +// });
    Suggestion importance[1-10]: 6

    __

    Why: Converting the incorrect hash comments to JavaScript comment markers improves code clarity and avoids potential parsing issues, although it affects non-executing lines.

    Low

    @letzya letzya marked this pull request as draft March 27, 2025 12:09
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants