Skip to content

Add an alternative Precommit workflow#7334

Open
Growl1234 wants to merge 7 commits into
deepmodeling:developfrom
Growl1234:make-pretty
Open

Add an alternative Precommit workflow#7334
Growl1234 wants to merge 7 commits into
deepmodeling:developfrom
Growl1234:make-pretty

Conversation

@Growl1234
Copy link
Copy Markdown

This PR introduces a self-contained precommit driver for ABACUS, replacing the previous workflow that relied on GitHub Action built-in/pre-commit style drivers.

The new implementation is inspired by the precommit infrastructure used in CP2K. It provides a project-owned driver under tools/precommit/precommit.py, together with a local precommit server for running external formatting/checking tools in a controlled environment (it would be best if a remote server is configured).

The driver performs strict formatting and file-property checks for files tracked by Git, covering most file types used in the repository. By default, it runs in check-only mode and reports formatting differences without modifying files. When invoked with --allow-modifications, it can automatically fix part of the formatting issues, such as indentation and style inconsistencies.

Copilot AI review requested due to automatic review settings May 12, 2026 09:39
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 adds a project-owned, CP2K-inspired precommit system for ABACUS, including a Python driver (tools/precommit/precommit.py) and a containerized Flask/gunicorn “precommit server” used to run external formatters in a controlled environment. It also introduces a GitHub Actions workflow to run these checks on pull requests, and refactors the existing test workflow to better surface grouped test failures.

Changes:

  • Added a self-contained precommit driver plus convention checks and supporting scripts under tools/precommit/.
  • Added a containerized precommit server (Dockerfile + server app) and local/CI startup tooling.
  • Added a new Precommit GitHub Actions workflow and improved test workflow failure reporting via a ctest wrapper.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
tools/precommit/start_local_server.sh Starts a local precommit server container (currently Podman-based).
tools/precommit/requirements.txt Python dependencies for the precommit server/tooling container.
tools/precommit/README.md Usage docs for installing the git hook and running the server/driver.
tools/precommit/precommit.py Precommit driver: file discovery, caching, remote formatting, local checks.
tools/precommit/precommit_server.py Flask server endpoints that run formatters inside the container.
tools/precommit/install_requirements.sh Installs OS + Python tooling inside the container image.
tools/precommit/format_makefile.py Local Makefile formatter helper.
tools/precommit/Dockerfile Container image definition for the precommit server.
tools/precommit/deploy.sh Script to build/push/deploy the server image (Cloud Run-oriented).
tools/precommit/cloudbuild.yaml Cloud Build recipe to build/push/deploy the server image.
tools/precommit/clang_format_wrapper.sh Wrapper to run clang-format with a project style file and split workaround.
tools/precommit/check_file_properties.py Local ABACUS-specific convention checks (encoding, flags, header rules, etc.).
tools/precommit/abacus_clang_format.yaml Project clang-format style configuration.
.github/workflows/test.yml Improves CI test reporting by wrapping ctest invocations and aggregating failures.
.github/workflows/precommit.yml New CI workflow that spins up the local precommit server and runs the driver.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/precommit/start_local_server.sh
Comment thread tools/precommit/format_makefile.py Outdated
Comment thread tools/precommit/format_makefile.py Outdated
Comment thread tools/precommit/format_makefile.py Outdated
Comment thread .github/workflows/precommit.yml
Comment thread tools/precommit/precommit_server.py
Comment thread tools/precommit/precommit_server.py Outdated
Comment thread tools/precommit/precommit.py
Comment thread tools/precommit/precommit.py
@Growl1234 Growl1234 force-pushed the make-pretty branch 6 times, most recently from 1ca3e9d to 9d7a362 Compare May 13, 2026 11:04
@Growl1234
Copy link
Copy Markdown
Author

The crucial part of this PR is under tools/precommit and GitHub Action workflows, while the remaining changes are only formatting related, without introducing any functional modifications.

If the developers agree with this approach, I would suggest merging this PR first. Follow-up PRs can then run make pretty on files in each directory in batches. Also, if possible, I would prefer this PR to be merged via rebase merge.

@Growl1234 Growl1234 force-pushed the make-pretty branch 5 times, most recently from accbaa6 to 03cbb10 Compare May 13, 2026 15:32
@mohanchen
Copy link
Copy Markdown
Collaborator

Thanks for your contribution. We need some time for internal discussion before deciding whether to accept them.

@mohanchen
Copy link
Copy Markdown
Collaborator

Besides, this PR still modifies over 300 files, some of which I believe are unnecessary to include here. It would greatly ease the review process if we only focus on the key changes. Reviewing more than 300 files requires substantial time and poses a significant challenge for reviewers.

@mohanchen mohanchen added Feature Discussed The features will be discussed first but will not be implemented soon Compile & CICD & Docs & Dependencies Issues related to compiling ABACUS labels May 14, 2026
@Growl1234
Copy link
Copy Markdown
Author

Thank you for your reply!

Your review could mainly focus on the tools/precommit part, which is the core of this PR. This workflow does not use clang-tidy, which is more likely to introduce regressions than pure formatting checks. It mainly keeps clang-format and formatting operations for most other file types. Therefore, the resulting code changes should be harmless. You may want to focus on whether there are any aspects of this infrastructure that you find concerning.

Also, many existing C++ and other source files already contain issues such as tab characters, DOS linebreaks, and inconsistent line-ending styles. Once this pre-commit workflow is put into use, changes involving 3000+ files, as in PR #7328, will inevitably happen anyways! Splitting them into several independent PRs has already minimized the file churn of each individual PR as much as possible, and in practice it has also slowed down the process. Therefore, I would prefer to keep this PR as it is, without either introducing additional changes or reverting the existing ones.

Looking forward to your discussion and decision. Thanks so much again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Compile & CICD & Docs & Dependencies Issues related to compiling ABACUS Feature Discussed The features will be discussed first but will not be implemented soon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants