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

fix: docker image ee build if neccesary #2367

Closed
wants to merge 3 commits into from

Conversation

liorzam
Copy link
Collaborator

@liorzam liorzam commented May 12, 2024

User description

Description

Elaborate on the subject, motivation, and context.

Related issues

  • Provide a link to each related issue.

Breaking changes

  • Describe the breaking changes that this pull request introduces.

How these changes were tested

  • Describe the tests that you ran to verify your changes, including devices, operating systems, browsers and versions.

Examples and references

  • Links, screenshots, and other resources related to this change.

Checklist

  • [] I have read the contribution guidelines of this project
  • [] I have read the style guidelines of this project
  • [] I have performed a self-review of my own code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings and errors
  • [] New and existing tests pass locally with my changes

PR Type

enhancement, bug_fix


Description

  • Added logic to append a dev-specific suffix to the release version when deploying to development environments, enhancing traceability and environment-specific configurations.
  • Introduced a new GitHub Actions job 'check_branch' to determine if the specified branch exists. This prevents the workflow from proceeding with non-existent branches, thus safeguarding against erroneous builds.
  • Modified the 'build-and-push-ee-image' job to depend on the new 'check_branch' job, ensuring that the build process only occurs if the branch is verified to exist.
  • Updated the 'Fetch submodule branch' step within the 'build-and-push-ee-image' job to utilize the 'skipnext' flag, which is set based on the existence of the branch, enhancing the robustness of the submodule update process.

Changes walkthrough 📝

Relevant files
Enhancement
publish-workflows-service.yml
Enhance GitHub Actions Workflow for Conditional Builds and Releases

.github/workflows/publish-workflows-service.yml

  • Added conditional logic to append a suffix to the version when
    deploying to dev.
  • Introduced a new job 'check_branch' to verify if a branch exists
    before proceeding with the build.
  • Modified 'build-and-push-ee-image' job to depend on 'check_branch' and
    only proceed if the branch exists.
  • Adjusted the 'Fetch submodule branch' step to set a 'skipnext' flag
    based on branch existence.
  • +43/-3   

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Summary by CodeRabbit

    • New Features

      • Enhanced release management with conditional logic for determining release suffix.
      • Introduced a new job to check branch existence and set an output variable accordingly.
    • Refactor

      • Updated jobs to incorporate new conditional logic and dependencies for improved workflow transitions and precise build executions.

    Copy link

    changeset-bot bot commented May 12, 2024

    ⚠️ No Changeset found

    Latest commit: 7bf1ddd

    Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

    This PR includes no changesets

    When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

    Click here to learn what changesets are, and how to add one.

    Click here if you're a maintainer who wants to add a changeset to this PR

    Copy link
    Contributor

    coderabbitai bot commented May 12, 2024

    Walkthrough

    The GitHub Actions workflow enhancements bring advanced conditional logic for release naming and branch validation. A new job verifies branch existence, influencing subsequent tasks, while the release process dynamically adjusts suffixes based on deployment configurations.

    Changes

    File Path Change Summary
    .github/workflows/publish-workflows-service.yml Added conditional logic for release suffix; introduced check_branch job; modified dependencies and conditions in build-and-push-ee-image job.

    Poem

    🐰✨
    In the matrix of code, beneath the digital sky,
    A crafty rabbit weaves workflows with a joyful sigh.
    Branches checked, releases named just right,
    Each line of code a dance in the moon's soft light.
    Oh, leap and bound, as the changes deploy,
    Woven with care, in the rabbit's paws of joy! 🌟


    Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

    Share
    Tips

    Chat

    There are 3 ways to chat with CodeRabbit:

    • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
      • I pushed a fix in commit <commit_id>.
      • Generate unit testing code for this file.
      • Open a follow-up GitHub issue for this discussion.
    • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
      • @coderabbitai generate unit testing code for this file.
      • @coderabbitai modularize this function.
    • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
      • @coderabbitai generate interesting stats about this repository and render them as a table.
      • @coderabbitai show all the console.log statements in this repository.
      • @coderabbitai read src/utils.ts and generate unit testing code.
      • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

    Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

    CodeRabbit Commands (invoked as PR comments)

    • @coderabbitai pause to pause the reviews on a PR.
    • @coderabbitai resume to resume the paused reviews.
    • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
    • @coderabbitai resolve resolve all the CodeRabbit review comments.
    • @coderabbitai help to get help.

    Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

    CodeRabbit Configration File (.coderabbit.yaml)

    • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
    • Please see the configuration documentation for more information.
    • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

    Documentation and Community

    • Visit our Documentation for detailed information on how to use CodeRabbit.
    • Join our Discord Community to get help, request features, and share feedback.
    • Follow us on X/Twitter for updates and announcements.

    @github-actions github-actions bot added enhancement New feature or request bug_fix labels May 12, 2024
    Copy link
    Contributor

    PR Description updated to latest commit (41a2d70)

    Copy link
    Contributor

    PR Review 🔍

    ⏱️ Estimated effort to review [1-5]

    3, because the PR involves multiple changes across a GitHub Actions workflow file, including conditional logic and dependency management between jobs. Understanding the impact of these changes on the CI/CD process requires a good grasp of GitHub Actions and the project's deployment workflow.

    🧪 Relevant tests

    No

    ⚡ Possible issues

    Possible Bug: The script in the 'Fetch submodule branch' step sets skipnext=true regardless of whether the branch exists or not. This could lead to unintended behaviors where subsequent steps that depend on this output might be skipped incorrectly.

    🔒 Security concerns

    No

    Code feedback:
    relevant file.github/workflows/publish-workflows-service.yml
    suggestion      

    The conditional logic for setting the skipnext flag in the 'Fetch submodule branch' step is incorrect as it sets skipnext=true in both conditions. This should be corrected to reflect the actual existence of the branch. [important]

    relevant lineecho "skipnext=true" >> $GITHUB_OUTPUT

    relevant file.github/workflows/publish-workflows-service.yml
    suggestion      

    Consider adding error handling or a failure step in the 'check_branch' job to halt the workflow explicitly if the branch does not exist, instead of just setting an output variable. This can improve the robustness and clarity of the workflow. [medium]

    relevant lineecho "skipnext=true" >> $GITHUB_OUTPUT

    relevant file.github/workflows/publish-workflows-service.yml
    suggestion      

    To enhance readability and maintainability, consider refactoring the repeated code for checking branch existence into a reusable action or script. This can reduce duplication and potential errors in multiple jobs. [medium]

    relevant lineis_exists=$(git ls-remote --exit-code --heads -t --ref -q origin "${{ github.ref_name }}" | wc -l)

    relevant file.github/workflows/publish-workflows-service.yml
    suggestion      

    Ensure that the suffix for the release version in the 'Release' job is correctly formatted. Currently, there might be a missing space before the suffix when concatenated, which could lead to incorrect version naming. [medium]

    relevant linegh release create ${{ needs.build-and-push-image.outputs.version }}${suffix} --notes-start-tag ${{ needs.build-and-push-image.outputs.bumped_tag }}

    Copy link
    Contributor

    PR Code Suggestions ✨

    CategorySuggestions                                                                                                                                                       
    Best practice
    Quote shell variables to prevent issues with special characters.

    Ensure that the suffix variable is properly quoted to prevent issues with special
    characters in the shell. This is particularly important when the variable is used in a
    command line context.

    .github/workflows/publish-workflows-service.yml [229]

    -suffix=""
    +suffix=''
     
    Use consistent quotation marks for GitHub context variables.

    Use double quotes for consistency when referencing GitHub context variables in shell
    scripts within the YAML file.

    .github/workflows/publish-workflows-service.yml [322]

    -echo "Branch '${{ github.ref_name }}' does not exist."
    +echo "Branch \"${{ github.ref_name }}\" does not exist."
     
    Maintainability
    Improve formatting by adding a space for consistency.

    Add a space between the bracket and the semicolon in the conditional check to follow best
    practices and improve readability.

    .github/workflows/publish-workflows-service.yml [280]

    -if [ $is_exists -eq 0  ]; then
    +if [ $is_exists -eq 0 ]; then
     
    Bug
    Fix the logical error in setting the skipnext variable.

    Correct the logical error in the conditional statement to ensure the skipnext variable
    reflects the correct state.

    .github/workflows/publish-workflows-service.yml [325]

    -echo "skipnext=true" >> $GITHUB_OUTPUT
    +echo "skipnext=false" >> $GITHUB_OUTPUT
     
    Enhancement
    Remove unnecessary exit statement to clean up the code.

    Remove the redundant exit 0 statement at the end of the script block, as it is unnecessary
    when the script executes successfully without errors.

    .github/workflows/publish-workflows-service.yml [327]

    -exit 0
    +# exit 0 (Removed as unnecessary)
     

    Copy link
    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.

    Actionable comments posted: 2

    Review Details

    Configuration used: CodeRabbit UI
    Review profile: CHILL

    Commits Files that changed from the base of the PR and between 0388faa and 41a2d70.
    Files selected for processing (1)
    • .github/workflows/publish-workflows-service.yml (3 hunks)
    Additional comments not posted (1)
    .github/workflows/publish-workflows-service.yml (1)

    269-287: LGTM! Good implementation of branch existence check.

    .github/workflows/publish-workflows-service.yml Outdated Show resolved Hide resolved
    Copy link
    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.

    Actionable comments posted: 1

    Review Details

    Configuration used: CodeRabbit UI
    Review profile: CHILL

    Commits Files that changed from the base of the PR and between 41a2d70 and a600a6a.
    Files selected for processing (1)
    • .github/workflows/publish-workflows-service.yml (3 hunks)

    Copy link
    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.

    Actionable comments posted: 1

    Review Details

    Configuration used: CodeRabbit UI
    Review profile: CHILL

    Commits Files that changed from the base of the PR and between a600a6a and 7bf1ddd.
    Files selected for processing (1)
    • .github/workflows/publish-workflows-service.yml (3 hunks)
    Additional comments not posted (2)
    .github/workflows/publish-workflows-service.yml (2)

    269-296: LGTM! The check_branch job correctly checks branch existence and sets the skipnext output variable.


    299-301: LGTM! The build-and-push-ee-image job correctly depends on the check_branch job and uses its output to conditionally execute.

    Comment on lines +225 to +232
    run: |
    if [ "${{ github.event.inputs.deploy_to_dev }}" == "true" ]; then
    suffix="-dev-${{ needs.build-and-push-image.outputs.sha_short }}"
    else
    suffix=""
    fi
    gh release create ${{ needs.build-and-push-image.outputs.version }}${suffix} --notes-start-tag ${{ needs.build-and-push-image.outputs.bumped_tag }}

    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    Security risk: Avoid direct interpolation of GitHub context data in scripts.

    -        run: |
    -          if [ "${{ github.event.inputs.deploy_to_dev }}" == "true" ]; then
    -            suffix="-dev-${{ needs.build-and-push-image.outputs.sha_short }}"
    -          else
    -            suffix=""
    -          fi
    -          gh release create ${{ needs.build-and-push-image.outputs.version }}${suffix} --notes-start-tag ${{ needs.build-and-push-image.outputs.bumped_tag }}
    +        env:
    +          DEPLOY_TO_DEV: ${{ github.event.inputs.deploy_to_dev }}
    +          SHA_SHORT: ${{ needs.build-and-push-image.outputs.sha_short }}
    +          VERSION: ${{ needs.build-and-push_image.outputs.version }}
    +          BUMPED_TAG: ${{ needs.build-and-push_image.outputs.bumped_tag }}
    +        run: |
    +          if [ "$DEPLOY_TO_DEV" == "true" ]; then
    +            suffix="-dev-$SHA_SHORT"
    +          else
    +            suffix=""
    +          fi
    +          gh release create "${VERSION}${suffix}" --notes-start-tag "$BUMPED_TAG"

    Committable suggestion

    ‼️ IMPORTANT
    Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

    Suggested change
    run: |
    if [ "${{ github.event.inputs.deploy_to_dev }}" == "true" ]; then
    suffix="-dev-${{ needs.build-and-push-image.outputs.sha_short }}"
    else
    suffix=""
    fi
    gh release create ${{ needs.build-and-push-image.outputs.version }}${suffix} --notes-start-tag ${{ needs.build-and-push-image.outputs.bumped_tag }}
    env:
    DEPLOY_TO_DEV: ${{ github.event.inputs.deploy_to_dev }}
    SHA_SHORT: ${{ needs.build-and-push-image.outputs.sha_short }}
    VERSION: ${{ needs.build-and-push_image.outputs.version }}
    BUMPED_TAG: ${{ needs.build-and-push_image.outputs.bumped_tag }}
    run: |
    if [ "$DEPLOY_TO_DEV" == "true" ]; then
    suffix="-dev-$SHA_SHORT"
    else
    suffix=""
    fi
    gh release create "${VERSION}${suffix}" --notes-start-tag "$BUMPED_TAG"

    @liorzam
    Copy link
    Collaborator Author

    liorzam commented May 15, 2024

    @liorzam liorzam closed this May 15, 2024
    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.

    None yet

    2 participants