Skip to content

Fix: make format with too many containers#1435

Merged
kmesh-bot merged 1 commit intokmesh-net:mainfrom
brushax:format-fix
Jul 10, 2025
Merged

Fix: make format with too many containers#1435
kmesh-bot merged 1 commit intokmesh-net:mainfrom
brushax:format-fix

Conversation

@brushax
Copy link
Copy Markdown
Contributor

@brushax brushax commented Jul 9, 2025

What type of PR is this?

/kind enhancement

What this PR does / why we need it:

make format will create a markdownlint-cli2 container 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?:

NONE

Copilot AI review requested due to automatic review settings July 9, 2025 09:55
@kmesh-bot kmesh-bot added the kind/enhancement New feature or request label Jul 9, 2025
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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 format command: The hack/format.sh script has been updated to reuse a named Docker container (kmesh-mdlint) for markdownlint-cli2 instead 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 .gitignore file now includes .local/ and *.o.tmp to prevent local development artifacts and temporary object files from being committed. A new .gitignore file in the config/ directory has been added to specifically ignore linux-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

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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the formatting workflow by reusing a named MarkdownLint container and tidies up shell scripts.

  • Reuse a persistent markdownlint-cli2 container to avoid creating new ones each run
  • Removed an unnecessary blank line in kmesh_compile_env_pre.sh
  • Added linux-bpf.h to config/.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

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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"'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

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]

Suggested change
docker exec $MDLINT_CONTAINER markdownlint-cli2 'markdownlint-cli2 --fix "**/*.md"'
docker exec $MDLINT_CONTAINER --fix "**/*.md"

@yp969803
Copy link
Copy Markdown
Contributor

yp969803 commented Jul 9, 2025

@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
Copy link
Copy Markdown

codecov bot commented Jul 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.89%. Comparing base (e0a2ca3) to head (f951d17).
Report is 8 commits behind head on main.

see 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 01c10a6...f951d17. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@brushax
Copy link
Copy Markdown
Contributor Author

brushax commented Jul 9, 2025

@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

The previous implementation was mainly because I didn't want to create a new ephemeral container every time. However, using the --rm parameter introduces relatively low complexity.

Copy link
Copy Markdown
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

/lgtm

@kmesh-bot
Copy link
Copy Markdown
Collaborator

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kmesh-bot kmesh-bot merged commit d878050 into kmesh-net:main Jul 10, 2025
12 checks passed
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.

5 participants