Fix: make format with too many containers#1435
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @Flying-Tom, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request primarily enhances the developer experience by optimizing the make format command to efficiently manage Docker containers used for markdown linting. It also includes minor cleanup and updates to .gitignore files to better manage generated and temporary files.
Highlights
- Optimized
make formatcommand: Thehack/format.shscript has been updated to reuse a named Docker container (kmesh-mdlint) formarkdownlint-cli2instead of creating a new, ephemeral container on every run. This prevents the accumulation of stopped containers and improves efficiency for repeated formatting tasks. - Gitignore updates: The main
.gitignorefile now includes.local/and*.o.tmpto prevent local development artifacts and temporary object files from being committed. A new.gitignorefile in theconfig/directory has been added to specifically ignorelinux-bpf.h.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the formatting workflow by reusing a named MarkdownLint container and tidies up shell scripts.
- Reuse a persistent
markdownlint-cli2container to avoid creating new ones each run - Removed an unnecessary blank line in
kmesh_compile_env_pre.sh - Added
linux-bpf.htoconfig/.gitignore
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| kmesh_compile_env_pre.sh | Removed an extraneous blank line before the dependency_pkg_install function definition |
| hack/format.sh | Introduced a named kmesh-mdlint container, checking and starting it instead of recreating |
| config/.gitignore | Added linux-bpf.h to the ignore list |
There was a problem hiding this comment.
Code Review
The pull request introduces changes to the format.sh script to use a persistent Docker container for markdown linting. The changes aim to avoid creating a new container every time the script is run. I have provided feedback on how to improve the container management and command execution within the container.
hack/format.sh
Outdated
| [ "$(docker inspect -f '{{.State.Running}}' $MDLINT_CONTAINER 2>/dev/null)" != "true" ] && | ||
| docker start $MDLINT_CONTAINER | ||
|
|
||
| docker exec $MDLINT_CONTAINER markdownlint-cli2 'markdownlint-cli2 --fix "**/*.md"' |
There was a problem hiding this comment.
The command being executed inside the container is redundant. The markdownlint-cli2 command is being called twice. The entrypoint of the container is already markdownlint-cli2. You can pass the arguments directly to the docker exec command. [^1]
| docker exec $MDLINT_CONTAINER markdownlint-cli2 'markdownlint-cli2 --fix "**/*.md"' | |
| docker exec $MDLINT_CONTAINER --fix "**/*.md" |
|
@Flying-Tom we can use the --rm flag when starting the container—this automatically removes the container once it exits. Please have a look at this approach |
Signed-off-by: Tom <yusencao@outlook.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
see 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
The previous implementation was mainly because I didn't want to create a new ephemeral container every time. However, using the |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hzxuzhonghu The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind enhancement
What this PR does / why we need it:
make formatwill create amarkdownlint-cli2container with random name every time, which needs to be fix.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: