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 configuration #126

Merged
merged 21 commits into from May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .clang-format
Expand Up @@ -4,7 +4,7 @@ AccessModifierOffset: 0
AlignAfterOpenBracket: Align
AlignEscapedNewlines: 'Left'
AlignOperands: 'true'
AlignTrailingComments: 'true'
AlignTrailingComments: 'false'
AllowAllArgumentsOnNextLine: 'false'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortFunctionsOnASingleLine: Empty
Expand All @@ -29,7 +29,7 @@ SpaceAfterTemplateKeyword: 'false'
SpaceBeforeParens: ControlStatements
SpacesInAngles: 'false'
SpaceInEmptyParentheses: false
Standard: Cpp11
Standard: c++14
TabWidth: '4'
UseTab: Never

Expand Down
1 change: 0 additions & 1 deletion .clang-format-ignore

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/make-changelog-md.sh
Expand Up @@ -7,4 +7,3 @@ pcregrep -M "^${tag}.*\n\^\^\^\^+.*\n(.*\n)+?(\^\^\^\^+|^---+)$" CHANGELOG.rst \
| tail -n +3 \
| head -n -2 \
| pandoc --from=rst --to=markdown

33 changes: 9 additions & 24 deletions .github/workflows/style_check.yml
Expand Up @@ -2,47 +2,32 @@ name: Style check

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
# Trigger on pull requests.
pull_request:

# Trigger on pushes to the mainline branches and version tags. This prevents building commits
# Trigger on pushes to the mainline branches. This prevents building commits
# twice when the pull request source branch is in the same repository.
push:
branches:
- "master"

# Trigger on request.
workflow_dispatch:

jobs:
style_checks:
name: Run ${{ matrix.name }}
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
container:
image: glotzerlab/ci:2021.05-clang10_py38
options: -u 0
strategy:
matrix:
include:
- name: clang_format
command: ./run-clang-format.py -r .
- name: flake8
command: flake8
- name: yapf
command: yapf -d -r .

steps:
- uses: actions/checkout@v2.3.4
- name: Execute ${{ matrix.name }}
run: ${{ matrix.command }}
- uses: actions/checkout@v2.3.4
- uses: actions/setup-python@v2.2.2
- uses: pre-commit/action@v2.0.2
with:
extra_args: --all-files --hook-stage manual clang-format

# This job is used to provide a single requirement for branch merge conditions.
checks_complete:
name: Style check
needs: [style_checks]
needs: [pre-commit]
runs-on: ubuntu-latest

steps:
Expand Down
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,34 @@
ci:
skip: [clang-format]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v3.4.0'
hooks:
- id: end-of-file-fixer
exclude_types: [svg]
- id: trailing-whitespace
exclude_types: [svg]
- id: check-json
- id: check-yaml
- id: check-case-conflict
- repo: https://github.com/google/yapf
rev: 'v0.31.0'
hooks:
- id: yapf
- repo: https://gitlab.com/pycqa/flake8
rev: '3.9.1'
hooks:
- id: flake8
args:
- --show-source
additional_dependencies:
- pep8-naming
- flake8-docstrings
- flake8-rst-docstrings
- repo: https://github.com/glotzerlab/pre-commit-clang-format
rev: v1.0.0
hooks:
- id: clang-format
stages: [manual]
exclude: (?:^extern/)
4 changes: 2 additions & 2 deletions .vscode/settings.json
Expand Up @@ -38,7 +38,7 @@
"dist": true,
"doc/build": true,
"doc/_build": true,
"*.sublime-workspace": true,
"*.sublime-workspace": true
},
"cSpell.enableFiletypes": [
"cuda"
Expand Down Expand Up @@ -86,5 +86,5 @@
"unmap",
"verts",
"yapf"
],
]
}
1 change: 0 additions & 1 deletion ContributorAgreement.md
Expand Up @@ -26,4 +26,3 @@ you are authorized to sign this contract on behalf of your company (if identifie
Based on the Sun Contributor Agreement - version 1.5.
This document is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License
http://creativecommons.org/licenses/by-sa/3.0/