name: clang-format

on:
  pull_request:
  push:
    branches:
      - master
  schedule:
    - cron: '0 0 * * *'

jobs:
  clang-format:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Lint with clang-format
      run: |
        find -name '*.cpp' -o -name '*.h' -o -name '*.cu' -o -name '*.cuh' | xargs clang-format -i
        GIT_DIFF=$(git diff)
        if [[ -z $GIT_DIFF ]]; then
            exit 0
        fi
        echo $GIT_DIFF
        exit 1
