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
This commit is contained in:
Henry Fredrick Schreiner 2019-10-23 22:11:48 -04:00 committed by Henry Schreiner
parent fda6126d7c
commit 4376990d3a
6 changed files with 105 additions and 34 deletions

View File

@ -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

25
.github/workflows/tests.yml vendored Normal file
View File

@ -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()

27
.pre-commit-config.yaml Normal file
View File

@ -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

27
.pre-commit-nodocker.yaml Normal file
View File

@ -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

View File

@ -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

View File

@ -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"