{"id":14986029,"url":"https://github.com/jidicula/clang-format-action","last_synced_at":"2025-04-12T07:21:41.579Z","repository":{"id":40429987,"uuid":"250397925","full_name":"jidicula/clang-format-action","owner":"jidicula","description":"GitHub Action for clang-format checking","archived":false,"fork":false,"pushed_at":"2025-03-20T11:22:15.000Z","size":302,"stargazers_count":112,"open_issues_count":15,"forks_count":34,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-03T09:08:18.176Z","etag":null,"topics":["actions","c","c-plus-plus","clang-format","cpp","formatting","github-action","github-actions","hacktoberfest","linter"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jidicula.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jidicula"}},"created_at":"2020-03-26T23:48:50.000Z","updated_at":"2025-03-27T09:35:03.000Z","dependencies_parsed_at":"2024-01-06T16:42:05.153Z","dependency_job_id":"a1733c66-8793-4293-9863-c1f2cda50067","html_url":"https://github.com/jidicula/clang-format-action","commit_stats":{"total_commits":302,"total_committers":19,"mean_commits":"15.894736842105264","dds":0.6490066225165563,"last_synced_commit":"387bf69ccfc819b2f93c50818dabb1b00222464a"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jidicula%2Fclang-format-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jidicula%2Fclang-format-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jidicula%2Fclang-format-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jidicula%2Fclang-format-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jidicula","download_url":"https://codeload.github.com/jidicula/clang-format-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248530796,"owners_count":21119634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","c","c-plus-plus","clang-format","cpp","formatting","github-action","github-actions","hacktoberfest","linter"],"created_at":"2024-09-24T14:12:09.811Z","updated_at":"2025-04-12T07:21:41.558Z","avatar_url":"https://github.com/jidicula.png","language":"C","funding_links":["https://github.com/sponsors/jidicula","https://github.com/sponsors/jidicula)!"],"categories":[],"sub_categories":[],"readme":"[![ubuntu-20.04 Tests](https://github.com/jidicula/clang-format-action/actions/workflows/test-ubuntu-20.04.yml/badge.svg)](https://github.com/jidicula/clang-format-action/actions/workflows/test-ubuntu-20.04.yml) [![ubuntu-22.04 Tests](https://github.com/jidicula/clang-format-action/actions/workflows/test-ubuntu-22.04.yml/badge.svg)](https://github.com/jidicula/clang-format-action/actions/workflows/test-ubuntu-22.04.yml) [![ubuntu-24.04 Tests](https://github.com/jidicula/clang-format-action/actions/workflows/test-ubuntu-24.04.yml/badge.svg)](https://github.com/jidicula/clang-format-action/actions/workflows/test-ubuntu-24.04.yml)\n\n[![shell-lint](https://github.com/jidicula/clang-format-action/workflows/shell-lint/badge.svg?branch=main)](https://github.com/jidicula/clang-format-action/actions?query=workflow%3Ashell-lint+branch%3Amain)\n\n\n# clang-format-action\nAn action for `clang-format` checks. This action does **NOT** format your code for you - it only verifies that your repository's code follows your project's formatting conventions.\n\nYou can define your own formatting rules in a `.clang-format` file at your repository root, or you can provide a fallback style (see [`fallback-style`](#inputs)). You can also provide a path to check. If you want to run checks against multiple paths in your repository, you can use this action in a [matrix run](#multiple-paths).\n\n## Major versions supported\n* 3: `clang-format-3.9`\n* 4: `clang-format-4.0`\n* 5: `clang-format-5.0`\n* 6: `clang-format-6.0`\n* 7: `clang-format-7`\n* 8: `clang-format-8`\n* 9: `clang-format-9`\n* 10: `clang-format-10`\n* 11: `clang-format-11`\n* 12: `clang-format-12`\n* 13: `clang-format-13`\n* 14: `clang-format-14`\n* 15: `clang-format-15`\n* 16: `clang-format-16`\n* 17: `clang-format-17`\n* 18: `clang-format-18`\n* 19: `clang-format-19`\n* 20: `clang-format-20`\n\n## Action version upgrade guarantee\n\n\u003e [!IMPORTANT]\n\u003e This action complies with the [Semantic Versioning spec](https://semver.org) for how it's called from GitHub Actions workflows. This means that for version format `x.y.z`, minor and patch version increments `y++` and `z++` will not break existing functionality for how this action is called in your GitHub Actions workflows. Major version increments (`x++`) *will* include breaking changes in how this action is called. If you notice version changes that violate this guarantee, [open an issue](https://github.com/jidicula/clang-format-action/issues/new?template=Blank+issue) and let's work together to fix it 😁.\n\n\u003e [!CAUTION]\n\u003e I provide no guarantees for formatting breakages *within* `clang-format` versions. This action only supports major versions of `clang-format` and doesn't support granular specification of `clang-format` minor or patch versions. It's possible that a formatting check workflow using this action and a pinned version of `clang-format` could break in a subsequent run if the underlying `clang-format` Ubuntu package has introduced a breaking minor or patch version change. I'm not sure how often this happens - vote in [this poll](https://github.com/jidicula/clang-format-action/discussions/192) and optionally leave a comment so I can understand this problem more.\n\n## Do you find this useful?\n\nYou can sponsor me [here](https://github.com/sponsors/jidicula)!\n\n## Inputs\n* `clang-format-version` [optional]: The major version of `clang-format` that you want to run on your codebase.\n  * Default: `13`\n  * Available versions: see [Versions supported](#major-versions-supported)\n* `check-path` [optional]: The path to the directory in the repo that should be checked for C/C++/Protobuf formatting.\n  * Default: `.`\n  * For cleaner output (i.e. with no double-slashed paths), the final directory in this path should have no trailing slash, e.g. `src` and not `src/`.\n* `fallback-style` [optional]: The fallback style for `clang-format` if no `.clang-format` file exists in your repository.\n  * Default: `llvm`\n  * Available values: `LLVM`, `Google`, `Chromium`, `Mozilla`, `WebKit` and others listed in the `clang-format` [docs for BasedOnStyle](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#configurable-format-style-options).\n* `exclude-regex` [optional]: A regex to exclude files or directories that should not be checked.\n  * Default: `^$`\n  * Pattern matching is done with a POSIX `grep -E` extended regex, **not** a glob expression. You can exclude multiple patterns like this: `(hello|world)`. Build and verify your regex at [regex101.com](https://regex101.com) ([example](https://regex101.com/r/llFcLy/7)).\n* `include-regex` [optional]: A regex to include files or directories that should be checked.\n  * Default: see [`INCLUDE_REGEX`](./check.sh#77)\n  * Pattern matching is done with a POSIX `grep -E` extended regex, **not** a glob expression. You can exclude multiple patterns like this: `(hello|world)`. Build and verify your regex at [regex101.com](https://regex101.com) ([example](https://regex101.com/r/llFcLy/7)).\n\nThis action checks all C/C++/Protobuf (including Arduino `.ino` and `.pde`) files in the provided directory in the GitHub workspace are formatted correctly using `clang-format`. If no directory is provided or the provided path is not a directory in the GitHub workspace, all C/C++/Protobuf files are checked.\n\nThe following file extensions are checked by default:\n* Header files:\n  * `.h`\n  * `.H`\n  * `.hpp`\n  * `.hh`\n  * `.h++`\n  * `.hxx `\n* Source files:\n  * `.c`\n  * `.C`\n  * `.cpp`\n  * `.cc`\n  * `.c++`\n  * `.cxx`\n  * `.ino`\n  * `.pde`\n  * `.cu`\n* Protobuf files:\n  * `.proto`\n\n## Returns:\n\n* SUCCESS: zero exit-code if C/C++/Protobuf files in `check-path` are formatted correctly\n* FAILURE: nonzero exit-code if C/C++/Protobuf files in `check-path` are not formatted correctly\n\n# Usage\n\n\u003e [!WARNING]\n\u003e This action is not supported on `windows` GitHub Actions runners!\n\n## Single Path\n\nTo use this action, create a `.github/workflows/clang-format-check.yml` in your repository containing:\n\n```yaml\nname: clang-format Check\non: [push, pull_request]\njobs:\n  formatting-check:\n    name: Formatting Check\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v4\n    - name: Run clang-format style check for C/C++/Protobuf programs.\n      uses: jidicula/clang-format-action@v4.15.0\n      with:\n        clang-format-version: '13'\n        check-path: 'src'\n        fallback-style: 'Mozilla' # optional\n```\n\n## Multiple Paths\nTo use this action on multiple paths in parallel, create a `.github/workflows/clang-format-check.yml` in your repository containing:\n\n```yaml\nname: clang-format Check\non: [push, pull_request]\njobs:\n  formatting-check:\n    name: Formatting Check\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        path:\n          - 'src'\n          - 'examples'\n    steps:\n    - uses: actions/checkout@v4\n    - name: Run clang-format style check for C/C++/Protobuf programs.\n      uses: jidicula/clang-format-action@v4.15.0\n      with:\n        clang-format-version: '13'\n        check-path: ${{ matrix.path }}\n        fallback-style: 'Mozilla' # optional\n```\n\n## Multiple Paths with Exclusion Regexes\nTo use this action on multiple paths in parallel with exclusions, create a `.github/workflows/clang-format-check.yml` in your repository containing:\n\n```yaml\nname: clang-format Check\non: [push, pull_request]\njobs:\n  formatting-check:\n    name: Formatting Check\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        path:\n          - check: 'src'\n            exclude: '(hello|world)' # Exclude file paths containing \"hello\" or \"world\"\n          - check: 'examples'\n            exclude: ''              # Nothing to exclude\n    steps:\n    - uses: actions/checkout@v4\n    - name: Run clang-format style check for C/C++/Protobuf programs.\n      uses: jidicula/clang-format-action@v4.15.0\n      with:\n        clang-format-version: '13'\n        check-path: ${{ matrix.path['check'] }}\n        exclude-regex: ${{ matrix.path['exclude'] }}\n        fallback-style: 'Mozilla' # optional\n```\n\n# Who uses this?\n\n[These public repos](https://github.com/search?q=%22uses%3A+jidicula%2Fclang-format-action%22+-user%3Ajidicula\u0026type=code) use this Action.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjidicula%2Fclang-format-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjidicula%2Fclang-format-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjidicula%2Fclang-format-action/lists"}