Commit 4376990d3a953fa0d47c8cf9747078b3808d9fe7

Authored by Henry Fredrick Schreiner
Committed by Henry Schreiner
1 parent fda6126d

Adding github actions, precommit, and fix for travis

Adding pre-commit files

GitHub actions, and Python 3 on Travis

Fix missing pip

Adding pre-commit instructions

Using bionic

Fix

Drop extra parts, add pip

Setuptools
.github/CONTRIBUTING.md
@@ -16,16 +16,32 @@ In general, make sure the addition is well thought out and does not increase the @@ -16,16 +16,32 @@ In general, make sure the addition is well thought out and does not increase the
16 16
17 * Once you make the PR, tests will run to make sure your code works on all supported platforms 17 * Once you make the PR, tests will run to make sure your code works on all supported platforms
18 * The test coverage is also measured, and that should remain 100% 18 * The test coverage is also measured, and that should remain 100%
19 -* 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` 19 +* 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.
20 * Everything must pass clang-tidy as well, run with `-DCLANG_TIDY_FIX-ON` (make sure you use a single threaded build process!) 20 * Everything must pass clang-tidy as well, run with `-DCLANG_TIDY_FIX-ON` (make sure you use a single threaded build process!)
21 21
22 -Note that the style check is really just: 22 +
  23 +## Pre-commit
  24 +
  25 +Format is handled by pre-commit. You should install it:
23 26
24 ```bash 27 ```bash
25 -git ls-files -- '.cpp' '.hpp' | xargs clang-format -i -style=file 28 +python3 -m pip install pre-commit
  29 +```
  30 +
  31 +Then, you can run it on the items you've added to your staging area, or all files:
  32 +
26 ``` 33 ```
  34 +pre-commit run
  35 +# OR
  36 +pre-commit run --all-files
  37 +```
  38 +
  39 +
  40 +And, if you want to always use it, you can install it as a git hook (hence the name, pre-commit):
27 41
28 -And, if you want to always use it, feel free to install the git hook provided in scripts. 42 +```bash
  43 +pre-commit install
  44 +```
29 45
30 ## For developers releasing to Conan.io 46 ## For developers releasing to Conan.io
31 47
.github/workflows/tests.yml 0 → 100644
  1 +name: Tests
  2 +on: [push]
  3 +
  4 +jobs:
  5 + formatting:
  6 + name: Formatting
  7 +
  8 + runs-on: ubuntu-latest
  9 + steps:
  10 + - uses: actions/checkout@v1
  11 + - uses: actions/setup-python@v1
  12 + with:
  13 + python-version: '3.7'
  14 + architecture: 'x64'
  15 +
  16 + - name: Install pre-commit
  17 + run: python -m pip install pre-commit
  18 +
  19 + - name: Run pre-commit
  20 + run: pre-commit run --all
  21 +
  22 + - name: Display format changes
  23 + run: git diff --exit-code
  24 + if: always()
  25 +
.pre-commit-config.yaml 0 → 100644
  1 +
  2 +repos:
  3 +- repo: https://github.com/psf/black
  4 + rev: 19.3b0
  5 + hooks:
  6 + - id: black
  7 +- repo: https://github.com/pre-commit/pre-commit-hooks
  8 + rev: v2.3.0
  9 + hooks:
  10 + - id: check-added-large-files
  11 + - id: mixed-line-ending
  12 + - id: trailing-whitespace
  13 + - id: check-merge-conflict
  14 + - id: check-case-conflict
  15 + - id: check-symlinks
  16 + - id: check-yaml
  17 +- repo: local
  18 + hooks:
  19 + - id: docker-clang-format
  20 + name: Docker Clang Format
  21 + language: docker_image
  22 + types:
  23 + - c++
  24 + entry: unibeautify/clang-format:latest
  25 + args:
  26 + - -style=file
  27 + - -i
.pre-commit-nodocker.yaml 0 → 100644
  1 +
  2 +repos:
  3 +- repo: https://github.com/psf/black
  4 + rev: 19.3b0
  5 + hooks:
  6 + - id: black
  7 +- repo: https://github.com/pre-commit/pre-commit-hooks
  8 + rev: v2.3.0
  9 + hooks:
  10 + - id: check-added-large-files
  11 + - id: mixed-line-ending
  12 + - id: trailing-whitespace
  13 + - id: check-merge-conflict
  14 + - id: check-case-conflict
  15 + - id: check-symlinks
  16 + - id: check-yaml
  17 +- repo: local
  18 + hooks:
  19 + - id: clang-format
  20 + name: Clang Format
  21 + language: system
  22 + types:
  23 + - c++
  24 + entry: clang-format
  25 + args:
  26 + - -style=file
  27 + - -i
.travis.yml
@@ -49,19 +49,13 @@ matrix: @@ -49,19 +49,13 @@ matrix:
49 49
50 # GCC 7 and coverage (8 does not support lcov, wait till 9 and new lcov) 50 # GCC 7 and coverage (8 does not support lcov, wait till 9 and new lcov)
51 - compiler: gcc 51 - compiler: gcc
52 - env:  
53 - - GCC_VER=7 52 + dist: bionic
54 addons: 53 addons:
55 apt: 54 apt:
56 - sources:  
57 - - ubuntu-toolchain-r-test  
58 packages: 55 packages:
59 - - g++-7  
60 - curl 56 - curl
61 - lcov 57 - lcov
62 install: 58 install:
63 - - export CC=gcc-7  
64 - - export CXX=g++-7  
65 - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" 59 - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
66 - cd $TRAVIS_BUILD_DIR 60 - cd $TRAVIS_BUILD_DIR
67 - ". .ci/build_lcov.sh" 61 - ". .ci/build_lcov.sh"
@@ -73,16 +67,15 @@ matrix: @@ -73,16 +67,15 @@ matrix:
73 67
74 # GCC 4.8 and Conan 68 # GCC 4.8 and Conan
75 - compiler: gcc 69 - compiler: gcc
76 - env:  
77 - - GCC_VER=4.8 70 + dist: bionic
78 addons: 71 addons:
79 apt: 72 apt:
80 packages: 73 packages:
81 - - g++-4.8 74 + - python3-pip
  75 + - python3-setuptools
82 install: 76 install:
83 - - export CC=gcc-4.8  
84 - - export CXX=g++-4.8  
85 - - python -m pip install --user conan 77 + - python3 -VV
  78 + - python3 -m pip install --user conan
86 - conan user 79 - conan user
87 script: 80 script:
88 - .ci/make_and_test.sh 11 81 - .ci/make_and_test.sh 11
azure-pipelines.yml
@@ -15,23 +15,6 @@ variables: @@ -15,23 +15,6 @@ variables:
15 15
16 jobs: 16 jobs:
17 17
18 -- job: Formatting  
19 - pool:  
20 - vmImage: 'ubuntu-16.04'  
21 - steps:  
22 - - task: UsePythonVersion@0  
23 - inputs:  
24 - versionSpec: '3.7'  
25 - architecture: 'x64'  
26 - - script: python -m pip install pre-commit  
27 - displayName: Install pre-commit  
28 - - script: pre-commit run --all  
29 - displayName: Run pre-commit  
30 - - script: git diff --exit-code  
31 - displayName: Display format changes  
32 - condition: always()  
33 -  
34 -  
35 - job: ClangTidy 18 - job: ClangTidy
36 variables: 19 variables:
37 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" 20 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"