Skip to content
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

Add github action to check that all files are formatted #37

Merged

Conversation

jr0me
Copy link
Member

@jr0me jr0me commented Jul 15, 2024

Description

This PR introduces a GitHub Action to enforce clang-format checks on all C/C++ source and header files, excluding specific directories like modules and common which bring many legacy files. The action runs on every push and pull request to ensure code consistency and style adherence across the repository.

Key Features:

  • Automatic Formatting Checks: The action runs clang-format in dry-run mode with -Werror to identify and report formatting issues.
  • Detailed Feedback: Integrates clang-tidy to provide specific rule violations and detailed feedback on formatting issues.

Usage Tips:

  • Git Integration: You can use git clang-format to format staged files before committing. This helps to ensure that your changes adhere to the project's formatting rules.
    git clang-format
  • Ignoring Blocks of Code: To ignore specific blocks of code from being formatted, you can use // clang-format off and // clang-format on comments around the code block.
    // clang-format off
    void unformatted_function() {
        int         x = 0;
        int         y = 0;
        std::cout << "This code block will not be formatted." << std::endl;
    }
    // clang-format on

This integration will help maintain a consistent code style and improve code readability across the project.

@jr0me jr0me force-pushed the enhancement/add-github-action-with-clang-format-check branch from 78d51ee to 4f22b43 Compare July 16, 2024 00:09
@jr0me jr0me requested a review from TomasTurina July 16, 2024 00:14
@TomasTurina TomasTurina linked an issue Jul 16, 2024 that may be closed by this pull request
@jr0me jr0me force-pushed the enhancement/add-github-action-with-clang-format-check branch from 4f22b43 to 2f8bcad Compare July 16, 2024 17:08
To ignore certain folders we add a format file in them,
this is needed for the common and modules folders
since they bring too many legacy files.

We also reuse a existing github action to perform the actual
clang format check.
Otherwise to see the actual errors one must download
the artifact generated by the action. If there are only a
few errors is easier and faster to just read the output
from the github action onsite.
@jr0me jr0me force-pushed the enhancement/add-github-action-with-clang-format-check branch from beac649 to 1bed5a6 Compare July 16, 2024 17:40
@TomasTurina TomasTurina merged commit 824bb1a into master Jul 16, 2024
2 checks passed
@TomasTurina TomasTurina deleted the enhancement/add-github-action-with-clang-format-check branch July 16, 2024 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Develop the new client
2 participants