diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index 1bed6513..641d3a8c 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci_test.yml @@ -47,30 +47,13 @@ jobs: lint: needs: [prepare] - if: > - needs.prepare.outputs.should_skip_ci_commit != 'true' && - needs.prepare.outputs.should_skip_ci_docs_only != 'true' - name: Lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: actions/setup-python@v6 - with: - python-version: '3.13' - - name: Install dependencies - run: | - pip install black pylint ruff - sudo apt-get install -y clang-format-15 - - - name: Lint - run: | - tests/scripts/task_lint.sh - + - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 test: - needs: [prepare] + needs: [lint, prepare] if: > needs.prepare.outputs.should_skip_ci_commit != 'true' && needs.prepare.outputs.should_skip_ci_docs_only != 'true' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dc24845b..f31f7f3f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,8 +15,29 @@ # specific language governing permissions and limitations # under the License. +# TODO(@junrushao): adding a few extra hooks: +# - Python type checking via mypy or ty +# - CMake linters +# - Conventional commits +default_install_hook_types: + - pre-commit repos: - # Standard hooks + - repo: local + hooks: + - id: check-asf-header + name: check ASF Header + entry: python tests/lint/check_asf_header.py --check + language: system + pass_filenames: false + verbose: false + - repo: local + hooks: + - id: check-file-type + name: check file types + entry: python tests/lint/check_file_type.py + language: system + pass_filenames: false + verbose: false - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 hooks: @@ -28,3 +49,31 @@ repos: - id: mixed-line-ending - id: requirements-txt-fixer - id: trailing-whitespace + - id: check-yaml + - id: check-toml + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.12.3 + hooks: + - id: ruff-check + types_or: [python, pyi, jupyter] + args: [--fix] + - id: ruff-format + types_or: [python, pyi, jupyter] + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: "v20.1.8" + hooks: + - id: clang-format + - repo: https://github.com/MarcoGorelli/cython-lint + rev: v0.16.7 + hooks: + - id: cython-lint + args: [--max-line-length=120] + - id: double-quote-cython-strings + - repo: https://github.com/scop/pre-commit-shfmt + rev: v3.12.0-2 + hooks: + - id: shfmt + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.10.0.1 + hooks: + - id: shellcheck diff --git a/README.md b/README.md index 525518e3..88083e99 100644 --- a/README.md +++ b/README.md @@ -18,5 +18,3 @@ # tvm ffi [![CI](https://github.com/apache/tvm-ffi/actions/workflows/ci_test.yml/badge.svg)](https://github.com/apache/tvm-ffi/actions/workflows/ci_test.yml) - - diff --git a/docs/_static/custom.css b/docs/_static/custom.css index 6277c6d4..088d4992 100644 --- a/docs/_static/custom.css +++ b/docs/_static/custom.css @@ -2,4 +2,4 @@ See: https://github.com/executablebooks/sphinx-book-theme/issues/732 */ #rtd-footer-container { margin: 0px !important; -} \ No newline at end of file +} diff --git a/docs/conf.py b/docs/conf.py index 8a1c5b36..e6218781 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,7 +16,6 @@ # under the License. # -*- coding: utf-8 -*- import os -import sys import tomli @@ -198,7 +197,7 @@ def footer_html():