Files
carbon-lang/.pre-commit-config.yaml
T
Jon Meow 6e5070de18 Adapting jsiek's executable semantics tooling for commit. (#237)
Notes versus what jsiek wrote:

- This adopts Bazel for building.
    - System-local versions of bison/flex are used. I found https://github.com/jmillikin/rules_bison, but those print a lot of warnings (things like -Wsign-compare IIRC) which makes builds hard to read. Plus I think the underlying bison_cc_library rule didn't work, so this would really only get a hermetic bison/flex build (helpful, but didn't seem worth more time).
    - I'm adding in a .bazeliskrc to push a somewhat more standard choice of bazel versions. I noticed I was getting unstable versions by default, possible Google-specific, but seemed good to include.
    - The `-lpthread` kludge.
- Turn all of the examples into golden tests.
    - Including adding a golden test rule.
- Fixed various style guide issues. For example:
    - Fixing function names to be CamelCase instead of snake_case (https://google.github.io/styleguide/cppguide.html#Function_Names)
    - Removed exception use (https://google.github.io/styleguide/cppguide.html#Exceptions)
    - File name fixes (https://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/cpp_style_guide.md#file-names)
- Dropped `using` of `std` names -- I believe this is preferred (maybe we should be explicit about this in the Carbon style guide)
- Switched `enum` uses to `enum class` for ease-of-identification.
- Spent some time breaking out files to hopefully be easier to read/edit pieces, and understand relations between structs.
- Added `code requires` to `syntax.ypp` to address include issues

Possibly other things -- but the fundamental structure is, I believe, unchanged. I put in the golden tests pretty early to ensure I wasn't mutating output/results.
2021-02-19 15:25:43 -08:00

96 lines
3.3 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
# 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: 6e2418c5521b7d606e72914dced3253f9ace1205 # frozen: v3.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
exclude: '^website/jekyll/site/_includes$'
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
args: ['--fix=lf']
- id: trailing-whitespace
exclude: '^(.*/testdata/.*\.golden)$'
- repo: https://github.com/google/pre-commit-tool-hooks
rev: 1d04a2848ac54d64bd6474ccec69aac45fa88414 # frozen: v1.1.1
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
- '\.6c$'
- ''
- '// '
- ''
- --custom_format
- '\.lpp$'
- '/*'
- ''
- '*/'
- --custom_format
- '\.ypp$'
- ''
- '// '
- ''
exclude: '^(website/(firebase/.firebaserc|jekyll/(Gemfile.lock|theme/.*))|.bazelversion|compile_flags.txt|.*\.def|.*/testdata/.*\.golden)$'
- id: check-google-doc-style
- id: markdown-toc
- repo: https://github.com/codespell-project/codespell
rev: 67c489d36dd4c52cbb9e4755d90c35c6231842ef # frozen: v2.0.0
hooks:
- id: codespell
args: ['-I', '.codespell_ignore']
exclude: '^website/jekyll/Gemfile.lock$'
- repo: local
hooks:
- id: proposal-list
name: Update list of proposals
description: Updates the list of proposals in proposals/README.md
entry: proposals/scripts/update_proposal_list.py
language: python
files: ^proposals/(README|p.*)\.md$
pass_filenames: false
# Formatters should be run late so that they can re-format any prior changes.
- repo: https://github.com/psf/black
rev: e66be67b9b6811913470f70c28b4d50f94d05b22 # frozen: 20.8b1
hooks:
- id: black
- repo: https://github.com/jlebar/pre-commit-hooks.git
rev: 349213c5414e360385e74f04964e6d5c43cdad36
hooks:
- id: bazel-buildifier
- id: clang-format-whole-file
types: [c++]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: 8e0d199f4004a7f226ed7974fc3883d9c702bded # frozen: v2.2.1
hooks:
- id: prettier
exclude: ^website/jekyll/theme/
# Run linters last, as formatters and other checks may fix issues.
- repo: https://gitlab.com/PyCQA/flake8
rev: bb6a530e28acab8d3551043b3e8709db8bcbac6b # frozen: 3.8.4
hooks:
- id: flake8
# We fully exclude fuzzer corpus directories as they are generated binary data.
exclude: '^(.*/fuzzer_corpus/.*)$'