# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # SPDX-License-Identifier: Apache-2.0 ci: autofix_commit_msg: | [pre-commit.ci] auto code formatting autofix_prs: false autoupdate_branch: '' autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' autoupdate_schedule: quarterly skip: [lychee, check-precommit-installed, secret-scan-trufflehog] submodules: false # Please update the rev: SHAs below with this command: # pre-commit autoupdate --freeze repos: # Runs first so a leaked credential blocks the commit before any formatter runs. # Self-installing: the hook downloads a pinned, checksum-verified trufflehog on # first use (no manual install). Skipped on pre-commit.ci; Pulse CI enforces server-side. - repo: https://github.com/NVIDIA/security-workflows rev: c736f0454dc99764a66af6b906adfcdfbf621985 # frozen: v0.4.0 hooks: - id: secret-scan-trufflehog - repo: https://github.com/astral-sh/ruff-pre-commit rev: 25bcf95026b96e2dd3c0aec3090c3d6ef6ca2e6c # frozen: v0.17.3 hooks: - id: ruff-check args: [--fix, --show-fixes] exclude: (^cuda_bindings_(?:12|13)/cuda/bindings/_internal/_fast_enum\.py$)|(.*\.pyi$) - id: ruff-format exclude: .*\.pyi$ - repo: https://github.com/pre-commit/mirrors-clang-format rev: 98ad4ddb9c057de2f5b9e93e44e6db959807d68c # frozen: v23.1.3 hooks: - id: clang-format types_or: [c, c++, cuda] exclude: ^cuda_core/(cuda/core/_include/(dlpack|aoti_shim)\.h|third_party/) - repo: local hooks: - id: check-precommit-installed name: Warn if the pre-commit git hook is not installed entry: python ./toolshed/check_precommit_installed.py language: python always_run: true pass_filenames: false verbose: true - id: check-cuda-core-bindings-floor name: Check cuda-core bindings floor declarations and documentation entry: python ./toolshed/check_cuda_core_bindings_floor.py language: python files: ^(cuda_core/pyproject\.toml|cuda_core/cuda/core/_bindings_floor\.py|cuda_core/docs/source/.*\.rst|toolshed/check_cuda_core_bindings_floor\.py)$ pass_filenames: false - id: check-spdx name: Check SPDX Headers entry: python ./toolshed/check_spdx.py language: python additional_dependencies: - https://files.pythonhosted.org/packages/cc/20/ff623b09d963f88bfde16306a54e12ee5ea43e9b597108672ff3a408aad6/pathspec-0.12.1-py3-none-any.whl exclude: '(.*pixi\.lock)|(\.git_archival\.txt)|(.*\.patch$)|(^cuda_core/cuda/core/_vendored/)|(^cuda_core/third_party/)' args: ["--fix"] - id: check-cython-not-none name: Check cdef-class-annotated def parameters carry 'not None' entry: python ./toolshed/check_cython_not_none.py language: python files: ^cuda_core/cuda/.*\.pyx$ - id: check-generated-file-seals name: Check generated-file seals entry: python ./toolshed/check_generated_file_seals.py language: python files: ^cuda_bindings_(?:12|13)/ types: [text] - id: check-bindings-config name: Validate bindings registry and package metadata entry: python -m ci.tools.bindings_config --check-package-metadata language: python additional_dependencies: [packaging==26.0, pyyaml==6.0.3] files: '^(ci/versions\.yml|ci/tools/bindings_config\.py|cuda_bindings_(?:12|13)/(pyproject|pixi)\.toml|cuda_python/(?:pyproject\.toml|setup\.py)|cuda_core/pyproject\.toml|cuda_core/cuda/core/_bindings_floor\.py)$' pass_filenames: false - id: check-pixi-cuda-version name: Check pixi cuda-version pins track ci/versions.yml entry: python -m ci.tools.check_pixi_cuda_version language: python additional_dependencies: [packaging==26.0, pyyaml==6.0.3] files: '^(ci/versions\.yml|ci/tools/(bindings_config|check_pixi_cuda_version)\.py|cuda_bindings_(?:12|13)/pixi\.toml|cuda_core/pixi\.toml)$' pass_filenames: false - id: check-mempool-hygiene name: Check tests do not create uncapped memory pools entry: python ./ci/tools/check_mempool_hygiene.py language: python files: '^(cuda_core|cuda_bindings_1[23])/tests/.*\.py$' - id: no-markdown-in-docs-source name: Prevent markdown files in docs/source directories entry: bash -c args: - 'for file in "$@"; do >&2 echo "error: markdown file "$file" found in a docs/source directory. Only reST (.rst) is allowed"; done && exit 1' - "_" # fake script name, because bash considers $0 (the first argument) to be the script name language: system files: '^.*/docs/source/.*\.md$' # The imported CUDA 12.9 documentation retains its historical MyST # sources; new documentation elsewhere must continue to use reST. exclude: '^cuda_bindings_12/docs/source/' - id: stubgen-pyx-cuda-core name: Generate .pyi stubs for cuda_core entry: python -X utf8 -m stubgen_pyx cuda_core/cuda --continue-on-error --include-private language: python files: ^cuda_core/cuda/.*\.(pyx|pxd)$ pass_filenames: false additional_dependencies: - stubgen-pyx==0.2.23 - Cython==3.2.9 # Link checking for authored documentation files - repo: local hooks: - id: lychee name: lychee (authored documentation) entry: python ./ci/tools/run_lychee.py language: python # Update this shared pin manually until Dependabot releases support for # local-hook dependencies: https://github.com/dependabot/dependabot-core/issues/15489 # Once supported, add lychee-bin to the allowlist in .github/dependabot.yml. additional_dependencies: &lychee_dependencies - lychee-bin==0.24.2 types: [text] require_serial: true args: - --cache - --max-cache-age=3d - --max-concurrency=4 - --max-retries=3 - --no-progress files: '\.(md|rst)$' exclude: ^qa/ # Generated HTML is checked explicitly after the documentation build. - id: lychee-rendered name: lychee (rendered documentation) entry: python ./ci/tools/run_lychee.py --rendered language: python additional_dependencies: *lychee_dependencies stages: [manual] pass_filenames: false always_run: true args: - --cache - --max-cache-age=3d - --max-concurrency=16 - --host-concurrency=2 - --host-request-interval=250ms - --max-retries=3 - --retry-wait-time=5 - --timeout=30 - --no-progress # Standard hooks - repo: https://github.com/pre-commit/pre-commit-hooks rev: "3e8a8703264a2f4a69428a0aa4dcb512790b2c8c" # frozen: v6.0.0 hooks: - id: check-added-large-files exclude: '^(?:cuda_bindings_13/cuda/bindings/(?:nvml\.pyx|_v2/driver\.pyx)|cuda_bindings_12/cuda/bindings/(?:driver\.pyx|runtime\.pyx\.in|nvml\.pyx)|cuda_bindings_(?:12|13)/pixi\.lock|qa/.*\.svg)$' - id: check-case-conflict - id: check-docstring-first - id: check-merge-conflict - id: check-symlinks - id: check-toml - id: check-yaml - id: debug-statements - id: end-of-file-fixer exclude: &gen_exclude '^(?:cuda_python/README\.md|(?:.*/)?CLAUDE\.md|(?:.*/)?\.git_archival\.txt|cuda_bindings_(?:12|13)/cuda/bindings/.*\.in?|cuda_bindings_(?:12|13)/docs/source/module/.*\.rst?|.*\.pyi|\.github/actions/upgrade-ca-certificates/impacted-intermediates\.json)$' - id: mixed-line-ending - id: trailing-whitespace exclude: | (?x)^(?: cuda_python/README\.md| cuda_bindings_(?:12|13)/cuda/bindings/.*\.in?| cuda_bindings_(?:12|13)/docs/source/module/.*\.rst?| .*\.patch$ )$ # Checking for common mistakes - repo: https://github.com/pre-commit/pygrep-hooks rev: "3a6eb0fadf60b3cccfd80bad9dbb6fae7e47b316" # frozen: v1.10.0 hooks: - id: rst-backticks - id: rst-directive-colons - id: rst-inline-touching-normal - repo: https://github.com/pre-commit/mirrors-mypy rev: ad26ebfa797fcb9b8f83275937c1c1d6e126719c # frozen: v2.4.1 hooks: - id: mypy alias: mypy-pathfinder name: mypy-pathfinder files: ^cuda_pathfinder/cuda/.*\.py$ # Exclude tests directory args: [--config-file=cuda_pathfinder/pyproject.toml] - id: mypy alias: mypy-cuda-core name: mypy-cuda-core files: ^cuda_core/cuda/.*\.(py|pyi)$ exclude: ^cuda_core/cuda/core/_vendored/ pass_filenames: false args: [--config-file=cuda_core/pyproject.toml, cuda_core/cuda/core] additional_dependencies: - numpy==2.4.2 - repo: https://github.com/rhysd/actionlint rev: "914e7df21a07ef503a81201c76d2b11c789d3fca" # frozen: v1.7.12 hooks: - id: actionlint args: ["-shellcheck="] exclude: ^\.github/workflows/coverage.yml$ - repo: https://github.com/MarcoGorelli/cython-lint rev: "35dbc940c2bd4499ebf39aba00ad717e05cec9b5" # frozen: v0.22.0 hooks: - id: cython-lint # Some rules (e.g. "inline" on a function declared in a .pxd) match # declarations in one file against implementations in another, and the # linter only remembers that within a single invocation. Pre-commit # splits filenames across parallel processes and only passes changed # files, so a .pyx edited without its .pxd would escape the check. # Instead, whenever any Cython file under these trees changes, lint # all of them in one process. Generated cuda_bindings_* and # third-party submodules are not listed. args: [--no-pycodestyle, cuda_core/cuda] files: ^cuda_core/cuda pass_filenames: false require_serial: true additional_dependencies: - Cython==3.2.9 default_language_version: python: python3