[PR #1368] [MERGED] [CI] Improve Code Formatting Workflow #2199

Closed
opened 2026-10-29 21:33:31 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/kvcache-ai/Mooncake/pull/1368
Author: @staryxchen
Created: 1/13/2026
Status: ✅ Merged
Merged: 1/14/2026
Merged by: @staryxchen

Base: main ← Head: feat/add-code-format-script


📝 Commits (2)

  • e5611a3 chore: add code formatting script and update PR template
  • d99acbe ci: simplify clang-format workflow by using script

📊 Changes

3 files changed (+279 additions, -42 deletions)

View changed files

📝 .github/pull_request_template.md (+1 -0)
📝 .github/workflows/ci.yml (+22 -42)
➕ scripts/code_format.sh (+256 -0)

📄 Description

Summary

This PR improves the code formatting workflow by introducing a unified formatting script and updating the CI pipeline to use it.

Changes

1. Add Code Formatting Script and Update PR Template

  • New script: scripts/code_format.sh - A comprehensive bash script for formatting C/C++ code using clang-format

    • Supports formatting only changed files (default) or all files (--all)
    • Supports check mode (--check) to verify formatting without modifying files
    • Configurable base branch for comparison (--base)
    • Excludes cachelib_memory_allocator directory
    • Provides colored output and helpful error messages
  • Updated PR template: Added a checklist item reminding developers to run ./scripts/code_format.sh before submitting

2. Simplify CI Workflow by Using the Shared Script

  • Refactored CI workflow: The clang-format job now uses code_format.sh --check instead of inline shell commands
  • Single source of truth: Both local development and CI use the same formatting logic
  • Easier maintenance: Only need to maintain one script (code_format.sh) for all formatting needs
  • Consistent behavior: Local --check mode and CI checks behave identically

Benefits

  • Developer experience: Easy-to-use script with clear options and helpful output
  • Maintainability: Single script to maintain instead of duplicated logic in CI
  • Consistency: Guaranteed identical behavior between local checks and CI
  • Flexibility: Developers can format all files or just changed files as needed

Usage

# Format changed files in current PR
./scripts/code_format.sh

# Check formatting without modifying files
./scripts/code_format.sh --check

# Format all C/C++ files in the project
./scripts/code_format.sh --all

# Compare against a different base branch
./scripts/code_format.sh --base origin/dev

Type of Change

  • Types
    • Bug fix
    • New feature
      • Transfer Engine
      • Mooncake Store
      • Mooncake EP
      • Integration
      • P2P Store
      • Python Wheel
    • Breaking change
    • CI/CD
    • Documentation update
    • Other

How Has This Been Tested?

Clipboard_Screenshot_1768293583

Checklist

  • I have performed a self-review of my own code.
  • I have updated the documentation.
  • I have added tests to prove my changes are effective.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/kvcache-ai/Mooncake/pull/1368 **Author:** [@staryxchen](https://github.com/staryxchen) **Created:** 1/13/2026 **Status:** ✅ Merged **Merged:** 1/14/2026 **Merged by:** [@staryxchen](https://github.com/staryxchen) **Base:** `main` ← **Head:** `feat/add-code-format-script` --- ### 📝 Commits (2) - [`e5611a3`](https://github.com/kvcache-ai/Mooncake/commit/e5611a325dcd4ee20ed55353f7129444bf201261) chore: add code formatting script and update PR template - [`d99acbe`](https://github.com/kvcache-ai/Mooncake/commit/d99acbecf1557ce4533535402a4710a1c9856535) ci: simplify clang-format workflow by using script ### 📊 Changes **3 files changed** (+279 additions, -42 deletions) <details> <summary>View changed files</summary> 📝 `.github/pull_request_template.md` (+1 -0) 📝 `.github/workflows/ci.yml` (+22 -42) ➕ `scripts/code_format.sh` (+256 -0) </details> ### 📄 Description ## Summary This PR improves the code formatting workflow by introducing a unified formatting script and updating the CI pipeline to use it. ## Changes ### 1. Add Code Formatting Script and Update PR Template - **New script**: `scripts/code_format.sh` - A comprehensive bash script for formatting C/C++ code using clang-format - Supports formatting only changed files (default) or all files (`--all`) - Supports check mode (`--check`) to verify formatting without modifying files - Configurable base branch for comparison (`--base`) - Excludes `cachelib_memory_allocator` directory - Provides colored output and helpful error messages - **Updated PR template**: Added a checklist item reminding developers to run `./scripts/code_format.sh` before submitting ### 2. Simplify CI Workflow by Using the Shared Script - **Refactored CI workflow**: The clang-format job now uses `code_format.sh --check` instead of inline shell commands - **Single source of truth**: Both local development and CI use the same formatting logic - **Easier maintenance**: Only need to maintain one script (`code_format.sh`) for all formatting needs - **Consistent behavior**: Local `--check` mode and CI checks behave identically ## Benefits - **Developer experience**: Easy-to-use script with clear options and helpful output - **Maintainability**: Single script to maintain instead of duplicated logic in CI - **Consistency**: Guaranteed identical behavior between local checks and CI - **Flexibility**: Developers can format all files or just changed files as needed ## Usage ```bash # Format changed files in current PR ./scripts/code_format.sh # Check formatting without modifying files ./scripts/code_format.sh --check # Format all C/C++ files in the project ./scripts/code_format.sh --all # Compare against a different base branch ./scripts/code_format.sh --base origin/dev ``` ## Type of Change * Types - [ ] Bug fix - [ ] New feature - [ ] Transfer Engine - [ ] Mooncake Store - [ ] Mooncake EP - [ ] Integration - [ ] P2P Store - [ ] Python Wheel - [ ] Breaking change - [x] CI/CD - [ ] Documentation update - [ ] Other ## How Has This Been Tested? <img width="761" height="285" alt="Clipboard_Screenshot_1768293583" src="https://github.com/user-attachments/assets/e2f14224-4048-404f-9ebd-1ca27fdd1fd4" /> ## Checklist - [x] I have performed a self-review of my own code. - [x] I have updated the documentation. - [x] I have added tests to prove my changes are effective. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:33:31 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kvcache-ai/Mooncake#2199
No description provided.