-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.ps1
More file actions
289 lines (249 loc) · 9.63 KB
/
run.ps1
File metadata and controls
289 lines (249 loc) · 9.63 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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# Cinema Ticket Management System - PowerShell Runner
# ==================================================
param(
[Parameter(Position=0)]
[string]$Command = "help",
[switch]$Help
)
# Colors
$Colors = @{
Blue = "Cyan"
Green = "Green"
Yellow = "Yellow"
Red = "Red"
Reset = "White"
}
function Write-ColorOutput {
param(
[string]$Message,
[string]$Color = "White"
)
Write-Host $Message -ForegroundColor $Color
}
function Show-Help {
Write-ColorOutput "Cinema Ticket Management System" $Colors.Blue
Write-ColorOutput "===============================" $Colors.Blue
Write-Host ""
Write-ColorOutput "Available commands:" $Colors.Green
Write-Host ""
$commands = @(
@{Name="help"; Description="Show this help message"},
@{Name="install"; Description="Install basic dependencies"},
@{Name="install-dev"; Description="Install with development dependencies"},
@{Name="setup"; Description="Setup complete development environment"},
@{Name="test"; Description="Run tests with pytest"},
@{Name="test-verbose"; Description="Run tests with verbose output"},
@{Name="test-coverage"; Description="Run tests with coverage report"},
@{Name="test-unittest"; Description="Run tests with unittest"},
@{Name="lint"; Description="Run all linting checks"},
@{Name="format"; Description="Format code with black and isort"},
@{Name="check"; Description="Run all checks (lint + test)"},
@{Name="analyze"; Description="Run comprehensive code quality analysis"},
@{Name="fix"; Description="Auto-fix code issues using libraries"},
@{Name="security"; Description="Run security analysis"},
@{Name="run"; Description="Run the main application"},
@{Name="clean"; Description="Clean temporary files and build artifacts"},
@{Name="benchmark-initial"; Description="Record initial benchmark"},
@{Name="benchmark-post-autofix"; Description="Record post-autofix benchmark"},
@{Name="benchmark-post-ai"; Description="Record post-AI benchmark"},
@{Name="benchmark-compare"; Description="Compare all benchmark stages"},
@{Name="benchmark-report"; Description="Generate comprehensive benchmark report"},
@{Name="quick-test"; Description="Quick test run"},
@{Name="quick-lint"; Description="Quick lint check"}
)
foreach ($cmd in $commands) {
Write-ColorOutput (" {0,-20}" -f $cmd.Name) $Colors.Blue -NoNewline
Write-ColorOutput $cmd.Description $Colors.Reset
}
Write-Host ""
Write-ColorOutput "Quick start:" $Colors.Yellow
Write-ColorOutput " .\run.ps1 setup # Setup development environment" $Colors.Reset
Write-ColorOutput " .\run.ps1 test # Run tests" $Colors.Reset
Write-ColorOutput " .\run.ps1 run # Run the application" $Colors.Reset
Write-Host ""
}
function Test-PythonInstalled {
try {
$pythonVersion = python --version 2>&1
if ($LASTEXITCODE -ne 0) {
throw "Python not found"
}
return $true
}
catch {
Write-ColorOutput "Error: Python is not installed or not in PATH" $Colors.Red
Write-ColorOutput "Please install Python 3.9+ from https://python.org" $Colors.Reset
exit 1
}
}
function Invoke-Install {
Write-ColorOutput "Installing dependencies..." $Colors.Green
pip install -r requirements.txt
pip install -e .
}
function Invoke-InstallDev {
Write-ColorOutput "Installing development dependencies..." $Colors.Green
pip install -e ".[dev]"
pip install -r requirements.txt
}
function Invoke-Setup {
Invoke-InstallDev
Write-ColorOutput "Setting up development environment..." $Colors.Green
Write-ColorOutput "✓ Dependencies installed" $Colors.Green
Write-ColorOutput "✓ Package installed in development mode" $Colors.Green
Write-Host ""
Write-ColorOutput "Development environment ready!" $Colors.Blue
Write-ColorOutput "Run '.\run.ps1 help' to see available commands" $Colors.Yellow
}
function Invoke-Test {
Write-ColorOutput "Running tests..." $Colors.Green
pytest
}
function Invoke-TestVerbose {
Write-ColorOutput "Running tests with verbose output..." $Colors.Green
pytest -v
}
function Invoke-TestCoverage {
Write-ColorOutput "Running tests with coverage..." $Colors.Green
pytest --cov=src --cov-report=html --cov-report=term --cov-report=xml
}
function Invoke-TestUnittest {
Write-ColorOutput "Running tests with unittest..." $Colors.Green
python -m unittest discover -v
}
function Invoke-Lint {
Write-ColorOutput "Running linting checks..." $Colors.Green
Write-ColorOutput "Checking with ruff..." $Colors.Yellow
ruff check .
Write-ColorOutput "Checking with black..." $Colors.Yellow
black --check .
Write-ColorOutput "Checking with isort..." $Colors.Yellow
isort --check-only .
Write-ColorOutput "Checking with mypy..." $Colors.Yellow
mypy src/ tests/ main.py --ignore-missing-imports
Write-ColorOutput "✓ All linting checks passed" $Colors.Green
}
function Invoke-Format {
Write-ColorOutput "Formatting code..." $Colors.Green
Write-ColorOutput "Formatting with black..." $Colors.Yellow
black .
Write-ColorOutput "Organizing imports with isort..." $Colors.Yellow
isort .
Write-ColorOutput "✓ Code formatted" $Colors.Green
}
function Invoke-Check {
Invoke-Lint
Invoke-Test
Write-ColorOutput "✓ All checks passed" $Colors.Green
}
function Invoke-Analyze {
Write-ColorOutput "Running code quality analysis..." $Colors.Green
python tools/analyze_code_quality.py
}
function Invoke-Fix {
Write-ColorOutput "Auto-fixing code issues..." $Colors.Green
python tools/auto_code_fixer_libraries_only.py
}
function Invoke-Security {
Write-ColorOutput "Running security analysis..." $Colors.Green
Write-ColorOutput "Checking with bandit..." $Colors.Yellow
bandit -r src/ tests/ main.py
Write-ColorOutput "Checking dependencies with safety..." $Colors.Yellow
safety check
Write-ColorOutput "Auditing packages with pip-audit..." $Colors.Yellow
pip-audit
}
function Invoke-Run {
Write-ColorOutput "Running Cinema Ticket Management System..." $Colors.Green
python main.py
}
function Invoke-Clean {
Write-ColorOutput "Cleaning temporary files..." $Colors.Green
# Remove __pycache__ directories
Get-ChildItem -Path . -Recurse -Directory -Name "__pycache__" | ForEach-Object {
Remove-Item -Path $_ -Recurse -Force -ErrorAction SilentlyContinue
}
# Remove .pyc files
Get-ChildItem -Path . -Recurse -Filter "*.pyc" | Remove-Item -Force -ErrorAction SilentlyContinue
# Remove .egg-info directories
Get-ChildItem -Path . -Recurse -Directory -Filter "*.egg-info" | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
# Remove other directories
$dirsToRemove = @("build", "dist", "htmlcov", ".pytest_cache", ".mypy_cache", ".ruff_cache", ".tox", ".venv", "venv")
foreach ($dir in $dirsToRemove) {
if (Test-Path $dir) {
Remove-Item -Path $dir -Recurse -Force -ErrorAction SilentlyContinue
}
}
# Remove files
$filesToRemove = @(".coverage", "bandit_report.json", "coverage.xml")
foreach ($file in $filesToRemove) {
if (Test-Path $file) {
Remove-Item -Path $file -Force -ErrorAction SilentlyContinue
}
}
Write-ColorOutput "✓ Cleanup completed" $Colors.Green
}
function Invoke-BenchmarkInitial {
Write-ColorOutput "Recording initial benchmark..." $Colors.Green
python tools/benchmark_code_quality.py --stage initial --description "Initial code quality state"
}
function Invoke-BenchmarkPostAutofix {
Write-ColorOutput "Recording post-autofix benchmark..." $Colors.Green
python tools/benchmark_code_quality.py --stage post-autofix --description "After running automated fixes"
}
function Invoke-BenchmarkPostAI {
Write-ColorOutput "Recording post-AI benchmark..." $Colors.Green
python tools/benchmark_code_quality.py --stage post-ai --description "After AI agent improvements"
}
function Invoke-BenchmarkCompare {
Write-ColorOutput "Comparing benchmark stages..." $Colors.Green
python tools/benchmark_code_quality.py --compare --table
}
function Invoke-BenchmarkReport {
Write-ColorOutput "Generating benchmark report..." $Colors.Green
python tools/benchmark_code_quality.py --report
}
function Invoke-QuickTest {
pytest -x
}
function Invoke-QuickLint {
ruff check src/ tests/ main.py
}
# Main execution
if ($Help) {
Show-Help
exit 0
}
# Check Python installation
Test-PythonInstalled
# Route commands
switch ($Command.ToLower()) {
"help" { Show-Help }
"install" { Invoke-Install }
"install-dev" { Invoke-InstallDev }
"setup" { Invoke-Setup }
"test" { Invoke-Test }
"test-verbose" { Invoke-TestVerbose }
"test-coverage" { Invoke-TestCoverage }
"test-unittest" { Invoke-TestUnittest }
"lint" { Invoke-Lint }
"format" { Invoke-Format }
"check" { Invoke-Check }
"analyze" { Invoke-Analyze }
"fix" { Invoke-Fix }
"security" { Invoke-Security }
"run" { Invoke-Run }
"clean" { Invoke-Clean }
"benchmark-initial" { Invoke-BenchmarkInitial }
"benchmark-post-autofix" { Invoke-BenchmarkPostAutofix }
"benchmark-post-ai" { Invoke-BenchmarkPostAI }
"benchmark-compare" { Invoke-BenchmarkCompare }
"benchmark-report" { Invoke-BenchmarkReport }
"quick-test" { Invoke-QuickTest }
"quick-lint" { Invoke-QuickLint }
default {
Write-ColorOutput "Unknown command: $Command" $Colors.Red
Show-Help
exit 1
}
}