diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f09e1f28..c97edaa2 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -16,16 +16,32 @@ In general, make sure the addition is well thought out and does not increase the * Once you make the PR, tests will run to make sure your code works on all supported platforms * The test coverage is also measured, and that should remain 100% -* Formatting should be done with clang-format, otherwise the format check will not pass. However, it is trivial to apply this to your PR, so don't worry about this check. If you do have clang-format, just run `scripts/check_style.sh` +* Formatting should be done with pre-commit, otherwise the format check will not pass. However, it is trivial to apply this to your PR, so don't worry about this check. If you do want to run it, see below. * Everything must pass clang-tidy as well, run with `-DCLANG_TIDY_FIX-ON` (make sure you use a single threaded build process!) -Note that the style check is really just: + +## Pre-commit + +Format is handled by pre-commit. You should install it: ```bash -git ls-files -- '.cpp' '.hpp' | xargs clang-format -i -style=file +python3 -m pip install pre-commit ``` -And, if you want to always use it, feel free to install the git hook provided in scripts. +Then, you can run it on the items you've added to your staging area, or all files: + +``` +pre-commit run +# OR +pre-commit run --all-files +``` + + +And, if you want to always use it, you can install it as a git hook (hence the name, pre-commit): + +```bash +pre-commit install +``` ## For developers releasing to Conan.io diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..fb9b941d --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,25 @@ +name: Tests +on: [push] + +jobs: + formatting: + name: Formatting + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + with: + python-version: '3.7' + architecture: 'x64' + + - name: Install pre-commit + run: python -m pip install pre-commit + + - name: Run pre-commit + run: pre-commit run --all + + - name: Display format changes + run: git diff --exit-code + if: always() + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..937cce32 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,27 @@ + +repos: +- repo: https://github.com/psf/black + rev: 19.3b0 + hooks: + - id: black +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-added-large-files + - id: mixed-line-ending + - id: trailing-whitespace + - id: check-merge-conflict + - id: check-case-conflict + - id: check-symlinks + - id: check-yaml +- repo: local + hooks: + - id: docker-clang-format + name: Docker Clang Format + language: docker_image + types: + - c++ + entry: unibeautify/clang-format:latest + args: + - -style=file + - -i diff --git a/.pre-commit-nodocker.yaml b/.pre-commit-nodocker.yaml new file mode 100644 index 00000000..5fcaf3e5 --- /dev/null +++ b/.pre-commit-nodocker.yaml @@ -0,0 +1,27 @@ + +repos: +- repo: https://github.com/psf/black + rev: 19.3b0 + hooks: + - id: black +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-added-large-files + - id: mixed-line-ending + - id: trailing-whitespace + - id: check-merge-conflict + - id: check-case-conflict + - id: check-symlinks + - id: check-yaml +- repo: local + hooks: + - id: clang-format + name: Clang Format + language: system + types: + - c++ + entry: clang-format + args: + - -style=file + - -i diff --git a/.travis.yml b/.travis.yml index abf69084..831aa364 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,19 +49,13 @@ matrix: # GCC 7 and coverage (8 does not support lcov, wait till 9 and new lcov) - compiler: gcc - env: - - GCC_VER=7 + dist: bionic addons: apt: - sources: - - ubuntu-toolchain-r-test packages: - - g++-7 - curl - lcov install: - - export CC=gcc-7 - - export CXX=g++-7 - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" - cd $TRAVIS_BUILD_DIR - ". .ci/build_lcov.sh" @@ -73,16 +67,15 @@ matrix: # GCC 4.8 and Conan - compiler: gcc - env: - - GCC_VER=4.8 + dist: bionic addons: apt: packages: - - g++-4.8 + - python3-pip + - python3-setuptools install: - - export CC=gcc-4.8 - - export CXX=g++-4.8 - - python -m pip install --user conan + - python3 -VV + - python3 -m pip install --user conan - conan user script: - .ci/make_and_test.sh 11 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0c894b89..180e2973 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -15,23 +15,6 @@ variables: jobs: -- job: Formatting - pool: - vmImage: 'ubuntu-16.04' - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.7' - architecture: 'x64' - - script: python -m pip install pre-commit - displayName: Install pre-commit - - script: pre-commit run --all - displayName: Run pre-commit - - script: git diff --exit-code - displayName: Display format changes - condition: always() - - - job: ClangTidy variables: CXX_FLAGS: "-Werror -Wcast-align -Wfloat-equal -Wimplicit-atomic-properties -Wmissing-declarations -Woverlength-strings -Wshadow -Wstrict-selector-match -Wundeclared-selector -Wunreachable-code -std=c++11"