Skip to content

Conversation

@dsm
Copy link
Collaborator

@dsm dsm commented Jun 18, 2025

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:

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

This helps maintain consistent code style across the codebase and reduces manual formatting overhead.

…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.
@dsm dsm added the CI label Jun 18, 2025
@dsm dsm changed the title chore: add CI workflow to auto-format using clang-format add CI workflow to auto-format using clang-format Jun 18, 2025
@dsm
Copy link
Collaborator Author

dsm commented Jun 18, 2025

example PR looks like this -> dsm#5

@ra3xdh ra3xdh added this to the 25.2.0 milestone Jun 19, 2025
@wawuwo
Copy link
Collaborator

wawuwo commented Jun 22, 2025

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)

@ra3xdh
Copy link
Owner

ra3xdh commented Jun 22, 2025

Isn't it better to run it as a check when a PR arrives?

Yes, this would be preferable, if possible.

@wawuwo
Copy link
Collaborator

wawuwo commented Jun 22, 2025

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.

@dsm
Copy link
Collaborator Author

dsm commented Jun 22, 2025

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?

@wawuwo
Copy link
Collaborator

wawuwo commented Jun 22, 2025

agree on a style

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.

@dsm
Copy link
Collaborator Author

dsm commented Jun 22, 2025

I think we can create a custom one based off Web kit or gnu

@wawuwo
Copy link
Collaborator

wawuwo commented Jun 22, 2025

Vadim, do you have a personal preference for code formatting? A preferred style maybe?

@ra3xdh
Copy link
Owner

ra3xdh commented Jun 22, 2025

Webkit style would be preferable for me.

@wawuwo
Copy link
Collaborator

wawuwo commented Jun 22, 2025

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.
In the meantime, @dsm could you please adapt this PR to introduce a check for incoming PRs as was discussed earlier?

@dsm
Copy link
Collaborator Author

dsm commented Jun 22, 2025

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.

ex:( I try to find which settings needed.)
image

@wawuwo wawuwo mentioned this pull request Jun 24, 2025
@ra3xdh ra3xdh removed this from the 25.2.0 milestone Jul 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants