mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 15:10:12 +01:00
The labeling script will now directly set a check status for the PR as `pending` when it marks something as dependent, and clear it when it no longer is. This emulates a check that starts when marked as dependent and runs until the last dependency lands, allowing automerge and other workflows to work cleanly. The branch protection rule will have to be updated to the new spelling. This should do the same key thing as #7113, but integrated to the new script. Assisted-by: Antigravity with Gemini
268 lines
8.5 KiB
YAML
268 lines
8.5 KiB
YAML
# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
# Exceptions. See /LICENSE for license information.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
# Update versions with:
|
|
# pre-commit autoupdate --freeze && pre-commit run -a
|
|
# See https://pre-commit.com for more information
|
|
# See https://pre-commit.com/hooks.html for more hooks
|
|
|
|
default_language_version:
|
|
python: python3 # Defaults to python2, so override it.
|
|
|
|
repos:
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
|
|
hooks:
|
|
- id: check-added-large-files
|
|
- id: check-case-conflict
|
|
- id: check-executables-have-shebangs
|
|
- id: check-merge-conflict
|
|
- id: check-symlinks
|
|
exclude: ^bazel-execroot$
|
|
- id: check-yaml
|
|
- id: detect-private-key
|
|
- id: end-of-file-fixer
|
|
exclude: '^(.*/fuzzer_corpus/.*|.*\.svg)$'
|
|
- id: mixed-line-ending
|
|
args: ['--fix=lf']
|
|
exclude: '^(.*/fuzzer_corpus/.*|.*\.svg)$'
|
|
- id: trailing-whitespace
|
|
exclude: '^(.*/fuzzer_corpus/.*|.*/testdata/.*\.golden|.*\.svg)$'
|
|
- repo: https://github.com/google/pre-commit-tool-hooks
|
|
rev: efaea7c61c774c0b1a9805fd999e754a2d19dbd1 # frozen: v1.2.5
|
|
hooks:
|
|
- id: check-google-doc-style
|
|
exclude: |
|
|
(?x)^(
|
|
.*\.agents/.*|
|
|
.*AGENTS.md
|
|
)$
|
|
- id: markdown-toc
|
|
- repo: local
|
|
hooks:
|
|
- id: fix-cc-deps
|
|
name: Fix missing C++ deps
|
|
entry: scripts/fix_cc_deps.py
|
|
language: python
|
|
files: ^.*/(BUILD|[^/]+\.(h|cpp))$
|
|
pass_filenames: false
|
|
|
|
# Formatters should be run late so that they can re-format any prior changes.
|
|
- repo: https://github.com/psf/black
|
|
rev: c6755bb741b6481d6b3d3bb563c83fa060db96c9 # frozen: 26.3.1
|
|
hooks:
|
|
- id: black
|
|
- repo: local
|
|
hooks:
|
|
- id: prettier
|
|
name: prettier
|
|
language: node
|
|
# TODO: Not upgrading to/past 3.4.0 due to list indent changes that may
|
|
# get fixed. See: https://github.com/prettier/prettier/issues/16929
|
|
additional_dependencies: ['prettier@3.3.3']
|
|
types_or: [html, javascript, json, markdown, yaml]
|
|
entry: npx prettier@3.3.3 --write --log-level=warn
|
|
- repo: local
|
|
hooks:
|
|
- id: buildifier
|
|
name: Bazel buildifier
|
|
entry: scripts/run_buildifier.py
|
|
# Beyond just formatting, explicitly fix lint warnings.
|
|
args: ['--lint=fix', '--warnings=all', '-r', '.']
|
|
language: python
|
|
files: |
|
|
(?x)^(
|
|
.*BUILD.*|
|
|
.*MODULE.bazel.*|
|
|
.*WORKSPACE.*|
|
|
.*\.bzl
|
|
)$
|
|
- id: check-bazel-mod-deps
|
|
# Check this after buildifier because buildifier may modify inputs, and
|
|
# MODULE.bazel.lock includes line/column details.
|
|
name: Check bazel mod deps
|
|
entry: scripts/bazel_mod_deps.py
|
|
language: python
|
|
files: |
|
|
(?x)^(
|
|
.*MODULE.bazel.*|
|
|
.*WORKSPACE.*
|
|
)$
|
|
- id: clang-format
|
|
name: clang-format
|
|
entry: clang-format
|
|
types_or: [c++, def]
|
|
language: python
|
|
args: ['-i']
|
|
additional_dependencies: ['clang-format==21.1.8']
|
|
|
|
- repo: local
|
|
hooks:
|
|
- id: check-header-guards
|
|
# This should run after clang-format, which may reformat a guard.
|
|
name: Check header guards
|
|
entry: scripts/check_header_guards.py
|
|
language: python
|
|
files: ^.*\.h$
|
|
- id: check-sha-filenames
|
|
# This may rename files, so it's deliberately between formatters and
|
|
# linters.
|
|
name: Check fuzzer SHA filenames
|
|
entry: scripts/check_sha_filenames.py
|
|
language: python
|
|
files: ^.*/fuzzer_corpus/.*$
|
|
- id: check-toolchain-diagnostics
|
|
name: Check toolchain diagnostics
|
|
entry: toolchain/diagnostics/check_diagnostics.py
|
|
language: python
|
|
files: |
|
|
(?x)^(
|
|
toolchain/.*\.cpp|
|
|
toolchain/.*\.h|
|
|
toolchain/diagnostics/check_diagnostics\.py|
|
|
toolchain/diagnostics/diagnostic_kind\.def
|
|
)$
|
|
pass_filenames: false
|
|
|
|
# Run linters last, as formatters and other checks may fix issues.
|
|
- repo: local
|
|
hooks:
|
|
- id: forbid-llvm-googletest
|
|
name: Checks for deps on LLVM's version of GoogleTest
|
|
entry: scripts/forbid_llvm_googletest.py
|
|
language: python
|
|
files: ^.*/BUILD$
|
|
pass_filenames: false
|
|
- repo: https://github.com/PyCQA/flake8
|
|
rev: d93590f5be797aabb60e3b09f2f52dddb02f349f # frozen: 7.3.0
|
|
hooks:
|
|
- id: flake8
|
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
rev: 'fc0f09a29bb495f4a91f00266155d6282d52485d' # frozen: v1.20.2
|
|
hooks:
|
|
- id: mypy
|
|
# Use setup.cfg to match the command line.
|
|
args:
|
|
- --config-file=setup.cfg
|
|
# This should match the requirements added in the WORKSPACE pip_install.
|
|
additional_dependencies:
|
|
- gql >= 2.0.0, < 3.0.0
|
|
- PyGitHub
|
|
- rich
|
|
- types-requests
|
|
# Exclusions are:
|
|
# - p#### scripts because they're not tested or maintained.
|
|
# - lit.cfg.py because it has multiple copies, breaking mypy.
|
|
# - `bazel_test_runner.py` which depends on Bazel-specific imports.
|
|
# - Unit tests because they sometimes violate typing, such as by
|
|
# assigning a mock to a function.
|
|
exclude: |
|
|
(?x)^(
|
|
proposals/(?!scripts/).*|
|
|
.*/lit\.cfg\.py|
|
|
examples/bazel_test_runner\.py|
|
|
.*_test\.py
|
|
)$
|
|
- repo: https://github.com/codespell-project/codespell
|
|
rev: 2ccb47ff45ad361a21071a7eedda4c37e6ae8c5a # frozen: v2.4.2
|
|
hooks:
|
|
- id: codespell
|
|
args: ['-I', '.codespell_ignore', '--uri-ignore-words-list', '*']
|
|
# Test data may contain intentional misspellings, as well as short,
|
|
# meaningless identifiers that codespell incorrectly identifies as
|
|
# typos but that we would want to detect in other contexts.
|
|
exclude: |
|
|
(?x)^(
|
|
.*/testdata/.*|
|
|
.*/fuzzer_corpus/.*
|
|
)$
|
|
- repo: https://github.com/google/pre-commit-tool-hooks
|
|
rev: efaea7c61c774c0b1a9805fd999e754a2d19dbd1 # frozen: v1.2.5
|
|
hooks:
|
|
- id: check-copyright
|
|
args:
|
|
- --copyright
|
|
- |+
|
|
Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
Exceptions. See /LICENSE for license information.
|
|
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
- --custom_format
|
|
- '\.(carbon|c|json|scss|ypp)(\.tmpl)?$'
|
|
- ''
|
|
- '// '
|
|
- ''
|
|
- --custom_format
|
|
- '\.(js|ts|mjs)$'
|
|
- '/*'
|
|
- ' * '
|
|
- ' */'
|
|
- --custom_format
|
|
- '\.(l|lpp|y)$'
|
|
- '/*'
|
|
- ''
|
|
- '*/'
|
|
- --custom_format
|
|
- '\.(plist)$'
|
|
- '<!--'
|
|
- ''
|
|
- '\-->'
|
|
- --custom_format
|
|
- '\.vim$'
|
|
- ''
|
|
- '" '
|
|
- ''
|
|
- --custom_format
|
|
- '\.scm$'
|
|
- ''
|
|
- '; '
|
|
- ''
|
|
- --custom_format
|
|
- '\.lua$'
|
|
- ''
|
|
- '-- '
|
|
- ''
|
|
exclude: |
|
|
(?x)^(
|
|
.bazelversion|
|
|
.github/pull_request_template.md|
|
|
.python-version|
|
|
compile_flags.txt|
|
|
github_tools/requirements.txt|
|
|
third_party/.*|
|
|
utils/vscode/esbuild.js|
|
|
website/.ruby-version|
|
|
website/Gemfile.lock|
|
|
.*\.def|
|
|
.*\.png|
|
|
.*\.svg|
|
|
.*/fuzzer_corpus/.*|
|
|
.*/testdata/.*\.golden
|
|
)$
|
|
- id: check-links
|
|
- repo: local
|
|
hooks:
|
|
- id: check-build-graph
|
|
name: Check build graph
|
|
entry: scripts/check_build_graph.py
|
|
language: python
|
|
files: |
|
|
(?x)^(
|
|
.*BUILD.*|
|
|
.*MODULE.bazel.*|
|
|
.*WORKSPACE.*|
|
|
.*\.bzl
|
|
)$
|
|
|
|
# This excludes third-party code, and patches to third-party code.
|
|
exclude: |
|
|
(?x)^(
|
|
MODULE.bazel.lock|
|
|
.*package-lock\.json|
|
|
bazel/bazel_clang_tidy/.*\.patch|
|
|
bazel/google_benchmark/.*\.patch|
|
|
bazel/libpfm/.*\.patch|
|
|
bazel/llvm_project/.*\.patch|
|
|
third_party/examples/.*/carbon/.*|
|
|
)$
|