Code Monkey home page Code Monkey logo

clang-format-action's Introduction

Clang formatter action

GitHub release GitHub Repo stars GitHub last commit PRs Welcome CI

This action runs clang-format on the latest commit. Many clang-format alternatives exist, I know, but i wanted to learn how to write a GitHub action.

Also, i'll keep this updated with the latest alpine version and will try to add as many options as possible.

Usage

Example workflow:

---
name: "Clang format"

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
jobs:
  format:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.head_ref }}
          fetch-depth: 2

      - uses: jayllyz/clang-format-action@v1
        # Default options
        with:
          check: false
          style: file
          extensions: cpp,h,hpp,c
          clang-version: latest

      # commit the changes (if there are any)
      - name: Commit changes
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: "clang-format โœ…"
          branch: ${{ github.head_ref }}
...

Options

You can read more about the options here : clang style docs.

Option Description Default
check If true, will only check if the files are formatted correctly. If false, will format the files. false
style Style to use for formatting. can be: file,LLVM,GNU,Google,Chromium,Microsoft,Mozilla or Webkit. file
extensions Comma-separated list of file extensions to check. Do not include the dot. cpp,h,hpp,c
clang-version Specify the major version of clang to use. latest

Action Badge

[![clang-format](https://github.com/<OWNER>/<REPOSITORY>/actions/workflows/<WORKFLOW_FILE_NAME>/badge.svg)](https://github.com/Jayllyz/clang-format-action)

Credits

License

MIT License

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

clang-format-action's People

Contributors

dependabot[bot] avatar jayllyz avatar

Watchers

 avatar

clang-format-action's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.