chore: bootstrap Godot quality tools

This commit is contained in:
Rijad Zuzo
2026-07-09 23:32:03 +02:00
parent 5cbab527bf
commit 8419116008
7 changed files with 46 additions and 14 deletions
+1
View File
@@ -23,6 +23,7 @@ crash_handler*
*.log *.log
# Local environment and secrets # Local environment and secrets
.venv/
.env .env
.env.* .env.*
!.env.example !.env.example
+13 -3
View File
@@ -25,21 +25,31 @@ systems project, not a content dump. The expected working style is:
Only Godot 4.7 matters for this project. Only Godot 4.7 matters for this project.
Use the project quality gate from PowerShell: Use the project quality gate for the current platform:
```bash
# macOS / Linux
./tools/quality.sh
```
```powershell ```powershell
# Windows
powershell -ExecutionPolicy Bypass -File .\tools\quality.ps1 powershell -ExecutionPolicy Bypass -File .\tools\quality.ps1
``` ```
For changed-file quick checks: For changed-file quick checks:
```bash
./tools/quality.sh --changed
```
```powershell ```powershell
powershell -ExecutionPolicy Bypass -File .\tools\quality.ps1 -Changed powershell -ExecutionPolicy Bypass -File .\tools\quality.ps1 -Changed
``` ```
The quality scripts isolate Godot's user profile under `logs/quality/godot_profile` The quality scripts isolate Godot's user profile under `logs/quality/godot_profile`
so headless Godot 4.7 can run without crashing on blocked Windows app-data paths. so headless Godot 4.7 can run without crashing when platform user-data paths
Do not remove that behavior. are unavailable. Do not remove that behavior.
Useful extra checks: Useful extra checks:
+11 -3
View File
@@ -5,12 +5,20 @@ parser errors, and LLM-generated garbage before committing.
## Requirements ## Requirements
- **Python 3** with `gdtoolkit` (gdscript-toolkit): - **Python 3** with the pinned `gdtoolkit` (gdscript-toolkit). The recommended
setup uses `uv` and a project-local environment:
```bash ```bash
pip install gdtoolkit uv venv .venv
uv pip install --python .venv/bin/python -r requirements-dev.txt
``` ```
On Windows, use `.venv/Scripts/python.exe` for the `--python` value.
- **Godot 4** binary on `PATH`, or set the `GODOT_BIN` environment variable - **Godot 4** binary on `PATH`, or set the `GODOT_BIN` environment variable
The quality and format scripts discover `.venv` automatically; activating it
is optional.
## Usage ## Usage
### Full project check ### Full project check
@@ -102,7 +110,7 @@ to the terminal.
To add this to CI, install the dependencies and run: To add this to CI, install the dependencies and run:
```bash ```bash
pip install gdtoolkit python -m pip install -r requirements-dev.txt
./tools/quality.sh ./tools/quality.sh
``` ```
+1
View File
@@ -0,0 +1 @@
gdtoolkit==4.5.0
+4 -2
View File
@@ -8,14 +8,16 @@ cd "$ROOT"
# detect gdformat # detect gdformat
FMT="" FMT=""
if command -v gdformat &>/dev/null; then if [[ -x "$ROOT/.venv/bin/gdformat" ]]; then
FMT="$ROOT/.venv/bin/gdformat"
elif command -v gdformat &>/dev/null; then
FMT="gdformat" FMT="gdformat"
elif python -m gdtoolkit.formatter --help &>/dev/null 2>&1; then elif python -m gdtoolkit.formatter --help &>/dev/null 2>&1; then
FMT="python -m gdtoolkit.formatter" FMT="python -m gdtoolkit.formatter"
fi fi
if [[ -z "$FMT" ]]; then if [[ -z "$FMT" ]]; then
echo "ERROR: gdformat not found. Install: pip install gdtoolkit" echo "ERROR: gdformat not found. Install requirements-dev.txt; see docs/local_quality_gate.md."
exit 1 exit 1
fi fi
+12 -4
View File
@@ -59,6 +59,7 @@ function Find-Godot {
} }
function Test-GdFormat { function Test-GdFormat {
if (Test-Path "$ROOT/.venv/Scripts/gdformat.exe") { return $true }
if (Get-Command gdformat -ErrorAction SilentlyContinue) { return $true } if (Get-Command gdformat -ErrorAction SilentlyContinue) { return $true }
try { try {
$null = & python -m gdtoolkit.formatter --help 2>&1 $null = & python -m gdtoolkit.formatter --help 2>&1
@@ -72,6 +73,7 @@ function Test-GdFormat {
} }
function Test-GdLint { function Test-GdLint {
if (Test-Path "$ROOT/.venv/Scripts/gdlint.exe") { return $true }
if (Get-Command gdlint -ErrorAction SilentlyContinue) { return $true } if (Get-Command gdlint -ErrorAction SilentlyContinue) { return $true }
try { try {
$null = & python -m gdtoolkit.linter --help 2>&1 $null = & python -m gdtoolkit.linter --help 2>&1
@@ -86,7 +88,10 @@ function Test-GdLint {
function Invoke-GdFormat { function Invoke-GdFormat {
$args = $args $args = $args
if (Get-Command gdformat -ErrorAction SilentlyContinue) { $localTool = "$ROOT/.venv/Scripts/gdformat.exe"
if (Test-Path $localTool) {
& $localTool @args 2>&1
} elseif (Get-Command gdformat -ErrorAction SilentlyContinue) {
& gdformat @args 2>&1 & gdformat @args 2>&1
} else { } else {
& python -m gdtoolkit.formatter @args 2>&1 & python -m gdtoolkit.formatter @args 2>&1
@@ -95,7 +100,10 @@ function Invoke-GdFormat {
function Invoke-GdLint { function Invoke-GdLint {
$args = $args $args = $args
if (Get-Command gdlint -ErrorAction SilentlyContinue) { $localTool = "$ROOT/.venv/Scripts/gdlint.exe"
if (Test-Path $localTool) {
& $localTool @args 2>&1
} elseif (Get-Command gdlint -ErrorAction SilentlyContinue) {
& gdlint @args 2>&1 & gdlint @args 2>&1
} else { } else {
& python -m gdtoolkit.linter @args 2>&1 & python -m gdtoolkit.linter @args 2>&1
@@ -161,7 +169,7 @@ $fmtResult = "PASS"
Set-Content -Path "$LOG/gdformat.log" -Value "" -Encoding utf8 Set-Content -Path "$LOG/gdformat.log" -Value "" -Encoding utf8
if (-not $fmtAvail) { if (-not $fmtAvail) {
$fmtResult = "SKIPPED" $fmtResult = "SKIPPED"
Add-Content -Path "$LOG/gdformat.log" -Value "gdformat not found -- install: pip install gdtoolkit" -Encoding utf8 Add-Content -Path "$LOG/gdformat.log" -Value "gdformat not found -- install requirements-dev.txt (see docs/local_quality_gate.md)" -Encoding utf8
} else { } else {
if ($Changed) { if ($Changed) {
$files = Get-ChangedGd $files = Get-ChangedGd
@@ -203,7 +211,7 @@ $lintResult = "PASS"
Set-Content -Path "$LOG/gdlint.log" -Value "" -Encoding utf8 Set-Content -Path "$LOG/gdlint.log" -Value "" -Encoding utf8
if (-not $lintAvail) { if (-not $lintAvail) {
$lintResult = "SKIPPED" $lintResult = "SKIPPED"
Add-Content -Path "$LOG/gdlint.log" -Value "gdlint not found -- install: pip install gdtoolkit" -Encoding utf8 Add-Content -Path "$LOG/gdlint.log" -Value "gdlint not found -- install requirements-dev.txt (see docs/local_quality_gate.md)" -Encoding utf8
} else { } else {
if ($Changed) { if ($Changed) {
$files = Get-ChangedGd $files = Get-ChangedGd
+4 -2
View File
@@ -54,12 +54,14 @@ find_godot() {
} }
find_gdformat() { find_gdformat() {
if [[ -x "$ROOT/.venv/bin/gdformat" ]]; then echo "$ROOT/.venv/bin/gdformat"; return 0; fi
if command -v gdformat &>/dev/null; then echo "gdformat"; return 0; fi if command -v gdformat &>/dev/null; then echo "gdformat"; return 0; fi
if python -m gdtoolkit.formatter --help &>/dev/null 2>&1; then echo "python -m gdtoolkit.formatter"; return 0; fi if python -m gdtoolkit.formatter --help &>/dev/null 2>&1; then echo "python -m gdtoolkit.formatter"; return 0; fi
return 1 return 1
} }
find_gdlint() { find_gdlint() {
if [[ -x "$ROOT/.venv/bin/gdlint" ]]; then echo "$ROOT/.venv/bin/gdlint"; return 0; fi
if command -v gdlint &>/dev/null; then echo "gdlint"; return 0; fi if command -v gdlint &>/dev/null; then echo "gdlint"; return 0; fi
if python -m gdtoolkit.linter --help &>/dev/null 2>&1; then echo "python -m gdtoolkit.linter"; return 0; fi if python -m gdtoolkit.linter --help &>/dev/null 2>&1; then echo "python -m gdtoolkit.linter"; return 0; fi
return 1 return 1
@@ -99,7 +101,7 @@ fmt_result="PASS"
: > "$LOG/gdformat.log" : > "$LOG/gdformat.log"
if [[ -z "$fmt_tool" ]]; then if [[ -z "$fmt_tool" ]]; then
fmt_result="SKIPPED" fmt_result="SKIPPED"
echo "gdformat not found — install: pip install gdtoolkit" > "$LOG/gdformat.log" echo "gdformat not found — install requirements-dev.txt (see docs/local_quality_gate.md)" > "$LOG/gdformat.log"
else else
if $CHANGED; then if $CHANGED; then
files=$(changed_gd) files=$(changed_gd)
@@ -137,7 +139,7 @@ lint_result="PASS"
: > "$LOG/gdlint.log" : > "$LOG/gdlint.log"
if [[ -z "$lint_tool" ]]; then if [[ -z "$lint_tool" ]]; then
lint_result="SKIPPED" lint_result="SKIPPED"
echo "gdlint not found — install: pip install gdtoolkit" > "$LOG/gdlint.log" echo "gdlint not found — install requirements-dev.txt (see docs/local_quality_gate.md)" > "$LOG/gdlint.log"
else else
if $CHANGED; then if $CHANGED; then
files=$(changed_gd) files=$(changed_gd)