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 pre-commit for code formatting #996

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions .github/workflows/clang_format.yml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/cmake_format.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/pre_commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: pre-commit

on:
push:
branches:
- master
- 'dev**'
pull_request:
schedule:
- cron: '0 5 * * *'

jobs:
pre-commit:
runs-on: ubuntu-22.04
env:
SKIP: no-commit-to-branch
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: apt
run: |
sudo apt update
sudo apt install -y dos2unix
- uses: pre-commit/[email protected]
61 changes: 61 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
exclude: ^.*\.dae$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.5.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
exclude: .clang-format
args: ['--unsafe']
- id: check-ast
- id: check-docstring-first
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- id: fix-byte-order-marker
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-json
- id: check-toml
- id: check-xml
- id: detect-private-key
- id: no-commit-to-branch
args: ['--branch', 'master']
- id: forbid-submodules
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
types_or: [c++, c, java, c#]
- repo: https://github.com/hhatto/autopep8
rev: v2.0.4
hooks:
- id: autopep8
args: ["--ignore=E402", "-i", "--max-line-length=120"]
- repo: https://github.com/Kr4is/cmake-format-precommit
rev: b912a5a5bce3c479f4cb52763979cc5a8319eb44
hooks:
- id: cmake-format
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.12.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2', '--preserve-quotes']
exclude: ^\.clang.*$
# - repo: https://github.com/efrecon/pre-commit-hook-lxml
# rev: v0.1.1
# hooks:
# - id: format-xml
# exclude: ^.*\.svg$
- repo: local
hooks:
- id: dos2unix
name: dos2unix
entry: dos2unix
args: ["-n", "-o"]
files: '\.(c|cpp|h|hpp|java|cs|i|m|cmake|txt|css|js|ts|html|md|txt|py|yaml|yml|csproj|rst|py\.in|csproj\.in)$'
language: system
Loading