Repository navigation
Expand file tree
/
Copy pathrel.ps1
More file actions
251 lines (184 loc) · 7.52 KB
/
Copy pathrel.ps1
File metadata and controls
251 lines (184 loc) · 7.52 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#Requires -Version 7.0
<#
Run the release validation sequence.
The script echoes each exact command before running it.
#>
Clear-Host
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
# $PSNativeCommandUseErrorActionPreference = $true
function Invoke-Step {
param(
[Parameter(Mandatory = $true)]
[string]$Section,
[Parameter(Mandatory = $true)]
[string]$Command,
[Parameter(Mandatory = $true)]
[scriptblock]$Script
)
Write-Host ""
Write-Host "============================================================"
Write-Host $Section
Write-Host "============================================================"
Write-Host $Command
& $Script
}
# ============================================================
# A) Toolchain refresh
# ============================================================
Invoke-Step "A1) Update lock file" "uv self update" {
uv self update
}
Invoke-Step "A2) Pin Python version" "uv python pin 3.15" {
uv python pin 3.15
}
Invoke-Step "A3) Update lock file" "uv lock --upgrade" {
uv lock --upgrade
}
Invoke-Step "A4) Sync Python tooling" "uv sync --extra dev --extra docs --upgrade" {
uv sync --extra dev --extra docs --upgrade
}
Invoke-Step "A5) Install pre-commit hooks" "uvx pre-commit install" {
uvx pre-commit install
}
Invoke-Step "A6) Autoupdate pre-commit hooks" "uvx pre-commit autoupdate" {
uvx pre-commit autoupdate
}
# ============================================================
# B) Package command surface
# ============================================================
Invoke-Step "B1) Run se-df dry-run command" "uv run se-df" {
uv run se-df
}
Invoke-Step "B2) Run se-df init command" "uv run se-df init" {
uv run se-df init
}
Invoke-Step "B3) Run se-df validate command" "uv run se-df validate" {
uv run se-df validate
}
Invoke-Step "B4) Run se-df generate command" "uv run se-df generate" {
uv run se-df generate
}
Invoke-Step "B5) Run se-df translate command" "uv run se-df translate" {
uv run se-df translate
}
Invoke-Step "B6) Run se-df compare command" "uv run se-df compare" {
uv run se-df compare
}
Invoke-Step "B7) Run se-df check command" "uv run se-df check" {
uv run se-df check
}
Invoke-Step "B8) Run se-df package command" "uv run se-df package" {
uv run se-df package
}
Invoke-Step "B9) Run se-df report command" "uv run se-df report" {
uv run se-df report
}
# ============================================================
# C) Pre-commit and Python tests
# ============================================================
Invoke-Step "C1) Stage all changes so pre-commit sees tracked/staged files" "git add -A" {
git add -A
}
Invoke-Step "C2) Run pre-commit autofix pass" "uvx pre-commit run --all-files" {
$oldNativePreference = $null
$hadNativePreference = Test-Path Variable:\PSNativeCommandUseErrorActionPreference
if ($hadNativePreference) {
$oldNativePreference = $PSNativeCommandUseErrorActionPreference
$PSNativeCommandUseErrorActionPreference = $false
}
uvx pre-commit run --all-files
$exitCode = $LASTEXITCODE
if ($hadNativePreference) {
$PSNativeCommandUseErrorActionPreference = $oldNativePreference
}
if ($exitCode -ne 0) {
Write-Host ""
Write-Host "Pre-commit may have modified files. Staging changes and continuing to verification pass."
git add -A
}
}
Invoke-Step "C3) Run pre-commit verification pass" "uvx pre-commit run --all-files" {
uvx pre-commit run --all-files
}
Invoke-Step "C4) Run Python tests" "uvx --python 3.15 -m pytest" {
uvx --python 3.15 -m pytest
}
Invoke-Step "C5) Run Pyright" "uvx --python 3.15 -m pyright" {
uvx --python 3.15 -m pyright
}
Invoke-Step "C6) Run final pre-commit check after tests/type checks" "uvx pre-commit run --all-files" {
uvx pre-commit run --all-files
}
# ============================================================
# D) Documentation
# ============================================================
Invoke-Step "D1) Build documentation" "uv run python -m zensical build" {
uv run python -m zensical build
}
# ============================================================
# E) Architectural and code-health checks
# ============================================================
Invoke-Step "E0) Check import layers" "run import-linter" {
$previousPythonPath = $env:PYTHONPATH
try {
$env:PYTHONPATH = Join-Path $PSScriptRoot "src"
uvx --python 3.14 --from import-linter `
lint-imports `
--config (Join-Path $PSScriptRoot ".github/.importlinter")
if ($LASTEXITCODE -ne 0) {
throw "Import Linter failed with exit code $LASTEXITCODE."
}
}
finally {
if ($null -eq $previousPythonPath) {
Remove-Item Env:PYTHONPATH -ErrorAction SilentlyContinue
}
else {
$env:PYTHONPATH = $previousPythonPath
}
}
}
Invoke-Step "E1) Find dead code" "uvx --with-editable . vulture src/se_df" {
uvx --with-editable . vulture src/se_df
}
Invoke-Step "E2) Check complexity; any output means C-or-worse complexity exists" "uvx radon cc src/se_df -s -a -n C" {
uvx radon cc src/se_df -s -a -n C
}
Invoke-Step "E3) Report raw code metrics" "uvx radon raw src/se_df -j | uv run python -c `"import json, sys; data=json.load(sys.stdin); keys=('loc','lloc','sloc','comments','multi','blank','single_comments'); totals={k:sum(file[k] for file in data.values()) for k in keys}; print('\n'.join(f'{k.upper()}: {v}' for k,v in totals.items()))`"" {
uvx radon raw src/se_df -j | uv run python -c "import json, sys; data=json.load(sys.stdin); keys=('loc','lloc','sloc','comments','multi','blank','single_comments'); totals={k:sum(file[k] for file in data.values()) for k in keys}; print('\n'.join(f'{k.upper()}: {v}' for k,v in totals.items()))"
}
# ============================================================
# F) Distribution artifacts and installed-package smoke tests
# ============================================================
Invoke-Step "F0) Clean distribution artifacts" "uv run python -c `"import shutil; from pathlib import Path; shutil.rmtree(Path('dist'), ignore_errors=True)`"" {
uv run python -c "import shutil; from pathlib import Path; shutil.rmtree(Path('dist'), ignore_errors=True)"
}
Invoke-Step "F1) Build source and wheel distributions" "uv build" {
uv build
}
Invoke-Step "F2) Check distribution metadata" "uvx twine check dist/*" {
uvx twine check dist/*
}
Invoke-Step "F3) Confirm wheel was built" "Get-ChildItem dist -Filter *.whl" {
$wheels = Get-ChildItem dist -Filter "*.whl" | Sort-Object LastWriteTime
if (-not $wheels) {
throw "No wheel found in dist/."
}
$wheel = $wheels[-1]
Write-Host "Wheel: $($wheel.FullName)"
}
Invoke-Step "F4) Smoke test installed wheel command help" "uvx --from <built-wheel> se-df --help" {
$wheel = Get-ChildItem dist -Filter "*.whl" | Sort-Object LastWriteTime | Select-Object -Last 1
if (-not $wheel) {
throw "No wheel found in dist/."
}
uvx --from $wheel.FullName se-df --help
}
Invoke-Step "F5) Smoke test installed wheel package metadata" "uvx --from <built-wheel> python -c `"from importlib.metadata import version; print(version('se-df'))`"" {
$wheel = Get-ChildItem dist -Filter "*.whl" | Sort-Object LastWriteTime | Select-Object -Last 1
if (-not $wheel) {
throw "No wheel found in dist/."
}
uvx --from $wheel.FullName python -c "from importlib.metadata import version; print(version('se-df'))"
}