Repository navigation
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
142 lines (133 loc) · 5.98 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
142 lines (133 loc) · 5.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò
#
# SPDX-License-Identifier: Unlicense
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: trailing-whitespace
exclude: |
(?x)^(
hw/bsp/mcx/sdk/
)
- id: end-of-file-fixer
exclude: |
(?x)^(
.idea/|
hw/bsp/mcx/sdk/
)
- id: forbid-submodules
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: codespell
args: [-w]
exclude: |
(?x)^(
lib/|
hw/bsp/mcx/sdk/
)
- repo: local
hooks:
- id: unique-example-pids
name: unique example USB PIDs
files: usb_descriptors\.c$
entry: python3 tools/check_example_pids.py
pass_filenames: false
language: system
- id: gen-doc
name: regenerate reference docs
files: ^(hw/bsp/.*/(board\.h|family\.c)|tools/get_deps\.py|test/hil/(tinyusb|hfp)\.json|\.claude/skills/build-doc/scripts/gen_doc\.py)$
entry: python3 .claude/skills/build-doc/scripts/gen_doc.py
pass_filenames: false
language: system
- id: unit-test
name: unit-test
files: ^(src/|test/unit-test/)
entry: sh -c "cd test/unit-test && ceedling test:all"
pass_filenames: false
types_or: [c, header]
language: system
# Two hooks, split by what each suite RUNS, not by what it reads: discovery is
# disjoint (test_hil*.py vs the two named suites) so nothing runs twice, but the
# file patterns overlap where both suites care. hil-test runs test_hil*.py only
# (~45s: deliberate hang and timeout simulations) and is scoped to the rig harness
# that owns them. The one part of it the selector depends on - the BottomLayer
# stdlib-closure AST guard over tools/change_impact.py and its imports - is named
# explicitly by change-impact-test instead, so a tools/ or workflow edit costs 4s
# rather than 80s of hang simulations that have nothing to say about it.
# change-impact-test runs the two selector-adjacent suites (~4s together) that read
# hw/bsp (board.cmake, FAMILY_MCUS), src (portable dirs + class include graph),
# examples (tusb_config.h, skip/only.txt), hw/mcu, the rig rosters under test/hil
# (a roster edit changes what the selector emits), .circleci (the sentinel contract
# config.yml rewrites config2.yml through) and .github/workflows (build.yml's own
# file hand-off and GITHUB_ENV guards) -- renaming a board, port dir or example
# breaks them without touching test/hil, and catching that here beats waiting for
# pre-commit CI.
# No types_or: the rig rosters (*.json) are inputs too.
# examples/device/mtp/src is in scope: test_hil_bounded parses README_TXT_CONTENT
# and md5-checks the logo header from there as its MTP fixtures.
- id: hil-test
name: hil-test
files: ^(test/hil/|examples/device/mtp/src/|tools/rtt\.py$|\.claude/skills/hil/scripts/hil_remote\.py$)
entry: python3 -m unittest discover -s test/hil/test -p 'test_hil*.py'
pass_filenames: false
language: system
- id: family-json
name: family-json
entry: sh -c "python3 tools/family_json.py fix && python3 test/hil/test/test_family_json.py"
always_run: true
pass_filenames: false
language: system
- id: change-impact-test
name: change-impact-test
files: ^(hw/bsp/|hw/mcu/|src/|examples/|test/hil/|tools/(change_impact|build|build_utils|family_json|get_deps|rtt)\.py$|\.github/(scripts|workflows)/|\.circleci/)
entry: sh -c "python3 test/hil/test/test_change_impact.py && python3 test/hil/test/test_ci_metrics.py && cd test/hil/test && python3 -m unittest -q test_hil_util.BottomLayer"
pass_filenames: false
language: system
- id: setup-toolchain-test
name: setup-toolchain-test
files: ^(\.github/actions/setup_toolchain/|test/hil/test/test_setup_toolchain\.py$)
entry: python3 test/hil/test/test_setup_toolchain.py
pass_filenames: false
language: system
# language: python, not system, for the next two hooks: their suites are
# stdlib-only except where they parse YAML (skill front matter,
# .pre-commit-config.yaml), so pre-commit's venv supplies PyYAML rather than
# relying on it being installed system-wide.
- id: claude-scripts
name: claude-scripts
files: ^(\.claude/(skills/.*/(scripts/|SKILL\.md)|test/)|tools/get_deps\.py$)
entry: python3 -m unittest discover -s .claude/test -p 'test_*.py'
pass_filenames: false
language: python
additional_dependencies: [pyyaml]
- id: drivers-coverage
name: drivers-coverage
files: ^(\.github/ci-pinned-boards\.json$|\.github/scripts/ci_set_matrix\.py$|tools/drivers_coverage_check\.py$|tools/change_impact\.py$|tools/build_utils\.py$|hw/bsp/|src/portable/|examples/|test/hil/test/test_drivers_coverage\.py$|tools/build\.py$|test/hil/test/test_ci_boards\.py$|tools/code_size\.py$|test/hil/test/test_code_size\.py$|\.github/scripts/code_size_ci\.py$|test/hil/test/test_code_size_ci\.py$|tools/membrowse_cli\.py$|test/hil/test/test_membrowse_cli\.py$|test/hil/tinyusb\.json$|test/hil/hfp\.json$)
entry: sh -c "cd test/hil/test && python3 -m unittest -q test_drivers_coverage test_ci_boards test_code_size test_code_size_ci test_membrowse_cli"
pass_filenames: false
language: python
additional_dependencies: [pyyaml, pyelftools]
- id: membrowse-targets
name: membrowse-targets
# build.py's toolchain-free target list vs a real configure: only the files that list reads
files: ^(tools/(build|build_utils|membrowse_cli)\.py|hw/bsp/.*\.(cmake|mk)|examples/.*/(skip|only)\.txt|examples/.*CMakeLists\.txt|test/hil/test/test_membrowse_targets\.py)$
entry: python3 test/hil/test/test_membrowse_targets.py
language: system
pass_filenames: false
# - id: build-fuzzer
# name: build-fuzzer
# files: ^(src/|test/fuzz/)
# language: system
# types_or: [c, header]
# entry: |
# bash -c 'export CC=clang
# export CXX=clang++
# fuzz_harness=$(ls -d test/fuzz/device/*/)
# for h in $fuzz_harness
# do
# make -C $h get-deps
# make -C $h all
# done'