-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.ps1
More file actions
53 lines (45 loc) · 1.27 KB
/
dev.ps1
File metadata and controls
53 lines (45 loc) · 1.27 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
# dev.ps1 — one-touch lint/format/type/test
param(
[ValidateSet('all','ruff','black','mypy','pytest')]
[string]$Only = 'all',
[switch]$Fix = $true, # Ruff --fix (default on)
[switch]$NoTests = $false, # skip pytest when running "all"
[string]$Path = '.' # path to check (for Ruff)
)
$ErrorActionPreference = 'Stop'
# Activate venv if present
if (-not $env:VIRTUAL_ENV -and (Test-Path .\.venv\Scripts\Activate.ps1)) {
. .\.venv\Scripts\Activate.ps1
}
function Run-Ruff {
Write-Host "`n=== Ruff ===" -ForegroundColor Cyan
$args = @('check')
if ($Fix) { $args += '--fix' }
$args += @('--force-exclude', $Path)
ruff @args
}
function Run-Black {
Write-Host "`n=== Black ===" -ForegroundColor Cyan
black .
}
function Run-Mypy {
Write-Host "`n=== mypy ===" -ForegroundColor Cyan
mypy src
}
function Run-Pytest {
Write-Host "`n=== pytest ===" -ForegroundColor Cyan
pytest -q
}
switch ($Only) {
'ruff' { Run-Ruff; break }
'black' { Run-Black; break }
'mypy' { Run-Mypy; break }
'pytest' { Run-Pytest; break }
default {
Run-Ruff
Run-Black
Run-Mypy
if (-not $NoTests) { Run-Pytest } else { Write-Host "`n(Skipping tests)" -ForegroundColor Yellow }
}
}
Write-Host "`nAll dev checks completed." -ForegroundColor Green