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

chore(cli): migrate to Cargo workspaces #380

Merged
merged 2 commits into from
Nov 5, 2024
Merged

Conversation

KeisukeYamashita
Copy link
Owner

@KeisukeYamashita KeisukeYamashita commented Nov 5, 2024

Why

Because I want to ensure this project is flexible enough for future development.

Summary by CodeRabbit

  • New Features

    • Introduced a new command-line interface tool, commitlint-rs, for linting commits based on the Conventional Commits specification.
  • Refactor

    • Transitioned project structure to a workspace configuration, simplifying package management.
  • Bug Fixes

    • Enhanced clarity in GitHub Actions workflow by centralizing working directory configuration and specifying Docker build context.

@KeisukeYamashita KeisukeYamashita self-assigned this Nov 5, 2024
Copy link

coderabbitai bot commented Nov 5, 2024

Caution

Review failed

The head commit changed during the review from 394e8e3 to 6ff3fdc.

Walkthrough

The pull request introduces significant changes to the project configuration, primarily focusing on the GitHub Actions workflow and the Rust package management structure. The release.yaml file is updated to centralize the working directory for run steps and specify the Docker build context. Additionally, the Cargo.toml file is restructured, removing the package metadata in favor of a workspace configuration, while a new Cargo.toml for the commitlint-rs package is added, detailing its dependencies and binary configuration.

Changes

File Change Summary
.github/workflows/release.yaml Added a defaults section for a default working-directory, and specified context for the Docker build step.
Cargo.toml Removed the [package], [dependencies], and [[bin]] sections; added a [workspace] section with cli as a member.
cli/Cargo.toml Introduced a new package commitlint-rs with metadata and dependencies; defined a binary target commitlint.

Possibly related PRs

  • feat(.github): use docker/metadata-action to generate tags and use cache for apk on build #340: The changes in the release.yaml file in both the main PR and this PR involve modifications to the GitHub Actions workflow, specifically related to the docker job, indicating a direct connection in the workflow configuration.
  • bump(cli): v0.2.0 #363: The main PR's changes to the Cargo.toml file, particularly the shift to a workspace configuration, relate to the updates in the commitlint-rs package's Cargo.toml in this PR, as both involve modifications to package management and structure.

🐇 In a world of code, so bright and new,
A rabbit hops in, with changes to pursue.
With workflows refined and packages aligned,
Commitlint now shines, its purpose defined.
Hooray for the updates, let’s cheer and rejoice,
For every new feature, we celebrate with voice! 🎉


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

Choose a reason for hiding this comment

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

[actionlint] reported by reviewdog 🐶
the runner of "actions-rs/toolchain@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]

- uses: actions-rs/toolchain@v1

Copy link

Choose a reason for hiding this comment

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

[actionlint] reported by reviewdog 🐶
the runner of "actions-rs/toolchain@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]

- uses: actions-rs/toolchain@v1

Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com>
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)
cli/Cargo.toml (1)

16-24: Optimize dependency features for CLI usage.

Consider the following optimizations:

  1. Replace tokio = { version = "1.37.0", features = ["full"] } with minimal required features (e.g., "rt", "macros") to reduce binary size.
  2. Review if all serde derive features are necessary.

Example optimization:

-tokio = { version = "1.37.0", features = ["full"] }
+tokio = { version = "1.37.0", features = ["rt", "rt-multi-thread", "macros", "fs", "io-util"] }
.github/workflows/release.yaml (1)

Line range hint 11-116: Consider documenting the workspace structure change.

The workflow changes reflect a significant structural change in the project. Consider adding a comment in the workflow file explaining the workspace structure and why certain paths are configured as they are.

Add a comment at the top of the file:

 name: Release
+# This workflow is configured to work with a Cargo workspace structure where
+# the main package resides in the ./cli directory.
 on:
   push:
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c234e90 and 45bcb14.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • .github/workflows/release.yaml (2 hunks)
  • Cargo.toml (1 hunks)
  • cli/Cargo.toml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • Cargo.toml
🔇 Additional comments (5)
cli/Cargo.toml (3)

27-29: LGTM!

The binary configuration follows standard Rust conventions.


31-32: LGTM! Verify binary release workflow.

The binstall configuration looks correct. Ensure the release workflow generates compatible artifacts.

#!/bin/bash
# Check if release workflow handles binary artifacts
if [ -d ".github/workflows" ]; then
    echo "Checking release workflow for binary artifacts:"
    rg -A 5 "asset|artifact|binary|release" .github/workflows/
fi

13-13: Verify the purpose of excluding the web directory.

The /web exclusion pattern seems isolated. If this is related to documentation or a web interface, consider documenting its purpose in the README.

✅ Verification successful

The /web exclusion is correct and properly documented

The /web directory contains the project's documentation website built with Astro (astro.config.mjs), TypeScript (tsconfig.json), and Node.js (package.json). It's appropriate to exclude it from the Rust package as it's a separate web application that doesn't need to be included in the CLI distribution.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if web directory exists and its purpose
fd -t d "web$" -x echo "Found web directory at: {}"
if [ -f "README.md" ]; then
    echo "Checking README.md for web directory documentation:"
    rg -i "web" "README.md"
fi

Length of output: 3231


Script:

#!/bin/bash
# Let's check for web-related files and directories in the repository
fd -t d "web" || true
fd -t f "web" || true

# Check Cargo.toml files for web-related configurations
echo "Checking Cargo.toml files:"
rg -A 3 "web" "Cargo.toml" || true
rg -A 3 "web" "**/Cargo.toml" || true

# Check if there are any web-related build or documentation tasks
echo "Checking for web-related tasks:"
rg -i "web" .github/workflows/*.y*ml || true

Length of output: 720


Script:

#!/bin/bash
# Let's check the contents of the web directory and its purpose
echo "Checking web directory structure:"
ls -la web/ || true

# Check for package.json or other web-related configuration files
echo "Checking for web configurations:"
fd -t f "package.json|tsconfig.json|webpack.config|vite.config" web/ || true

# Check if web directory is related to documentation
echo "Checking for documentation in web:"
fd . web/ -t f -e md || true

Length of output: 1878

.github/workflows/release.yaml (2)

116-116: Verify Docker build configuration.

The Docker build context is correctly set to ./cli to match the new workspace structure. However, we should verify the Dockerfile location and its content to ensure compatibility.

Let's verify the Docker setup:

✅ Verification successful

Let me gather more information about the Dockerfile contents to ensure complete verification.


Docker configuration is properly aligned with the new workspace structure

The Docker setup is correctly configured:

  • Dockerfile is properly located at cli/Dockerfile
  • Build context at ./cli matches the Dockerfile location
  • The Dockerfile uses appropriate paths for copying files and setting up the build
  • Multi-stage build is properly configured with correct COPY instructions
  • No other conflicting Docker configurations were found
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Docker configuration alignment with the new structure

# Test 1: Check Dockerfile location
echo "Checking Dockerfile location:"
fd -t f "Dockerfile" cli/

# Test 2: Check for any Docker-related paths in the Dockerfile
if [ -f "cli/Dockerfile" ]; then
    echo "Checking paths in Dockerfile:"
    rg "COPY|ADD" cli/Dockerfile
fi

Length of output: 324


Script:

#!/bin/bash
# Check complete Dockerfile contents to verify the configuration
echo "Complete Dockerfile contents:"
cat cli/Dockerfile

# Check if there are any other Docker-related files
echo -e "\nChecking for docker-compose or other Docker-related files:"
fd -t f "docker-compose|\.docker" 

Length of output: 785


11-14: Verify the impact of the default working directory.

The addition of a default working directory aligns with the Cargo workspace migration. However, we should verify that all run steps in the workflow are compatible with this change.

Let's verify the compatibility:

✅ Verification successful

The working directory change is correctly configured and compatible with all steps

The verification shows that:

  1. The ./cli working directory is appropriate as it contains:
    • The main Cargo.toml for the CLI package
    • The Dockerfile used by the docker job
  2. All run steps in the workflow are Cargo-related commands that should execute in the CLI directory:
    • cargo build --release
    • cargo publish
  3. Other path references in the workflow are either:
    • Absolute paths for artifacts
    • Explicitly set contexts (docker build, web deployment)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if any run steps might be affected by the working directory change

# Test 1: Find all run steps in the workflow
echo "Checking run steps in the workflow:"
rg "^\s*-\s*run:" -A 1

# Test 2: Check if Cargo.toml exists in the cli directory
fd -t f "Cargo.toml" cli/

# Test 3: Check if there are any path references in run commands that might need adjustment
rg "run:.*\.\/" -A 1

Length of output: 254


Script:

#!/bin/bash
# Let's try a different approach to analyze the workflow file

# First, let's see the entire workflow file content
echo "=== Workflow file content ==="
cat .github/workflows/release.yaml

# Then, let's specifically look for run steps without the problematic escape sequence
echo -e "\n=== Run steps in workflow ==="
rg "run:" .github/workflows/release.yaml -A 1

# Finally, check if there are any path references that might be affected
echo -e "\n=== Path references in workflow ==="
rg "path:|\.\/|\.\.\/|\/" .github/workflows/release.yaml

Length of output: 4886


Script:

#!/bin/bash
# Let's check for path references with a corrected regex

# Check for path references in the workflow
echo "=== Path references in workflow ==="
rg "path:|\\./|\\.\\./" .github/workflows/release.yaml

# Check if Dockerfile exists in the cli directory
echo -e "\n=== Check for Dockerfile ==="
fd Dockerfile cli/

# Check the content of Cargo.toml in cli directory
echo -e "\n=== CLI Cargo.toml content ==="
cat cli/Cargo.toml

Length of output: 1604

Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com>
Copy link

Choose a reason for hiding this comment

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

[actionlint] reported by reviewdog 🐶
the runner of "actions-rs/toolchain@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]

- uses: actions-rs/toolchain@v1

Copy link

Choose a reason for hiding this comment

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

[actionlint] reported by reviewdog 🐶
the runner of "actions-rs/cargo@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]

- uses: actions-rs/cargo@v1

Copy link

Choose a reason for hiding this comment

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

[actionlint] reported by reviewdog 🐶
the runner of "actions-rs/cargo@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]

- uses: actions-rs/cargo@v1

Copy link

Choose a reason for hiding this comment

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

[actionlint] reported by reviewdog 🐶
the runner of "actions-rs/toolchain@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]

- uses: actions-rs/toolchain@v1

Copy link

Choose a reason for hiding this comment

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

[actionlint] reported by reviewdog 🐶
the runner of "actions-rs/cargo@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]

- uses: actions-rs/cargo@v1

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