Add an alternative Precommit workflow#7334
Conversation
There was a problem hiding this comment.
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
PrecommitGitHub 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.
1ca3e9d to
9d7a362
Compare
|
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. |
accbaa6 to
03cbb10
Compare
|
Thanks for your contribution. We need some time for internal discussion before deciding whether to accept them. |
|
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. |
|
Thank you for your reply! Your review could mainly focus on the 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! |
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.