Skip to content

Commit

Permalink
Adding github actions, precommit, and fix for travis
Browse files Browse the repository at this point in the history
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
  • Loading branch information
henryiii committed Oct 24, 2019
1 parent fda6126 commit 4376990
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 34 deletions.
24 changes: 20 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

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):

And, if you want to always use it, feel free to install the git hook provided in scripts.
```bash
pre-commit install
```

## For developers releasing to Conan.io

Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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 changes: 27 additions & 0 deletions .pre-commit-nodocker.yaml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 6 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
17 changes: 0 additions & 17 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 4376990

Please sign in to comment.