-
-
Notifications
You must be signed in to change notification settings - Fork 143
add CI workflow to auto-format using clang-format #1413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: current
Are you sure you want to change the base?
Conversation
…ormat This commit adds a reusable GitHub Actions workflow that automatically formats all source files within the 'qucs' and 'qucs-*' directories using clang-format. Key features: - Can be manually triggered via workflow_dispatch or invoked via workflow_call from another workflow - Formats .cpp, .c, .h, and .hpp files - Creates a pull request if any changes are detected - Uses the GitHub CLI (gh) to create pull requests This helps maintain consistent code style across the codebase and reduces manual formatting overhead.
|
example PR looks like this -> dsm#5 |
|
Isn't it better to run it as a check when a PR arrives? I mean proper formatting should be a basic requirement for any PR. If there is an established formatting policy and a PR breaks formatting then it's not ready to be merged (IMHO) |
Yes, this would be preferable, if possible. |
|
Of course this would require agreeing on style and formatting the whole codebase beforehand… But I think it's feasible and is a better approach in general. |
|
I agree that adding a formatting check on PRs is the way to go. Once we agree on a style and format for the code base, we can set it up. The PR creation part can be made optional. workflow_dispatch (manual call) support arguments or completely removed. what do you think? |
clang-format is very flexible. The first option is to create a bespoke style from scratch or based on one of predefined (though it probably will be very time-consuming). Another option is to simply adopt one of predefined styles — LLVM, Google, Chromium, Mozilla, WebKit, Microsoft, GNU. (WebKit is the first and GNU is the last in my personal list of favourites) Examples of these styles can be found here. What do you guys think? I'm more inclined to go with WebKit style. |
|
I think we can create a custom one based off Web kit or gnu |
|
Vadim, do you have a personal preference for code formatting? A preferred style maybe? |
|
Webkit style would be preferable for me. |
Great! Then let's settle on vanilla WebKit style. I'll prepare a PR which formats all code in the repo. |
|
Hi @ra3xdh, it needs to setup a branch ruleset in repository settings to wait specific CI job success or not to block merge. I'll update to ci action that format only changed files in PR to ensure style. |

Hi @ra3xdh,
This PR adds a reusable GitHub Actions workflow that automatically formats all source files within the 'qucs' and 'qucs-*' directories using clang-format.
Key features:
This helps maintain consistent code style across the codebase and reduces manual formatting overhead.