godot-affected-checks 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- godot_affected_checks-0.1.0/LICENSE +21 -0
- godot_affected_checks-0.1.0/PKG-INFO +295 -0
- godot_affected_checks-0.1.0/README.md +271 -0
- godot_affected_checks-0.1.0/godot_affected_checks.egg-info/PKG-INFO +295 -0
- godot_affected_checks-0.1.0/godot_affected_checks.egg-info/SOURCES.txt +29 -0
- godot_affected_checks-0.1.0/godot_affected_checks.egg-info/dependency_links.txt +1 -0
- godot_affected_checks-0.1.0/godot_affected_checks.egg-info/entry_points.txt +4 -0
- godot_affected_checks-0.1.0/godot_affected_checks.egg-info/requires.txt +9 -0
- godot_affected_checks-0.1.0/godot_affected_checks.egg-info/top_level.txt +1 -0
- godot_affected_checks-0.1.0/godot_checks/__init__.py +3 -0
- godot_affected_checks-0.1.0/godot_checks/addon/bench.gd +135 -0
- godot_affected_checks-0.1.0/godot_checks/addon/check.gd +68 -0
- godot_affected_checks-0.1.0/godot_checks/addon/runner.gd +26 -0
- godot_affected_checks-0.1.0/godot_checks/addon/runner.tscn +6 -0
- godot_affected_checks-0.1.0/godot_checks/cli.py +379 -0
- godot_affected_checks-0.1.0/godot_checks/config.py +56 -0
- godot_affected_checks-0.1.0/godot_checks/gdscript.py +289 -0
- godot_affected_checks-0.1.0/godot_checks/godot.py +59 -0
- godot_affected_checks-0.1.0/godot_checks/graphify/__init__.py +0 -0
- godot_affected_checks-0.1.0/godot_checks/graphify/extractor.py +175 -0
- godot_affected_checks-0.1.0/godot_checks/graphify/install.py +107 -0
- godot_affected_checks-0.1.0/godot_checks/mcp_server.py +93 -0
- godot_affected_checks-0.1.0/godot_checks/project.py +349 -0
- godot_affected_checks-0.1.0/godot_checks/py.typed +0 -0
- godot_affected_checks-0.1.0/godot_checks/runner.py +244 -0
- godot_affected_checks-0.1.0/godot_checks/select.py +162 -0
- godot_affected_checks-0.1.0/pyproject.toml +45 -0
- godot_affected_checks-0.1.0/setup.cfg +4 -0
- godot_affected_checks-0.1.0/tests/test_e2e.py +80 -0
- godot_affected_checks-0.1.0/tests/test_features.py +136 -0
- godot_affected_checks-0.1.0/tests/test_unit.py +241 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 remnantlab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: godot-affected-checks
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Run only the Godot tests a change can reach: GDScript dependency graph, headless runner for plain checks, GUT and gdUnit4.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/remnantlab/godot-affected-checks
|
|
7
|
+
Project-URL: Issues, https://github.com/remnantlab/godot-affected-checks/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/remnantlab/godot-affected-checks/blob/main/CHANGELOG.md
|
|
9
|
+
Keywords: godot,gdscript,testing,ci,gut,gdunit4,test-impact-analysis
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: Software Development :: Testing
|
|
12
|
+
Classifier: Topic :: Games/Entertainment
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: tree-sitter>=0.23
|
|
17
|
+
Requires-Dist: tree-sitter-gdscript>=6.0
|
|
18
|
+
Provides-Extra: mcp
|
|
19
|
+
Requires-Dist: mcp>=1.2; extra == "mcp"
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
22
|
+
Requires-Dist: mcp>=1.2; extra == "dev"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# godot-affected-checks
|
|
26
|
+
|
|
27
|
+
**English** · [한국어](https://github.com/remnantlab/godot-affected-checks/blob/main/README.ko.md) · [简体中文](https://github.com/remnantlab/godot-affected-checks/blob/main/README.zh-CN.md) · [日本語](https://github.com/remnantlab/godot-affected-checks/blob/main/README.ja.md)
|
|
28
|
+
|
|
29
|
+
Run only the Godot tests a change can reach.
|
|
30
|
+
|
|
31
|
+
`godot-checks` reads your project into a dependency graph (GDScript, scenes,
|
|
32
|
+
resources, autoloads, `class_name`s), works out which tests can see the files you
|
|
33
|
+
changed, and runs those headless: plain check scripts, [GUT](https://github.com/bitwes/Gut)
|
|
34
|
+
tests and [gdUnit4](https://github.com/godot-gdunit-labs/gdUnit4) suites, side by side.
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
$ godot-checks run --affected
|
|
38
|
+
2 changed file(s)
|
|
39
|
+
ok res://checks/check_enemy.gd 3 ok 0.3s
|
|
40
|
+
ok res://checks/check_player.gd 1 ok 0.3s
|
|
41
|
+
ok gdUnit4 (1 suites) 1 ok 2.7s
|
|
42
|
+
|
|
43
|
+
3 of 3 runs passed
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Why
|
|
47
|
+
|
|
48
|
+
- **Big suites are slow.** A project with a hundred headless checks spends minutes
|
|
49
|
+
on every change. Most of them cannot see the change at all.
|
|
50
|
+
- **Godot hides script errors from exit codes.** After a GDScript runtime error the
|
|
51
|
+
engine stops that one function and carries on; a check can print "all passed"
|
|
52
|
+
and exit 0 over a broken method. GUT (4.5+) and gdUnit4 (opt-in) catch this
|
|
53
|
+
inside their own tests. `godot-checks` catches it for any script it runs, and
|
|
54
|
+
also fails a run that hangs, crashes, or never reports a result.
|
|
55
|
+
- **Autoloads break `godot --script`.** A script that names an autoload
|
|
56
|
+
(`Score.add(1)`) does not compile under `--script`, because the engine has not
|
|
57
|
+
registered autoloads yet. Checks here run from a small runner scene, so the game
|
|
58
|
+
starts the normal way first.
|
|
59
|
+
|
|
60
|
+
## Install
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
pip install godot-affected-checks # or: uv tool install godot-affected-checks
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Python 3.11+. It needs a Godot 4 binary: set `GODOT`, put `godot` on `PATH`, or set
|
|
67
|
+
`godot = "..."` in the config; `godot-checks doctor` shows what it found.
|
|
68
|
+
|
|
69
|
+
To write checks with the built-in base class, run `godot-checks init` in the
|
|
70
|
+
project: it copies the addon to `addons/godot_checks/` and adds a first check.
|
|
71
|
+
|
|
72
|
+
## What "affected" means
|
|
73
|
+
|
|
74
|
+
A test is picked when it reaches a changed file through any chain of uses, however
|
|
75
|
+
long:
|
|
76
|
+
|
|
77
|
+
| Edge (A uses B) | Example |
|
|
78
|
+
|---|---|
|
|
79
|
+
| res:// path | `preload("res://enemy.tscn")`, `load(...)`, `"res://data/items.json"` |
|
|
80
|
+
| scene / resource | an `ext_resource` in a `.tscn` / `.tres` (path or `uid://`) |
|
|
81
|
+
| autoload | `Score.add(1)` uses the autoload's script (or its scene's root script) |
|
|
82
|
+
| class_name | `Enemy.new()`, `var e: Enemy`, `extends Enemy` |
|
|
83
|
+
| extends path | `extends "res://base.gd"` |
|
|
84
|
+
|
|
85
|
+
So a change to `data/items.json` runs the check that spawns `main.tscn`, whose
|
|
86
|
+
root script preloads `items.gd`, which reads the JSON. What the changed file
|
|
87
|
+
itself uses is not re-run: it did not change.
|
|
88
|
+
|
|
89
|
+
`godot-checks why <check> <file>` prints the chain.
|
|
90
|
+
|
|
91
|
+
**When it runs everything instead:** `project.godot` changed, or a changed
|
|
92
|
+
non-script file is not named anywhere by a literal path (it is read some way the
|
|
93
|
+
graph cannot follow, such as a path built at runtime). Calls through untyped
|
|
94
|
+
variables or `call("name")` are not followed; file-level edges usually cover them
|
|
95
|
+
anyway, and where a script fails to parse its names are collected from the raw
|
|
96
|
+
text instead. Use `--affected` while working and the full suite in CI.
|
|
97
|
+
|
|
98
|
+
`doctor` lists every `load()`, `preload()`, `change_scene_to_file()` and
|
|
99
|
+
`FileAccess.open()` whose path is built at runtime: those are where `--affected` is
|
|
100
|
+
blind. `why` lists the ones a check reaches when it finds no chain.
|
|
101
|
+
|
|
102
|
+
## Commands
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
godot-checks run # everything
|
|
106
|
+
godot-checks run enemy player # check_enemy.gd, test_player.gd, player_test.gd ...
|
|
107
|
+
godot-checks run --affected # what uncommitted changes reach
|
|
108
|
+
godot-checks run --affected --base origin/main # ... plus commits since main
|
|
109
|
+
godot-checks run --affected --files scripts/enemy.gd
|
|
110
|
+
godot-checks run --strict # also fail on engine ERROR: lines and leaks at exit
|
|
111
|
+
godot-checks run --junit report.xml # JUnit XML for CI
|
|
112
|
+
godot-checks run --dry-run # list, do not run
|
|
113
|
+
godot-checks run --shard 2/4 # slice 2 of 4, for parallel CI jobs
|
|
114
|
+
godot-checks run --shard 2/4 --timings checks/timings.json # slices of even run time
|
|
115
|
+
godot-checks run --watch # re-run what each save reaches, until Ctrl+C
|
|
116
|
+
godot-checks run --failed-first # start with what failed last time
|
|
117
|
+
godot-checks untested # scripts no check or test reaches
|
|
118
|
+
godot-checks affected # what would run, and why everything if so
|
|
119
|
+
godot-checks why checks/check_player.gd data/items.json
|
|
120
|
+
godot-checks graph [--json] # the whole dependency graph
|
|
121
|
+
godot-checks init # copy the addon, write a first check
|
|
122
|
+
godot-checks doctor # Godot, project, what was found
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Exit code 1 when anything failed. In GitHub Actions a table of the runs goes to
|
|
126
|
+
the job's summary page (`$GITHUB_STEP_SUMMARY`), failures first. What failed is
|
|
127
|
+
kept in `.godot/godot-checks-last.json` for `--failed-first`.
|
|
128
|
+
|
|
129
|
+
`--timings FILE` keeps seconds per check file; any run with it updates the file,
|
|
130
|
+
and `--shard` then splits by run time instead of by count, so one slow check does
|
|
131
|
+
not hold up a slice. Commit the file: every CI job must read the same one to cut
|
|
132
|
+
the same slices. A check missing from it counts as the median.
|
|
133
|
+
|
|
134
|
+
## Writing checks
|
|
135
|
+
|
|
136
|
+
```gdscript
|
|
137
|
+
# checks/check_enemy.gd
|
|
138
|
+
extends GodotCheck
|
|
139
|
+
|
|
140
|
+
func run() -> void:
|
|
141
|
+
var e := Enemy.new()
|
|
142
|
+
expect(not e.hit(1), "survives one hit")
|
|
143
|
+
expect_eq(e.hp, 2, "loses one hp")
|
|
144
|
+
var player: Node = await spawn("res://scenes/main.tscn")
|
|
145
|
+
await frames(2)
|
|
146
|
+
expect(player.attack(e), "the player can finish it")
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Helpers: `expect`, `expect_eq`, `expect_near`, `frames(n)`, `seconds(t)`, `spawn(path)`.
|
|
150
|
+
Run one by hand:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
godot --headless --path . res://addons/godot_checks/runner.tscn -- res://checks/check_enemy.gd
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Older `extends SceneTree` scripts that print `failures: N` themselves still run,
|
|
157
|
+
through `--script`. A comment `--quit-after N` in a check's first lines sets its
|
|
158
|
+
frame limit.
|
|
159
|
+
|
|
160
|
+
Checks whose source mentions `user://` run one at a time, so they do not share
|
|
161
|
+
save files mid-run (`serial` in the config).
|
|
162
|
+
|
|
163
|
+
## GUT and gdUnit4
|
|
164
|
+
|
|
165
|
+
Install them as usual (`addons/gut`, `addons/gdUnit4`). `godot-checks` finds their
|
|
166
|
+
tests by file name (`test_*.gd` for GUT, `*_test.gd` / `*Test.gd` for gdUnit4),
|
|
167
|
+
puts them in the graph like any other script, and runs the picked ones in one
|
|
168
|
+
Godot process per framework, reading their JUnit output.
|
|
169
|
+
|
|
170
|
+
## Configuration
|
|
171
|
+
|
|
172
|
+
`godot-checks.toml` in the project root, or `[tool.godot-checks]` in
|
|
173
|
+
`pyproject.toml`. All keys are optional:
|
|
174
|
+
|
|
175
|
+
```toml
|
|
176
|
+
godot = "/path/to/godot"
|
|
177
|
+
ignore = [".godot/*", ".import/*", ".git/*", "addons/gut/*", "addons/gdUnit4/*"]
|
|
178
|
+
plain = ["checks/**/check_*.gd", "tools/check_*.gd"]
|
|
179
|
+
gut = ["test/**/test_*.gd", "tests/**/test_*.gd"]
|
|
180
|
+
gdunit = ["test/**/*_test.gd", "tests/**/*_test.gd", "test/**/*Test.gd", "tests/**/*Test.gd"]
|
|
181
|
+
timeout = 600 # seconds per run
|
|
182
|
+
jobs = 0 # parallel runs; 0 = one per CPU
|
|
183
|
+
quit_after = 3000 # frame limit for checks without a header
|
|
184
|
+
strict = false
|
|
185
|
+
serial = ["user://"] # regexes; matching checks run one at a time
|
|
186
|
+
restore_after_import = true # undo what a first --import rewrites
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
A fresh checkout has no `.godot/` and no `class_name` resolves without it, so the
|
|
190
|
+
first run imports the project, then puts back `project.godot` and the `.import`
|
|
191
|
+
files the import rewrote.
|
|
192
|
+
|
|
193
|
+
## CI
|
|
194
|
+
|
|
195
|
+
```yaml
|
|
196
|
+
- uses: actions/setup-python@v5
|
|
197
|
+
with: { python-version: "3.12" }
|
|
198
|
+
- run: pip install godot-affected-checks
|
|
199
|
+
- run: |
|
|
200
|
+
curl -fsSLO https://github.com/godotengine/godot/releases/download/4.7.2-stable/Godot_v4.7.2-stable_linux.x86_64.zip
|
|
201
|
+
unzip -q Godot_v4.7.2-stable_linux.x86_64.zip
|
|
202
|
+
echo "GODOT=$PWD/Godot_v4.7.2-stable_linux.x86_64" >> "$GITHUB_ENV"
|
|
203
|
+
- run: godot-checks run --junit report.xml
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
On pull requests, `godot-checks run --affected --base origin/${{ github.base_ref }}`
|
|
207
|
+
runs the part a branch can reach (fetch with `fetch-depth: 0`).
|
|
208
|
+
|
|
209
|
+
Or use this repository as an action, which installs Godot (checksum-verified) and
|
|
210
|
+
the tool on Linux, macOS or Windows runners:
|
|
211
|
+
|
|
212
|
+
```yaml
|
|
213
|
+
- uses: actions/checkout@v4
|
|
214
|
+
with: { fetch-depth: 0 }
|
|
215
|
+
- uses: remnantlab/godot-affected-checks@v0
|
|
216
|
+
with:
|
|
217
|
+
affected: ${{ github.event_name == 'pull_request' }}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Inputs: `project`, `godot-version`, `affected`, `args`, `junit`.
|
|
221
|
+
|
|
222
|
+
### pre-commit
|
|
223
|
+
|
|
224
|
+
```yaml
|
|
225
|
+
- repo: https://github.com/remnantlab/godot-affected-checks
|
|
226
|
+
rev: v0.1.0
|
|
227
|
+
hooks:
|
|
228
|
+
- id: godot-affected-checks
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## graphify
|
|
232
|
+
|
|
233
|
+
[graphify](https://github.com/Graphify-Labs/graphify) turns a codebase into a
|
|
234
|
+
knowledge graph for AI assistants but reads no GDScript. This package carries an
|
|
235
|
+
extractor for it, built on the same parser: classes, functions, signals, consts,
|
|
236
|
+
enums, and calls resolved through autoloads, `class_name`s and typed locals.
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
uv tool install graphifyy --with godot-affected-checks
|
|
240
|
+
uv tool run --from graphifyy godot-checks-graphify install # again after each graphify upgrade
|
|
241
|
+
graphify update .
|
|
242
|
+
graphify explain "hit"
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
graphify has no plugin hook yet ([#3180](https://github.com/Graphify-Labs/graphify/issues/3180)),
|
|
246
|
+
so the installer patches the installed package; `install --check` exits 1 when the
|
|
247
|
+
patch is gone. Tested with graphify 0.9.126.
|
|
248
|
+
|
|
249
|
+
## Benchmark
|
|
250
|
+
|
|
251
|
+
How many copies of a scene does this machine draw at your target frame rate?
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
godot --path . --script res://addons/godot_checks/bench.gd -- --scene res://npc.tscn --count 60 --csv bench.csv
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Spawns the copies on rings, plays their animation (`--every K` advances each one
|
|
258
|
+
every Kth frame, `--frozen` stops it), and prints average, median, 99th percentile
|
|
259
|
+
and worst frame time. Vsync is off unless `--vsync`. Run it windowed.
|
|
260
|
+
|
|
261
|
+
## AI agents (MCP)
|
|
262
|
+
|
|
263
|
+
`godot-checks-mcp` is an MCP server with five tools: `run_checks` (all, by name,
|
|
264
|
+
or affected), `affected_checks`, `why`, `untested` and `doctor`. An agent can run
|
|
265
|
+
what its edit reaches and read why a check was picked.
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
pip install "godot-affected-checks[mcp]"
|
|
269
|
+
claude mcp add godot-checks -- godot-checks-mcp
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Claude Code
|
|
273
|
+
|
|
274
|
+
`hooks/claude-session-start.sh` is a SessionStart hook for cloud sessions: it
|
|
275
|
+
installs uv, this package and a checksum-verified Godot Linux build, and exports
|
|
276
|
+
`GODOT`, so an agent can run `godot-checks run --affected` after each edit.
|
|
277
|
+
|
|
278
|
+
## Limits
|
|
279
|
+
|
|
280
|
+
- The grammar ([tree-sitter-gdscript](https://pypi.org/project/tree-sitter-gdscript/))
|
|
281
|
+
lags the newest syntax in places (one-line lambdas with `if`, non-ASCII
|
|
282
|
+
identifiers); such files fall back to collecting every name in their text.
|
|
283
|
+
- C# is read with patterns, not a parser: a `.cs` file uses the types it names
|
|
284
|
+
(declared in other `.cs` files, or GDScript `class_name`s) and the `res://` paths
|
|
285
|
+
it mentions. Good enough to pick tests, not a C# call graph.
|
|
286
|
+
- Blind spots are found by call name: an ALL_CAPS argument is taken for a const
|
|
287
|
+
whose string the graph already has, so `load(SCENE)` is not reported.
|
|
288
|
+
- Parsed scripts are cached in `.godot/godot-checks-cache.pickle` by file time and
|
|
289
|
+
size (only when `.godot/` exists); delete it to start fresh.
|
|
290
|
+
- tree-sitter-gdscript publishes wheels for Linux x86_64, macOS arm64 and
|
|
291
|
+
Windows x64; elsewhere pip builds it from source (a C compiler is needed).
|
|
292
|
+
|
|
293
|
+
## License
|
|
294
|
+
|
|
295
|
+
MIT
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# godot-affected-checks
|
|
2
|
+
|
|
3
|
+
**English** · [한국어](https://github.com/remnantlab/godot-affected-checks/blob/main/README.ko.md) · [简体中文](https://github.com/remnantlab/godot-affected-checks/blob/main/README.zh-CN.md) · [日本語](https://github.com/remnantlab/godot-affected-checks/blob/main/README.ja.md)
|
|
4
|
+
|
|
5
|
+
Run only the Godot tests a change can reach.
|
|
6
|
+
|
|
7
|
+
`godot-checks` reads your project into a dependency graph (GDScript, scenes,
|
|
8
|
+
resources, autoloads, `class_name`s), works out which tests can see the files you
|
|
9
|
+
changed, and runs those headless: plain check scripts, [GUT](https://github.com/bitwes/Gut)
|
|
10
|
+
tests and [gdUnit4](https://github.com/godot-gdunit-labs/gdUnit4) suites, side by side.
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
$ godot-checks run --affected
|
|
14
|
+
2 changed file(s)
|
|
15
|
+
ok res://checks/check_enemy.gd 3 ok 0.3s
|
|
16
|
+
ok res://checks/check_player.gd 1 ok 0.3s
|
|
17
|
+
ok gdUnit4 (1 suites) 1 ok 2.7s
|
|
18
|
+
|
|
19
|
+
3 of 3 runs passed
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Why
|
|
23
|
+
|
|
24
|
+
- **Big suites are slow.** A project with a hundred headless checks spends minutes
|
|
25
|
+
on every change. Most of them cannot see the change at all.
|
|
26
|
+
- **Godot hides script errors from exit codes.** After a GDScript runtime error the
|
|
27
|
+
engine stops that one function and carries on; a check can print "all passed"
|
|
28
|
+
and exit 0 over a broken method. GUT (4.5+) and gdUnit4 (opt-in) catch this
|
|
29
|
+
inside their own tests. `godot-checks` catches it for any script it runs, and
|
|
30
|
+
also fails a run that hangs, crashes, or never reports a result.
|
|
31
|
+
- **Autoloads break `godot --script`.** A script that names an autoload
|
|
32
|
+
(`Score.add(1)`) does not compile under `--script`, because the engine has not
|
|
33
|
+
registered autoloads yet. Checks here run from a small runner scene, so the game
|
|
34
|
+
starts the normal way first.
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
pip install godot-affected-checks # or: uv tool install godot-affected-checks
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Python 3.11+. It needs a Godot 4 binary: set `GODOT`, put `godot` on `PATH`, or set
|
|
43
|
+
`godot = "..."` in the config; `godot-checks doctor` shows what it found.
|
|
44
|
+
|
|
45
|
+
To write checks with the built-in base class, run `godot-checks init` in the
|
|
46
|
+
project: it copies the addon to `addons/godot_checks/` and adds a first check.
|
|
47
|
+
|
|
48
|
+
## What "affected" means
|
|
49
|
+
|
|
50
|
+
A test is picked when it reaches a changed file through any chain of uses, however
|
|
51
|
+
long:
|
|
52
|
+
|
|
53
|
+
| Edge (A uses B) | Example |
|
|
54
|
+
|---|---|
|
|
55
|
+
| res:// path | `preload("res://enemy.tscn")`, `load(...)`, `"res://data/items.json"` |
|
|
56
|
+
| scene / resource | an `ext_resource` in a `.tscn` / `.tres` (path or `uid://`) |
|
|
57
|
+
| autoload | `Score.add(1)` uses the autoload's script (or its scene's root script) |
|
|
58
|
+
| class_name | `Enemy.new()`, `var e: Enemy`, `extends Enemy` |
|
|
59
|
+
| extends path | `extends "res://base.gd"` |
|
|
60
|
+
|
|
61
|
+
So a change to `data/items.json` runs the check that spawns `main.tscn`, whose
|
|
62
|
+
root script preloads `items.gd`, which reads the JSON. What the changed file
|
|
63
|
+
itself uses is not re-run: it did not change.
|
|
64
|
+
|
|
65
|
+
`godot-checks why <check> <file>` prints the chain.
|
|
66
|
+
|
|
67
|
+
**When it runs everything instead:** `project.godot` changed, or a changed
|
|
68
|
+
non-script file is not named anywhere by a literal path (it is read some way the
|
|
69
|
+
graph cannot follow, such as a path built at runtime). Calls through untyped
|
|
70
|
+
variables or `call("name")` are not followed; file-level edges usually cover them
|
|
71
|
+
anyway, and where a script fails to parse its names are collected from the raw
|
|
72
|
+
text instead. Use `--affected` while working and the full suite in CI.
|
|
73
|
+
|
|
74
|
+
`doctor` lists every `load()`, `preload()`, `change_scene_to_file()` and
|
|
75
|
+
`FileAccess.open()` whose path is built at runtime: those are where `--affected` is
|
|
76
|
+
blind. `why` lists the ones a check reaches when it finds no chain.
|
|
77
|
+
|
|
78
|
+
## Commands
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
godot-checks run # everything
|
|
82
|
+
godot-checks run enemy player # check_enemy.gd, test_player.gd, player_test.gd ...
|
|
83
|
+
godot-checks run --affected # what uncommitted changes reach
|
|
84
|
+
godot-checks run --affected --base origin/main # ... plus commits since main
|
|
85
|
+
godot-checks run --affected --files scripts/enemy.gd
|
|
86
|
+
godot-checks run --strict # also fail on engine ERROR: lines and leaks at exit
|
|
87
|
+
godot-checks run --junit report.xml # JUnit XML for CI
|
|
88
|
+
godot-checks run --dry-run # list, do not run
|
|
89
|
+
godot-checks run --shard 2/4 # slice 2 of 4, for parallel CI jobs
|
|
90
|
+
godot-checks run --shard 2/4 --timings checks/timings.json # slices of even run time
|
|
91
|
+
godot-checks run --watch # re-run what each save reaches, until Ctrl+C
|
|
92
|
+
godot-checks run --failed-first # start with what failed last time
|
|
93
|
+
godot-checks untested # scripts no check or test reaches
|
|
94
|
+
godot-checks affected # what would run, and why everything if so
|
|
95
|
+
godot-checks why checks/check_player.gd data/items.json
|
|
96
|
+
godot-checks graph [--json] # the whole dependency graph
|
|
97
|
+
godot-checks init # copy the addon, write a first check
|
|
98
|
+
godot-checks doctor # Godot, project, what was found
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Exit code 1 when anything failed. In GitHub Actions a table of the runs goes to
|
|
102
|
+
the job's summary page (`$GITHUB_STEP_SUMMARY`), failures first. What failed is
|
|
103
|
+
kept in `.godot/godot-checks-last.json` for `--failed-first`.
|
|
104
|
+
|
|
105
|
+
`--timings FILE` keeps seconds per check file; any run with it updates the file,
|
|
106
|
+
and `--shard` then splits by run time instead of by count, so one slow check does
|
|
107
|
+
not hold up a slice. Commit the file: every CI job must read the same one to cut
|
|
108
|
+
the same slices. A check missing from it counts as the median.
|
|
109
|
+
|
|
110
|
+
## Writing checks
|
|
111
|
+
|
|
112
|
+
```gdscript
|
|
113
|
+
# checks/check_enemy.gd
|
|
114
|
+
extends GodotCheck
|
|
115
|
+
|
|
116
|
+
func run() -> void:
|
|
117
|
+
var e := Enemy.new()
|
|
118
|
+
expect(not e.hit(1), "survives one hit")
|
|
119
|
+
expect_eq(e.hp, 2, "loses one hp")
|
|
120
|
+
var player: Node = await spawn("res://scenes/main.tscn")
|
|
121
|
+
await frames(2)
|
|
122
|
+
expect(player.attack(e), "the player can finish it")
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Helpers: `expect`, `expect_eq`, `expect_near`, `frames(n)`, `seconds(t)`, `spawn(path)`.
|
|
126
|
+
Run one by hand:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
godot --headless --path . res://addons/godot_checks/runner.tscn -- res://checks/check_enemy.gd
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Older `extends SceneTree` scripts that print `failures: N` themselves still run,
|
|
133
|
+
through `--script`. A comment `--quit-after N` in a check's first lines sets its
|
|
134
|
+
frame limit.
|
|
135
|
+
|
|
136
|
+
Checks whose source mentions `user://` run one at a time, so they do not share
|
|
137
|
+
save files mid-run (`serial` in the config).
|
|
138
|
+
|
|
139
|
+
## GUT and gdUnit4
|
|
140
|
+
|
|
141
|
+
Install them as usual (`addons/gut`, `addons/gdUnit4`). `godot-checks` finds their
|
|
142
|
+
tests by file name (`test_*.gd` for GUT, `*_test.gd` / `*Test.gd` for gdUnit4),
|
|
143
|
+
puts them in the graph like any other script, and runs the picked ones in one
|
|
144
|
+
Godot process per framework, reading their JUnit output.
|
|
145
|
+
|
|
146
|
+
## Configuration
|
|
147
|
+
|
|
148
|
+
`godot-checks.toml` in the project root, or `[tool.godot-checks]` in
|
|
149
|
+
`pyproject.toml`. All keys are optional:
|
|
150
|
+
|
|
151
|
+
```toml
|
|
152
|
+
godot = "/path/to/godot"
|
|
153
|
+
ignore = [".godot/*", ".import/*", ".git/*", "addons/gut/*", "addons/gdUnit4/*"]
|
|
154
|
+
plain = ["checks/**/check_*.gd", "tools/check_*.gd"]
|
|
155
|
+
gut = ["test/**/test_*.gd", "tests/**/test_*.gd"]
|
|
156
|
+
gdunit = ["test/**/*_test.gd", "tests/**/*_test.gd", "test/**/*Test.gd", "tests/**/*Test.gd"]
|
|
157
|
+
timeout = 600 # seconds per run
|
|
158
|
+
jobs = 0 # parallel runs; 0 = one per CPU
|
|
159
|
+
quit_after = 3000 # frame limit for checks without a header
|
|
160
|
+
strict = false
|
|
161
|
+
serial = ["user://"] # regexes; matching checks run one at a time
|
|
162
|
+
restore_after_import = true # undo what a first --import rewrites
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
A fresh checkout has no `.godot/` and no `class_name` resolves without it, so the
|
|
166
|
+
first run imports the project, then puts back `project.godot` and the `.import`
|
|
167
|
+
files the import rewrote.
|
|
168
|
+
|
|
169
|
+
## CI
|
|
170
|
+
|
|
171
|
+
```yaml
|
|
172
|
+
- uses: actions/setup-python@v5
|
|
173
|
+
with: { python-version: "3.12" }
|
|
174
|
+
- run: pip install godot-affected-checks
|
|
175
|
+
- run: |
|
|
176
|
+
curl -fsSLO https://github.com/godotengine/godot/releases/download/4.7.2-stable/Godot_v4.7.2-stable_linux.x86_64.zip
|
|
177
|
+
unzip -q Godot_v4.7.2-stable_linux.x86_64.zip
|
|
178
|
+
echo "GODOT=$PWD/Godot_v4.7.2-stable_linux.x86_64" >> "$GITHUB_ENV"
|
|
179
|
+
- run: godot-checks run --junit report.xml
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
On pull requests, `godot-checks run --affected --base origin/${{ github.base_ref }}`
|
|
183
|
+
runs the part a branch can reach (fetch with `fetch-depth: 0`).
|
|
184
|
+
|
|
185
|
+
Or use this repository as an action, which installs Godot (checksum-verified) and
|
|
186
|
+
the tool on Linux, macOS or Windows runners:
|
|
187
|
+
|
|
188
|
+
```yaml
|
|
189
|
+
- uses: actions/checkout@v4
|
|
190
|
+
with: { fetch-depth: 0 }
|
|
191
|
+
- uses: remnantlab/godot-affected-checks@v0
|
|
192
|
+
with:
|
|
193
|
+
affected: ${{ github.event_name == 'pull_request' }}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Inputs: `project`, `godot-version`, `affected`, `args`, `junit`.
|
|
197
|
+
|
|
198
|
+
### pre-commit
|
|
199
|
+
|
|
200
|
+
```yaml
|
|
201
|
+
- repo: https://github.com/remnantlab/godot-affected-checks
|
|
202
|
+
rev: v0.1.0
|
|
203
|
+
hooks:
|
|
204
|
+
- id: godot-affected-checks
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## graphify
|
|
208
|
+
|
|
209
|
+
[graphify](https://github.com/Graphify-Labs/graphify) turns a codebase into a
|
|
210
|
+
knowledge graph for AI assistants but reads no GDScript. This package carries an
|
|
211
|
+
extractor for it, built on the same parser: classes, functions, signals, consts,
|
|
212
|
+
enums, and calls resolved through autoloads, `class_name`s and typed locals.
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
uv tool install graphifyy --with godot-affected-checks
|
|
216
|
+
uv tool run --from graphifyy godot-checks-graphify install # again after each graphify upgrade
|
|
217
|
+
graphify update .
|
|
218
|
+
graphify explain "hit"
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
graphify has no plugin hook yet ([#3180](https://github.com/Graphify-Labs/graphify/issues/3180)),
|
|
222
|
+
so the installer patches the installed package; `install --check` exits 1 when the
|
|
223
|
+
patch is gone. Tested with graphify 0.9.126.
|
|
224
|
+
|
|
225
|
+
## Benchmark
|
|
226
|
+
|
|
227
|
+
How many copies of a scene does this machine draw at your target frame rate?
|
|
228
|
+
|
|
229
|
+
```
|
|
230
|
+
godot --path . --script res://addons/godot_checks/bench.gd -- --scene res://npc.tscn --count 60 --csv bench.csv
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Spawns the copies on rings, plays their animation (`--every K` advances each one
|
|
234
|
+
every Kth frame, `--frozen` stops it), and prints average, median, 99th percentile
|
|
235
|
+
and worst frame time. Vsync is off unless `--vsync`. Run it windowed.
|
|
236
|
+
|
|
237
|
+
## AI agents (MCP)
|
|
238
|
+
|
|
239
|
+
`godot-checks-mcp` is an MCP server with five tools: `run_checks` (all, by name,
|
|
240
|
+
or affected), `affected_checks`, `why`, `untested` and `doctor`. An agent can run
|
|
241
|
+
what its edit reaches and read why a check was picked.
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
pip install "godot-affected-checks[mcp]"
|
|
245
|
+
claude mcp add godot-checks -- godot-checks-mcp
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Claude Code
|
|
249
|
+
|
|
250
|
+
`hooks/claude-session-start.sh` is a SessionStart hook for cloud sessions: it
|
|
251
|
+
installs uv, this package and a checksum-verified Godot Linux build, and exports
|
|
252
|
+
`GODOT`, so an agent can run `godot-checks run --affected` after each edit.
|
|
253
|
+
|
|
254
|
+
## Limits
|
|
255
|
+
|
|
256
|
+
- The grammar ([tree-sitter-gdscript](https://pypi.org/project/tree-sitter-gdscript/))
|
|
257
|
+
lags the newest syntax in places (one-line lambdas with `if`, non-ASCII
|
|
258
|
+
identifiers); such files fall back to collecting every name in their text.
|
|
259
|
+
- C# is read with patterns, not a parser: a `.cs` file uses the types it names
|
|
260
|
+
(declared in other `.cs` files, or GDScript `class_name`s) and the `res://` paths
|
|
261
|
+
it mentions. Good enough to pick tests, not a C# call graph.
|
|
262
|
+
- Blind spots are found by call name: an ALL_CAPS argument is taken for a const
|
|
263
|
+
whose string the graph already has, so `load(SCENE)` is not reported.
|
|
264
|
+
- Parsed scripts are cached in `.godot/godot-checks-cache.pickle` by file time and
|
|
265
|
+
size (only when `.godot/` exists); delete it to start fresh.
|
|
266
|
+
- tree-sitter-gdscript publishes wheels for Linux x86_64, macOS arm64 and
|
|
267
|
+
Windows x64; elsewhere pip builds it from source (a C compiler is needed).
|
|
268
|
+
|
|
269
|
+
## License
|
|
270
|
+
|
|
271
|
+
MIT
|