All Projects → jidicula → clang-format-action

jidicula / clang-format-action

Licence: MIT license
GitHub Action for clang-format checking

Programming Languages

shell
77523 projects
C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language
Cuda
1817 projects
processing
702 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to clang-format-action

Android-CICD
This repo demonstrates how to work on CI/CD for Mobile Apps 📱 using Github Actions 💊 + Firebase Distribution 🎉
Stars: ✭ 37 (-22.92%)
Mutual labels:  linter, actions, github-actions
assign-one-project-github-action
Automatically add an issue or pull request to specific GitHub Project(s) when you create and/or label them.
Stars: ✭ 140 (+191.67%)
Mutual labels:  actions, github-actions, github-action
clojure-dependency-update-action
A simple GitHub Actions job to create Pull Requests for outdated dependencies in clojure projects
Stars: ✭ 37 (-22.92%)
Mutual labels:  actions, github-actions, github-action
changed-files
Github action to retrieve all (added, copied, modified, deleted, renamed, type changed, unmerged, unknown) files and directories.
Stars: ✭ 733 (+1427.08%)
Mutual labels:  actions, github-actions, github-action
action-sync-node-meta
GitHub Action that syncs package.json with the repository metadata.
Stars: ✭ 25 (-47.92%)
Mutual labels:  actions, github-actions, github-action
setup-jdk
(DEPRECATED) Set up your GitHub Actions workflow with a specific version of AdoptOpenJDK
Stars: ✭ 32 (-33.33%)
Mutual labels:  actions, github-actions, github-action
megalinter
🦙 Mega-Linter analyzes 48 languages, 22 formats, 19 tooling formats, excessive copy-pastes, spelling mistakes and security issues in your repository sources with a GitHub Action, other CI tools or locally.
Stars: ✭ 534 (+1012.5%)
Mutual labels:  formatting, linter, github-actions
action-netlify-deploy
🙌 Netlify deployments via GitHub actions
Stars: ✭ 32 (-33.33%)
Mutual labels:  actions, github-actions, github-action
qodana-action
⚙️ Scan your Java, Kotlin, PHP, Python, JavaScript, TypeScript projects at GitHub with Qodana
Stars: ✭ 112 (+133.33%)
Mutual labels:  actions, github-actions, github-action
overview
Automate your workflows with GitHub actions for MATLAB.
Stars: ✭ 40 (-16.67%)
Mutual labels:  actions, github-actions, github-action
recent-activity
Add your recent activity to your profile readme!
Stars: ✭ 87 (+81.25%)
Mutual labels:  actions, github-actions, github-action
github-run-tests-action
mabl Github Actions implementation
Stars: ✭ 39 (-18.75%)
Mutual labels:  actions, github-actions, github-action
nrwl-nx-action
A GitHub Action to wrap Nrwl Nx commands in your workflows.
Stars: ✭ 163 (+239.58%)
Mutual labels:  actions, github-actions, github-action
ssh2actions
Connect to GitHub Actions VM via SSH for interactive debugging
Stars: ✭ 62 (+29.17%)
Mutual labels:  actions, github-actions, github-action
build-godot-action
GitHub action that builds a Godot project for multiple platforms
Stars: ✭ 62 (+29.17%)
Mutual labels:  actions, github-actions, github-action
rubocop-linter-action
Rubocop Linter Action: A GitHub Action to run Rubocop against your code!
Stars: ✭ 86 (+79.17%)
Mutual labels:  linter, actions, github-actions
Format.cmake
💅 Stylize your code! Automatic clang-format and cmake-format targets for CMake.
Stars: ✭ 94 (+95.83%)
Mutual labels:  linter, clang-format
cfn-lint-action
GitHub Action for interacting with CloudFormation Linter
Stars: ✭ 41 (-14.58%)
Mutual labels:  linter, github-actions
sentry-releases-action
A GitHub action that creates releases for Sentry.io.
Stars: ✭ 38 (-20.83%)
Mutual labels:  github-actions, github-action
arduino-lint-action
GitHub Actions action to check Arduino projects for problems
Stars: ✭ 20 (-58.33%)
Mutual labels:  linter, github-actions

ubuntu-18.04 Tests ubuntu-20.04 Tests ubuntu-22.04 Tests

shell-lint

clang-format-action

GitHub Action for clang-format checks. Note that this Action does NOT format your code for you - it only verifies that your repository's code follows your project's formatting conventions.

You 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). 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.

Versions supported

  • clang-format-3.9
  • clang-format-4.0
  • clang-format-5.0
  • clang-format-6.0
  • clang-format-7
  • clang-format-8
  • clang-format-9
  • clang-format-10
  • clang-format-11
  • clang-format-12
  • clang-format-13
  • clang-format-14
  • clang-format-15

Do you find this useful?

You can sponsor me here!

Inputs

  • clang-format-version [optional]: The version of clang-format that you want to run on your codebase.
  • check-path [optional]: The path to the directory in the repo that should be checked for C/C++/Protobuf formatting.
    • Default: .
    • 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/.
  • fallback-style [optional]: The fallback style for clang-format if no .clang-format file exists in your repository.
    • Default: llvm
    • Available values: LLVM, Google, Chromium, Mozilla, WebKit and others listed in the clang-format docs for BasedOnStyle.
  • exclude-regex [optional]: A regex to exclude files or directories that should not be checked.
    • Default: ^$
    • 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 https://regex101.com .
  • include-regex [optional]: A regex to include files or directories that should be checked.
    • Default: ^.*\.((((c|C)(c|pp|xx|\+\+)?$)|((h|H)h?(pp|xx|\+\+)?$))|(ino|pde|proto|cu))$
    • 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 https://regex101.com .

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

The following file extensions are checked by default:

  • Header files:
    • .h
    • .H
    • .hpp
    • .hh
    • .h++
    • .hxx
  • Source files:
    • .c
    • .C
    • .cpp
    • .cc
    • .c++
    • .cxx
    • .ino
    • .pde
    • .cu
  • Protobuf files:
    • .proto

Returns:

  • SUCCESS: zero exit-code if C/C++/Protobuf files in check-path are formatted correctly
  • FAILURE: nonzero exit-code if C/C++/Protobuf files in check-path are not formatted correctly

Usage

⚠️This action does not run on windows GitHub Actions runners!

Single Path

To use this action, create a .github/workflows/clang-format-check.yml in your repository containing:

name: clang-format Check
on: [push, pull_request]
jobs:
  formatting-check:
    name: Formatting Check
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Run clang-format style check for C/C++/Protobuf programs.
      uses: jidicula/[email protected]
      with:
        clang-format-version: '13'
        check-path: 'src'
        fallback-style: 'Mozilla' # optional

Multiple Paths

To use this action on multiple paths in parallel, create a .github/workflows/clang-format-check.yml in your repository containing:

name: clang-format Check
on: [push, pull_request]
jobs:
  formatting-check:
    name: Formatting Check
    runs-on: ubuntu-latest
    strategy:
      matrix:
        path:
          - 'src'
          - 'examples'
    steps:
    - uses: actions/checkout@v3
    - name: Run clang-format style check for C/C++/Protobuf programs.
      uses: jidicula/[email protected]
      with:
        clang-format-version: '13'
        check-path: ${{ matrix.path }}
        fallback-style: 'Mozilla' # optional

Multiple Paths with Exclusion Regexes

To use this action on multiple paths in parallel with exclusions, create a .github/workflows/clang-format-check.yml in your repository containing:

name: clang-format Check
on: [push, pull_request]
jobs:
  formatting-check:
    name: Formatting Check
    runs-on: ubuntu-latest
    strategy:
      matrix:
        path:
          - check: 'src'
            exclude: '(hello|world)' # Exclude file paths containing "hello" or "world"
          - check: 'examples'
            exclude: ''              # Nothing to exclude
    steps:
    - uses: actions/checkout@v3
    - name: Run clang-format style check for C/C++/Protobuf programs.
      uses: jidicula/[email protected]
      with:
        clang-format-version: '13'
        check-path: ${{ matrix.path['check'] }}
        exclude-regex: ${{ matrix.path['exclude'] }}
        fallback-style: 'Mozilla' # optional

Who uses this?

These public repos use this Action.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].