Skip to content

Commit

Permalink
Add pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
kursatyurt committed Mar 16, 2023
1 parent b48fe3e commit 1a83235
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Proposed Changes
*Give a brief overview of your contribution here in a few sentences.*



## Related Work
Expand All @@ -14,5 +14,6 @@
- [ ] I am submitting my contribution to the develop branch.
- [ ] My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
- [ ] My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
- [ ] I used the pre-commit hook to prevent dirty commits and used `pre-commit run --all` to format old commits.
- [ ] I have added a test case that demonstrates my contribution, if necessary.
- [ ] I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.
30 changes: 30 additions & 0 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Code Style
on:
pull_request:
paths:
- "**.[ch]pp"
- "**.[ch]"
- "**.cfg"
- "**.py"

jobs:
formatting:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.10'
check-latest: true
- name: Install pre-commit
run: pip install pre-commit
- name: Run checks
run: pre-commit run -a -v
- name: Git status
if: always()
run: git status
- name: Full diff
if: always()
run: git diff
62 changes: 62 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
repos:
# Official repo for the clang-format hook
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v15.0.7"
hooks:
- id: clang-format
exclude: |
(?x)^(
^Common/include/CConfig.hpp|
^Common/include/option_structure.hpp|
^Common/src/CConfig.cpp|
^SU2_CFD|
^externals|
^subprojects|
^TestCases|
^legacy
)
types_or: [c++, c]
# black repo for python formatting
- repo: https://github.com/ambv/black
rev: 22.6.0
hooks:
- id: black
exclude: |
(?x)^(
^SU2_CFD|
^externals|
^subprojects|
^TestCases|
^legacy
)
# Official repo for default hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
hooks:
- id: mixed-line-ending
exclude: |
(?x)^(
^SU2_CFD|
^externals|
^subprojects|
^TestCases|
^legacy
)
- id: trailing-whitespace
exclude: |
(?x)^(
^SU2_CFD|
^externals|
^subprojects|
^TestCases|
^legacy
)
- id: end-of-file-fixer
exclude: |
(?x)^(
^SU2_CFD|
^externals|
^subprojects|
^TestCases|
^legacy
)

0 comments on commit 1a83235

Please sign in to comment.