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

Use the released tag version to identify newly-created docker images #592

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

m-Peter
Copy link
Collaborator

@m-Peter m-Peter commented Sep 26, 2024

Closes: #489

Description

The new docker image URL will include the released tag version, instead of a git commit hash, e.g.:

us-west1-docker.pkg.dev/dl-flow-devex-production/development/flow-evm-gateway:v0.36.3

For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the standards mentioned here.
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

Summary by CodeRabbit

Summary by CodeRabbit

  • Chores
    • Updated the Docker build process to utilize a new environment variable for versioning.
    • Streamlined the versioning mechanism for Docker images by referencing Git tags.
    • Added a new step to set the gateway version, enhancing clarity and maintainability of the build workflow.

@m-Peter m-Peter added this to the Flow-EVM-M2 milestone Sep 26, 2024
@m-Peter m-Peter self-assigned this Sep 26, 2024
Copy link
Contributor

coderabbitai bot commented Sep 26, 2024

Walkthrough

The changes in this pull request involve updates to the .github/workflows/build.yml file, specifically focusing on the Docker build process. An environment variable GATEWAY_VERSION has been introduced to capture the latest Git tag, while the DOCKER_IMAGE_URL has been modified to reference this new variable instead of the Git SHA, enhancing the versioning mechanism for Docker images.

Changes

File Change Summary
.github/workflows/build.yml Added GATEWAY_VERSION variable and updated DOCKER_IMAGE_URL to use it.

Assessment against linked issues

Objective Addressed Explanation
Version docker images (#489)

Possibly related PRs

Suggested labels

Feature

Poem

🐰 In the garden where the code does grow,
A version tag now steals the show.
With Docker's image, clear and bright,
Our builds will shine, a lovely sight!
Hopping forward, we embrace the change,
In the world of code, we rearrange! 🌼


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

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 d5b8984 and 145578f.

📒 Files selected for processing (1)
  • .github/workflows/build.yml (2 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/build.yml

10-10: context "env" is not allowed here. available contexts are "github", "inputs", "secrets", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details

(expression)

🔇 Additional comments (1)
.github/workflows/build.yml (1)

Line range hint 1-40: Overall assessment: Changes align with PR objectives

The modifications to this workflow file effectively implement a versioning system for Docker images using Git tags, which aligns well with the PR objectives and addresses the issue raised in #489. Once the suggested corrections are applied, this solution will:

  1. Use the latest Git tag as the version for the Docker image.
  2. Ensure that the Docker image is built and tagged with this version.
  3. Push the versioned image to the repository.

This approach should resolve the issue of users being unable to pull the onflow/flow-evm-gateway image from Docker Hub by providing clearly versioned images.

To further improve the workflow and ensure it meets all requirements:

  1. Consider adding a step to validate that a tag exists before proceeding with the build.
  2. Add error handling for cases where no tags are found.
  3. Include a step to output the built image details (repository and tag) for easy reference in the workflow summary.

These additional steps will enhance the robustness and usability of the workflow.

🧰 Tools
🪛 actionlint

10-10: context "env" is not allowed here. available contexts are "github", "inputs", "secrets", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details

(expression)

@m-Peter m-Peter force-pushed the versioned-docker-images branch from 145578f to ad3d5af Compare September 26, 2024 12:41
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 145578f and ad3d5af.

📒 Files selected for processing (1)
  • .github/workflows/build.yml (3 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/build.yml

25-25: shellcheck reported issue in this script: SC2086:info:1:73: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (3)
.github/workflows/build.yml (3)

9-9: LGTM: Environment variable simplification

The simplification of the DOCKER_IMAGE_URL environment variable is a good change. It now correctly uses the vars context to set the Docker image URL, which aligns with the PR objective of using released tag versions for Docker images. This change also resolves the previous issue of using the env context in the global env section.


Line range hint 1-44: Summary: PR objectives achieved with minor improvements needed

This PR successfully addresses the main objective of using released tag versions to identify newly-created Docker images. The changes in the workflow file improve the versioning process and simplify the Docker image URL, which should resolve the issues mentioned in the linked GitHub issue #489.

Key improvements:

  1. Simplified DOCKER_IMAGE_URL definition.
  2. Added a step to set GATEWAY_VERSION based on Git tags.
  3. Updated Docker build and push commands to use the GATEWAY_VERSION.

These changes should allow users to pull the onflow/flow-evm-gateway image from Docker Hub without encountering access problems, as the images will now be properly versioned and pushed to the repository.

To fully complete the PR objectives:

  1. Apply the suggested quoting fix in the "Set Gateway Version" step.
  2. Run the verification script to ensure consistent usage of GATEWAY_VERSION.
  3. Update the Dockerfile (if not already done) to use the GATEWAY_VERSION build argument.

Once these minor improvements are implemented, this PR will be ready for merge, effectively addressing the versioning issue for Docker images.

🧰 Tools
🪛 actionlint

25-25: shellcheck reported issue in this script: SC2086:info:1:73: Double quote to prevent globbing and word splitting

(shellcheck)


43-44: Approve: Docker build and push commands updated correctly

The changes to the Docker build and push commands are well-implemented. They correctly use the GATEWAY_VERSION from the step output for both tagging the image and as a build argument. This approach ensures consistency in versioning throughout the build process and aligns with the PR objective of using released tag versions for Docker images.

To ensure these changes have the intended effect across the workflow, let's verify the usage of GATEWAY_VERSION:

This script will help confirm that the GATEWAY_VERSION is used consistently in the workflow and that the Dockerfile is prepared to receive and use this build argument.

@m-Peter m-Peter force-pushed the versioned-docker-images branch from 7701506 to b679e52 Compare September 26, 2024 13:02
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: 0

🧹 Outside diff range and nitpick comments (1)
.github/workflows/build.yml (1)

23-25: Approve with minor suggestion: Gateway Version setting step

Great addition of the "Set Gateway Version" step. This correctly addresses the issue raised in past comments by setting the version in a step rather than in the global env. The use of git describe aligns well with the PR objective of using released tag versions for Docker images.

To address the static analysis hint and further improve robustness, consider updating the command with proper quoting:

run: echo "GATEWAY_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo 'unknown')" >> "$GITHUB_OUTPUT"

This change adds quotes around the $GITHUB_OUTPUT variable, preventing potential issues with word splitting or globbing.

🧰 Tools
🪛 actionlint

25-25: shellcheck reported issue in this script: SC2086:info:1:91: Double quote to prevent globbing and word splitting

(shellcheck)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ad3d5af and b679e52.

📒 Files selected for processing (1)
  • .github/workflows/build.yml (3 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/build.yml

25-25: shellcheck reported issue in this script: SC2086:info:1:91: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (3)
.github/workflows/build.yml (3)

9-9: LGTM: Simplified Docker image URL

The change to DOCKER_IMAGE_URL aligns well with the PR objective of using released tag versions for Docker images. By removing the Git SHA and using only the REPO_DOCKER_IMAGE_URL variable, we've simplified the image URL definition, which should help address the issues mentioned in #489.


Line range hint 1-44: Summary: Excellent progress on implementing released tag versions for Docker images

The changes made in this file significantly contribute to resolving the issues mentioned in #489 and align well with the PR objectives. Here's a summary of the improvements:

  1. Simplified DOCKER_IMAGE_URL definition
  2. Added a robust step to set the GATEWAY_VERSION based on Git tags
  3. Updated Docker build and push commands to use the GATEWAY_VERSION consistently

These changes should address the inability to pull the onflow/flow-evm-gateway image from Docker Hub by implementing a clear versioning system based on Git tags. The new approach should make it easier for users to access and manage the correct image versions.

Great work on implementing these changes! Once the minor suggestion for quoting in the "Set Gateway Version" step is addressed, this PR will be in excellent shape to merge.

🧰 Tools
🪛 actionlint

25-25: shellcheck reported issue in this script: SC2086:info:1:91: Double quote to prevent globbing and word splitting

(shellcheck)


43-44: LGTM: Correct usage of GATEWAY_VERSION in Docker commands

The changes to the Docker build and push commands look great. They correctly use the GATEWAY_VERSION from the set_version step, both for tagging the image and as a build argument. This aligns perfectly with the PR objective of using released tag versions for Docker images and addresses the recommendations from past comments.

These modifications should help resolve the issue of pulling the correct image version mentioned in #489, as the image tag now consistently uses the Git tag version.

To ensure the changes are working as expected, you can run the following verification script:

✅ Verification successful

Verification Complete: GATEWAY_VERSION usage in Docker commands confirmed

All Docker build and push commands correctly utilize the GATEWAY_VERSION from the set_version step. This aligns with the PR objective of using released tag versions for Docker images and addresses issue #489.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the Docker image URL and tag format

# Test: Check if the Docker image URL and tag format match the expected pattern
rg --type yaml 'docker build -t \$\{\{ env\.DOCKER_IMAGE_URL \}\}:\$\{\{ steps\.set_version\.outputs\.GATEWAY_VERSION \}\}'

# Test: Ensure the GATEWAY_VERSION is used as a build argument
rg --type yaml '--build-arg GATEWAY_VERSION=\$\{\{ steps\.set_version\.outputs\.GATEWAY_VERSION \}\}'

# Test: Verify the Docker push command uses the correct tag
rg --type yaml 'docker push \$\{\{ env\.DOCKER_IMAGE_URL \}\}:\$\{\{ steps\.set_version\.outputs\.GATEWAY_VERSION \}\}'

Length of output: 1079


Script:

#!/bin/bash
# Description: Search for Docker build and push commands in build.yml

# Search for docker build command with GATEWAY_VERSION
rg --fixed-strings 'docker build -t ${{ env.DOCKER_IMAGE_URL }}:${{ steps.set_version.outputs.GATEWAY_VERSION }}' .github/workflows/build.yml

# Search for docker push command with GATEWAY_VERSION
rg --fixed-strings 'docker push ${{ env.DOCKER_IMAGE_URL }}:${{ steps.set_version.outputs.GATEWAY_VERSION }}' .github/workflows/build.yml

Length of output: 582

@m-Peter m-Peter force-pushed the versioned-docker-images branch 2 times, most recently from 802eb0a to 69a0ced Compare September 27, 2024 12:19
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: 0

🧹 Outside diff range and nitpick comments (1)
.github/workflows/build.yml (1)

23-25: LGTM: Gateway Version setting step with minor improvement needed

The addition of the "Set Gateway Version" step is a good improvement. It correctly sets the version based on the latest Git tag and uses GITHUB_OUTPUT for sharing the value between steps.

To address the static analysis hint and prevent potential issues with word splitting or globbing, please update the command with proper quoting:

run: echo "GATEWAY_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo 'unknown')" >> $GITHUB_OUTPUT

This change adds quotes around the command substitution, improving the robustness of the step.

🧰 Tools
🪛 actionlint

25-25: shellcheck reported issue in this script: SC2086:info:1:91: Double quote to prevent globbing and word splitting

(shellcheck)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b679e52 and 69a0ced.

📒 Files selected for processing (1)
  • .github/workflows/build.yml (3 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/build.yml

25-25: shellcheck reported issue in this script: SC2086:info:1:91: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (3)
.github/workflows/build.yml (3)

9-9: LGTM: Simplified Docker image URL

The change to DOCKER_IMAGE_URL aligns well with the PR objective. Using ${{ vars.REPO_DOCKER_IMAGE_URL }} simplifies the configuration and allows for easier management of the Docker image URL across different environments or projects.


43-44: LGTM: Correct implementation of Gateway Version in Docker commands

The changes to the Docker build and push commands correctly implement the use of the GATEWAY_VERSION:

  1. The Docker image is now built with the tag ${{ steps.set_version.outputs.GATEWAY_VERSION }}.
  2. The GATEWAY_VERSION is passed as a build argument, allowing it to be used within the Dockerfile.
  3. The Docker push command uses the same version tag.

These changes successfully address the PR objective and the linked issue (#489) by implementing a versioning system for Docker images based on Git tags. This will make it easier for users to pull specific versions of the image and manage dependencies.


Line range hint 9-44: Summary: Successful implementation of Docker image versioning

The changes in this PR successfully implement the use of released tag versions for Docker images, addressing the objectives outlined in the PR description and the linked issue (#489). Key improvements include:

  1. Simplified DOCKER_IMAGE_URL definition.
  2. Introduction of a "Set Gateway Version" step to capture the latest Git tag.
  3. Consistent use of the GATEWAY_VERSION in Docker build and push commands.

These changes will resolve the issue of users being unable to pull the onflow/flow-evm-gateway image from Docker Hub by providing a clear versioning system based on Git tags.

There's a minor suggestion to improve the quoting in the "Set Gateway Version" step, but overall, the implementation is solid and achieves the desired outcome.

Great work on addressing this important issue!

🧰 Tools
🪛 actionlint

25-25: shellcheck reported issue in this script: SC2086:info:1:91: Double quote to prevent globbing and word splitting

(shellcheck)

@m-Peter m-Peter removed the request for review from devbugging September 30, 2024 15:39
@m-Peter m-Peter force-pushed the versioned-docker-images branch from 228a397 to 57f159a Compare October 17, 2024 10:23
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: 0

🧹 Outside diff range and nitpick comments (1)
.github/workflows/build.yml (1)

23-26: Approve with minor improvement: Gateway Version setting step

The addition of the "Set Gateway Version" step is an excellent improvement. It correctly addresses the issue raised in past comments by setting the version in a step rather than in the global env. The use of git describe to get the latest tag and the fallback to 'unknown' are good practices.

However, there's a minor improvement needed to address the static analysis hint:

Please update the command with proper quoting to prevent potential issues with word splitting or globbing:

run: echo "GATEWAY_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo 'unknown')" >> "$GITHUB_OUTPUT"

This change adds quotes around the $GITHUB_OUTPUT variable, improving the robustness of the step.

🧰 Tools
🪛 actionlint

25-25: shellcheck reported issue in this script: SC2086:info:1:91: Double quote to prevent globbing and word splitting

(shellcheck)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 69a0ced and 57f159a.

📒 Files selected for processing (1)
  • .github/workflows/build.yml (3 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/build.yml

25-25: shellcheck reported issue in this script: SC2086:info:1:91: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (3)
.github/workflows/build.yml (3)

9-9: LGTM: Environment variable update

The simplification of the DOCKER_IMAGE_URL environment variable is a good change. It aligns with the PR objective of using released tag versions instead of commit hashes for Docker images. This change provides more flexibility in tagging the images later in the workflow.


43-44: LGTM: Docker build and push commands updated

The changes to the Docker build and push commands are excellent. They correctly implement the use of the GATEWAY_VERSION from the step output, both for tagging the image and as a build argument. This ensures consistency between the version used in the build process and the tag applied to the image.

These updates fully address the PR objective of using released tag versions for Docker images and resolve the issues mentioned in the past review comments.


Line range hint 1-44: Summary: Successful implementation of released tag versioning for Docker images

The changes in this workflow file successfully implement the use of released tag versions for Docker images, addressing the main objective of the PR. The key improvements include:

  1. Simplification of the DOCKER_IMAGE_URL environment variable.
  2. Addition of a step to set the GATEWAY_VERSION based on the latest Git tag.
  3. Consistent use of the GATEWAY_VERSION in both Docker build and push commands.

These changes should resolve the issue of users being unable to pull the onflow/flow-evm-gateway image from Docker Hub, as mentioned in the linked issue #489.

To ensure the changes work as expected, let's verify the implementation:

This script will help verify that all the necessary changes are in place and correctly implemented.

✅ Verification successful

✅ Verification Successful: Workflow changes correctly implement Docker image versioning.

The verification script confirms that:

  1. The workflow is triggered on tag pushes.
  2. The DOCKER_IMAGE_URL environment variable is properly set.
  3. The "Set Gateway Version" step is correctly implemented.
  4. Docker build and push commands utilize the GATEWAY_VERSION as intended.

These findings validate that the workflow changes align with the PR objectives and effectively address the issue of Docker image versioning.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the workflow changes for Docker image versioning

# Test 1: Check if the workflow is triggered on tag push
echo "Test 1: Verifying workflow trigger"
grep -n 'on:' .github/workflows/build.yml -A 5

# Test 2: Verify the DOCKER_IMAGE_URL environment variable
echo "Test 2: Checking DOCKER_IMAGE_URL"
grep -n 'DOCKER_IMAGE_URL:' .github/workflows/build.yml

# Test 3: Check the "Set Gateway Version" step
echo "Test 3: Verifying Set Gateway Version step"
grep -n 'Set Gateway Version' .github/workflows/build.yml -A 3

# Test 4: Verify Docker build and push commands
echo "Test 4: Checking Docker build and push commands"
grep -n 'docker build' .github/workflows/build.yml -A 2

Length of output: 1338

🧰 Tools
🪛 actionlint

25-25: shellcheck reported issue in this script: SC2086:info:1:91: Double quote to prevent globbing and word splitting

(shellcheck)

@m-Peter m-Peter merged commit ed2e887 into main Oct 17, 2024
2 checks passed
@m-Peter m-Peter deleted the versioned-docker-images branch October 17, 2024 10:36
@coderabbitai coderabbitai bot mentioned this pull request Oct 17, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Version docker images
2 participants