name: lint

on: [push, pull_request]

jobs:
  lint:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python 3.8
        uses: actions/setup-python@v2
        with:
          python-version: 3.8
      - name: Install pre-commit hook
        run: |
          python -m 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.13
        with:
          source: src
          extensions: h,c,cpp,hpp,cu,cuh
          clangFormatVersion: 11
          style: file
      - name: Check markdown link
        uses: gaurav-nelson/github-action-markdown-link-check@v1
        with:
          use-quiet-mode: 'yes'
          use-verbose-mode: 'yes'
#          check-modified-files-only: 'yes'
          config-file: '.github/md-link-config.json'
          file-path: './README.md, ./LICENSE, ./README_zh-CN.md'
      - name: Check doc link
        run: |
          python .github/scripts/doc_link_checker.py --target README_zh-CN.md
          python .github/scripts/doc_link_checker.py --target README.md
      - name: Check docstring coverage
        run: |
          python -m pip install interrogate
          interrogate -v --ignore-init-method --ignore-magic --ignore-module --ignore-private --ignore-nested-functions --ignore-nested-classes --fail-under 80 lmdeploy
      - name: Check pylint score
        run: |
          python -m pip install pylint
          pylint lmdeploy
