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

ci: push devcontainer on workflow dispatch #2485

Closed
wants to merge 4 commits into from

Conversation

glihm
Copy link
Collaborator

@glihm glihm commented Sep 30, 2024

Summary by CodeRabbit

  • Chores
    • Enhanced Docker image handling in GitHub Actions for improved tagging and pushing.
    • Expanded event triggers for manual Docker image pushes.
    • Refined logic for setting Docker tags based on event types.
  • New Features
    • Updated Dockerfile to support a Rust development environment with additional packages and dependencies.
    • Streamlined installation process for Foundry and added platform-specific tooling for hurl.

Copy link

coderabbitai bot commented Sep 30, 2024

Walkthrough

Ohayo, sensei! The changes in this pull request enhance the GitHub Actions workflow for managing Docker images. The configuration now accommodates pushing images on manual triggers alongside existing event types. The DOCKER_TAG environment variable is set based on the event type, ensuring clarity and consistency. Furthermore, the propose-update-pr job has been refined to operate under specific conditions, ensuring it updates relevant files with the new Docker image tag as intended.

Changes

File Path Change Summary
.github/workflows/devcontainer.yml Modified to include workflow_dispatch for Docker image pushing; refined DOCKER_TAG logic; adjusted propose-update-pr job conditions.
.devcontainer/Dockerfile Updated to install additional packages for a Rust development environment, including LLVM 17 and various Rust components, with platform-specific tooling added.

Possibly related PRs


🪧 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.

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

@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 (2)
.github/workflows/devcontainer.yml (2)

Line range hint 30-55: Ohayo, sensei! Excellent refinement of Docker tag logic

The changes to the DOCKER_TAG setting logic are well-implemented and improve the consistency across different event types. The use of a short SHA for push events and allowing custom tags for manual triggers are particularly good practices.

One small suggestion to improve readability:

Consider using a single step to set both the environment variable and the output for all event types. This could reduce repetition and make the workflow more maintainable. Here's an example:

- name: Set Docker tag and output
  run: |
    if [[ "${{ github.event_name }}" == "release" ]]; then
      DOCKER_TAG="${{ github.event.release.tag_name }}"
    elif [[ "${{ github.event_name }}" == "push" ]]; then
      DOCKER_TAG=$(echo "${{ github.sha }}" | cut -c 1-7)
    else
      DOCKER_TAG="${{ inputs.docker_tag }}"
    fi
    echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
    echo "tag_name=$DOCKER_TAG" >> $GITHUB_OUTPUT

This consolidates the logic into a single step, making it easier to maintain and understand.

🧰 Tools
🪛 actionlint

65-65: the runner of "docker/build-push-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


Line range hint 76-105: Ohayo, sensei! Well-structured updates to the PR creation process

The changes to the propose-update-pr job are well-thought-out. Moving the condition to the job level is a great improvement for clarity and efficiency. The logic for updating the relevant files is sound and ensures consistency across the project.

One small suggestion for consistency:

Consider using the ${{ env.DOCKER_TAG }} instead of ${{ needs.build-and-push.outputs.tag_name }} in the sed commands. This would make the tag reference consistent with the build-and-push job. Here's an example for the devcontainer.json update:

- name: Update devcontainer.json
  run: sed -i "s|ghcr.io/dojoengine/dojo-dev:[a-zA-Z0-9._-]*|ghcr.io/dojoengine/dojo-dev:${{ env.DOCKER_TAG }}|" .devcontainer/devcontainer.json

Make sure to apply this change to the GitHub action devcontainers update step as well.

🧰 Tools
🪛 actionlint

65-65: the runner of "docker/build-push-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ee06e56 and 1d4ed0f.

📒 Files selected for processing (1)
  • .github/workflows/devcontainer.yml (1 hunks)
🔇 Additional comments (1)
.github/workflows/devcontainer.yml (1)

67-67: Ohayo, sensei! LGTM: Enhanced flexibility for Docker image pushing

The addition of the workflow_dispatch event to the push condition is a great improvement. It allows for manual triggering of the Docker image build and push process, which can be very useful for testing or ad-hoc deployments.

Copy link

@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.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1d4ed0f and aa83627.

📒 Files selected for processing (2)
  • .devcontainer/Dockerfile (1 hunks)
  • .github/workflows/devcontainer.yml (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/devcontainer.yml

Comment on lines +79 to +81
elif [ "$BUILD_TYPE" = "workflow_dispatch" ]; then \
echo "Installing Dojo at commit $DOJO_VERSION"; \
dojoup -c $DOJO_VERSION; \
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Ohayo, sensei! Avoid code duplication by consolidating conditions

The blocks for push and workflow_dispatch are performing the same actions. Consider combining them to simplify the script and reduce redundancy.

Apply this diff to refactor the code:

 RUN if [ "$BUILD_TYPE" = "release" ]; then \
     echo "Installing Dojo version $DOJO_VERSION"; \
     dojoup -v $DOJO_VERSION; \
-elif [ "$BUILD_TYPE" = "push" ]; then \
+elif [ "$BUILD_TYPE" = "push" ] || [ "$BUILD_TYPE" = "workflow_dispatch" ]; then \
     echo "Installing Dojo at commit $DOJO_VERSION"; \
     dojoup -c $DOJO_VERSION; \
-elif [ "$BUILD_TYPE" = "workflow_dispatch" ]; then \
-    echo "Installing Dojo at commit $DOJO_VERSION"; \
-    dojoup -c $DOJO_VERSION; \
 else \
     echo "Installing latest stable version of Dojo"; \
     dojoup; \
     fi
📝 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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
elif [ "$BUILD_TYPE" = "workflow_dispatch" ]; then \
echo "Installing Dojo at commit $DOJO_VERSION"; \
dojoup -c $DOJO_VERSION; \
elif [ "$BUILD_TYPE" = "push" ] || [ "$BUILD_TYPE" = "workflow_dispatch" ]; then \
echo "Installing Dojo at commit $DOJO_VERSION"; \
dojoup -c $DOJO_VERSION; \

Copy link

@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

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

46-46: Ohayo, sensei! Nice addition of DOJO_VERSION!

The addition of the DOJO_VERSION environment variable is a good improvement for consistency in version tracking. It aligns well with the existing DOCKER_TAG logic.

Consider using double quotes for the environment variable assignment to prevent potential issues with special characters:

- echo "DOJO_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
+ echo "DOJO_VERSION=\"${{ github.event.release.tag_name }}\"" >> $GITHUB_ENV
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between aa83627 and 71cba6d.

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

51-51: shellcheck reported issue in this script: SC2086:info:2:33: Double quote to prevent globbing and word splitting

(shellcheck)


51-51: shellcheck reported issue in this script: SC2086:info:3:35: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:2:35: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:3:47: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (2)
.github/workflows/devcontainer.yml (2)

Line range hint 1-15: Ohayo, sensei! LGTM on the workflow trigger update!

The addition of the workflow_dispatch event with a docker_tag input is a great improvement. It allows for manual triggering of the workflow and provides flexibility in naming the Docker image. This change enhances the usability of the CI process.

🧰 Tools
🪛 actionlint

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

(shellcheck)


44-44: shellcheck reported issue in this script: SC2086:info:2:61: Double quote to prevent globbing and word splitting

(shellcheck)


44-44: shellcheck reported issue in this script: SC2086:info:3:32: Double quote to prevent globbing and word splitting

(shellcheck)


51-51: shellcheck reported issue in this script: SC2086:info:2:33: Double quote to prevent globbing and word splitting

(shellcheck)


51-51: shellcheck reported issue in this script: SC2086:info:3:35: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:2:35: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:3:47: Double quote to prevent globbing and word splitting

(shellcheck)


71-77: Ohayo, sensei! Excellent updates to the build and push step!

The changes in this step are well-thought-out and improve the workflow significantly:

  1. The push condition now includes the workflow_dispatch event, allowing manual triggers to push Docker images. This adds flexibility to the CI process.

  2. The addition of DOJO_VERSION as a build argument ensures that the version information is available during the build process, which can be crucial for versioning within the container.

These changes align well with the previous updates and enhance the overall functionality of the workflow.

echo "tag_name=$DOCKER_TAG" >> $GITHUB_OUTPUT

- name: Set Docker tag for push event
if: github.event_name == 'push'
run: |
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c 1-7)
echo "DOCKER_TAG=$SHORT_SHA" >> $GITHUB_ENV
echo "DOJO_VERSION=$SHORT_SHA" >> $GITHUB_OUTPUT
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ohayo, sensei! Good addition, but let's align it with the release event.

The addition of the DOJO_VERSION is great for consistency. However, there's a small inconsistency in how it's being set.

In the release event, DOJO_VERSION is set to $GITHUB_ENV, but here it's set to $GITHUB_OUTPUT. Let's make it consistent:

- echo "DOJO_VERSION=$SHORT_SHA" >> $GITHUB_OUTPUT
+ echo "DOJO_VERSION=$SHORT_SHA" >> $GITHUB_ENV

Also, consider using double quotes as suggested in the previous comment.

📝 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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo "DOJO_VERSION=$SHORT_SHA" >> $GITHUB_OUTPUT
echo "DOJO_VERSION=$SHORT_SHA" >> $GITHUB_ENV

Comment on lines 59 to 60
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c 1-7)
echo "DOJO_VERSION=$SHORT_SHA" >> $GITHUB_OUTPUT
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ohayo, sensei! Good additions, but let's refine them a bit.

The addition of SHORT_SHA and DOJO_VERSION is good for consistency. However, there are a couple of points to consider:

  1. The DOJO_VERSION is set to $GITHUB_OUTPUT instead of $GITHUB_ENV, similar to the push event. Let's make it consistent:
- echo "DOJO_VERSION=$SHORT_SHA" >> $GITHUB_OUTPUT
+ echo "DOJO_VERSION=$SHORT_SHA" >> $GITHUB_ENV
  1. Consider using the user-provided docker_tag for DOJO_VERSION instead of SHORT_SHA, to align with the DOCKER_TAG logic:
- echo "DOJO_VERSION=$SHORT_SHA" >> $GITHUB_ENV
+ echo "DOJO_VERSION=${{ inputs.docker_tag }}" >> $GITHUB_ENV

Also, remember to use double quotes for the environment variable assignments.

Committable suggestion was skipped due to low confidence.

Copy link

@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

🧹 Outside diff range and nitpick comments (2)
.github/workflows/devcontainer.yml (2)

54-54: Ohayo, sensei! Good addition, but let's make it even better.

The DOJO_VERSION is correctly set to the short SHA for push events, maintaining consistency with the DOCKER_TAG. However, we can improve it slightly:

Consider using double quotes to prevent potential issues with special characters:

- echo "DOJO_VERSION=$SHORT_SHA" >> $GITHUB_ENV
+ echo "DOJO_VERSION=\"$SHORT_SHA\"" >> $GITHUB_ENV

77-77: Ohayo, sensei! Great addition of DOJO_VERSION as a build arg.

Passing DOJO_VERSION as a build argument is an excellent way to make the version information available during the Docker build process. This can be useful for versioning within the container or for other build-time decisions.

For consistency with other build args, consider using quotes:

- DOJO_VERSION=${{ env.DOJO_VERSION }}
+ DOJO_VERSION="${{ env.DOJO_VERSION }}"
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 71cba6d and e2544f9.

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

51-51: shellcheck reported issue in this script: SC2086:info:2:33: Double quote to prevent globbing and word splitting

(shellcheck)


51-51: shellcheck reported issue in this script: SC2086:info:3:35: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:2:35: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:3:47: Double quote to prevent globbing and word splitting

(shellcheck)

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

46-46: Ohayo, sensei! Nice addition of DOJO_VERSION for releases.

The DOJO_VERSION is correctly set to the release tag name for the release event. This ensures consistency between the release version and the Docker image tag.


71-71: Ohayo, sensei! Excellent update to the push condition.

The addition of github.event_name == 'workflow_dispatch' to the push condition is spot on. This change allows manual triggering of image pushes, which perfectly aligns with the PR objective of pushing the devcontainer on workflow dispatch.


Line range hint 1-114: Ohayo, sensei! Overall, these changes are dojo-tastic!

The modifications to the workflow successfully implement the PR objective of pushing the devcontainer on workflow dispatch. The changes maintain consistency in version labeling across different event types and enhance the flexibility of the CI process.

A few minor suggestions have been made to improve code robustness and consistency. Once these are addressed, the changes will be even more solid.

Great work on enhancing the CI workflow, sensei!

🧰 Tools
🪛 actionlint

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

(shellcheck)


44-44: shellcheck reported issue in this script: SC2086:info:2:61: Double quote to prevent globbing and word splitting

(shellcheck)


44-44: shellcheck reported issue in this script: SC2086:info:3:32: Double quote to prevent globbing and word splitting

(shellcheck)


51-51: shellcheck reported issue in this script: SC2086:info:2:33: Double quote to prevent globbing and word splitting

(shellcheck)


51-51: shellcheck reported issue in this script: SC2086:info:3:35: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:2:35: Double quote to prevent globbing and word splitting

(shellcheck)


58-58: shellcheck reported issue in this script: SC2086:info:3:47: Double quote to prevent globbing and word splitting

(shellcheck)

Comment on lines +59 to +60
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c 1-7)
echo "DOJO_VERSION=$SHORT_SHA" >> $GITHUB_ENV
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ohayo, sensei! Let's clarify the version setting for workflow_dispatch.

The addition of SHORT_SHA and DOJO_VERSION for the workflow_dispatch event is good, but there's a potential inconsistency:

  1. DOJO_VERSION is set to the short SHA, while DOCKER_TAG uses the user input.
  2. We might want to use double quotes to prevent issues with special characters.

Consider the following changes:

- SHORT_SHA=$(echo "${{ github.sha }}" | cut -c 1-7)
- echo "DOJO_VERSION=$SHORT_SHA" >> $GITHUB_ENV
+ SHORT_SHA=$(echo "${{ github.sha }}" | cut -c 1-7)
+ echo "DOJO_VERSION=\"${{ inputs.docker_tag }}\"" >> $GITHUB_ENV

This aligns DOJO_VERSION with DOCKER_TAG for consistency. However, if there's a specific reason for using the short SHA instead of the user input for DOJO_VERSION, please clarify.

Committable suggestion was skipped due to low confidence.

@glihm
Copy link
Collaborator Author

glihm commented Sep 30, 2024

Use preview instead. Thanks @steebchen. <3

@glihm glihm closed this Sep 30, 2024
@glihm glihm deleted the ci/devcontainer-dispatch branch January 16, 2025 22:06
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