diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..904e4f4 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,26 @@ +name: Clang format + +on: [pull_request] + +jobs: + clang-format-8: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Run clang-foramt on changed files + run: | + set -x + git fetch origin ${{ github.event.pull_request.base.ref }} + git fetch origin pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }} + BASE_COMMIT=$(git rev-parse ${{ github.event.pull_request.base.sha }}) + COMMIT_FILES=$(git diff --name-only ${BASE_COMMIT} | grep -i -v LinkDef) + RESULT_OUTPUT=$(git-clang-format-8 --commit ${BASE_COMMIT} --diff --binary $(which clang-format-8) ${COMMIT_FILES}) + if [ "$RESULT_OUTPUT" == "no modified files to format" ] || [ "$RESULT_OUTPUT" == "clang-format did not modify any files" ]; then + exit 0 + else + git-clang-format-8 --commit $BASE_COMMIT --diff --binary $(which clang-format-8) + echo "$RESULT_OUTPUT" + exit 1 + fi diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7fdcd0b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,56 +0,0 @@ -language: cpp -matrix: - include: - - os: osx - osx_image: xcode10.2 - env: TOOL=test - - os: linux - dist: xenial - env: TOOL=test - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - gcc-8 - - g++-8 - - cmake - - libboost-system1.58-dev - - libboost-filesystem1.58-dev - - libboost-test1.58-dev - - libboost-program-options1.58-dev - - os: linux - dist: xenial - env: TOOL=clang-format - addons: - apt: - sources: - - llvm-toolchain-xenial-7 - packages: - - clang-format-7 - compiler: clang - branches: - only: - - dev -before_script: - - if [[ $TOOL == "test" ]]; then sed -i -e 's/test\/TestSystem.cxx//g' CMakeLists.txt; fi - - if [[ $TOOL == "test" ]]; then mkdir build; cd build; fi -script: - - if [[ $TOOL == "test" ]] && [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake ..; fi - - if [[ $TOOL == "test" ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake .. -DCMAKE_C_COMPILER=/usr/bin/gcc-8 -DCMAKE_CXX_COMPILER=/usr/bin/g++-8; fi - - if [[ $TOOL == "test" ]]; then make -j; fi - - if [[ $TOOL == "test" ]]; then make test; fi - - if [[ $TOOL == "clang-format" ]] && [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - cd $TRAVIS_BUILD_DIR; - BASE_COMMIT=$(git rev-parse $TRAVIS_BRANCH); - COMMIT_FILES=$(git diff --name-only $BASE_COMMIT | grep -i -v LinkDef); - RESULT_OUTPUT="$(git-clang-format-7 --commit $BASE_COMMIT --diff --binary `which clang-format-7` $COMMIT_FILES)"; - if [ "$RESULT_OUTPUT" == "no modified files to format" ] || [ "$RESULT_OUTPUT" == "clang-format did not modify any files" ] ; then - exit 0; - else - echo "$RESULT_OUTPUT"; - exit 1; - fi - fi -notifications: - email: false