name: lint

on: [push, pull_request]

jobs:
  lint:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python 3.7
        uses: actions/setup-python@v2
        with:
          python-version: 3.7
      - name: Install pre-commit hook
        run: |
          # markdownlint requires ruby >= 2.7
          sudo apt-add-repository ppa:brightbox/ruby-ng -y
          sudo apt-get update
          sudo apt-get install -y ruby2.7
          pip install pre-commit
          pre-commit install
      - name: Linting
        run: pre-commit run --all-files
      - name: Format c/cuda codes with clang-format
        uses: DoozyX/clang-format-lint-action@v0.11
        with:
          source: csrc
          extensions: h,c,cpp,hpp,cu,cuh
          style: file
      - name: Check docstring coverage
        run: |
          pip install interrogate
          interrogate -v --ignore-init-method --ignore-module --ignore-private --ignore-nested-functions --ignore-nested-classes --fail-under 95 mmdeploy
      - name: Check pylint score
        run: |
          pip install pylint
          pylint mmdeploy
