Skip to content

Commit 2b178d6

Browse files
committed
Add repo health scripts and run plugin option tests
1 parent 6405715 commit 2b178d6

4 files changed

Lines changed: 406 additions & 0 deletions

File tree

‎scripts/commit_project.ps1‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
param(
2+
[Parameter(Mandatory = $true)]
3+
[string]$Message,
4+
5+
[switch]$Push
6+
)
7+
8+
$ErrorActionPreference = "Stop"
9+
10+
Write-Host ""
11+
Write-Host "=== SkunkScrape Commit Project ===" -ForegroundColor Cyan
12+
13+
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
14+
Write-Error "Git is not available on PATH."
15+
}
16+
17+
if (-not (Test-Path ".\scripts\commit_ready.ps1")) {
18+
Write-Error "scripts\commit_ready.ps1 not found."
19+
}
20+
21+
Write-Host ""
22+
Write-Host "[1/4] Running commit readiness check..." -ForegroundColor Yellow
23+
powershell -ExecutionPolicy Bypass -File .\scripts\commit_ready.ps1
24+
if ($LASTEXITCODE -ne 0) {
25+
Write-Error "Commit readiness check failed."
26+
}
27+
28+
Write-Host ""
29+
Write-Host "[2/4] Staging approved files..." -ForegroundColor Yellow
30+
31+
$pathsToStage = @(
32+
".\main.py",
33+
".\pyproject.toml",
34+
".\README.md",
35+
".\.gitignore",
36+
".\skunkscrape",
37+
".\tests",
38+
".\scripts"
39+
)
40+
41+
foreach ($path in $pathsToStage) {
42+
if (Test-Path $path) {
43+
git add $path
44+
}
45+
}
46+
47+
Write-Host ""
48+
Write-Host "[3/4] Git status after staging:" -ForegroundColor Yellow
49+
git status --short
50+
51+
Write-Host ""
52+
Write-Host "[4/4] Creating commit..." -ForegroundColor Yellow
53+
git commit -m $Message
54+
55+
if ($LASTEXITCODE -ne 0) {
56+
Write-Error "Git commit failed."
57+
}
58+
59+
if ($Push.IsPresent) {
60+
Write-Host ""
61+
Write-Host "[Push] Pushing to origin main..." -ForegroundColor Yellow
62+
git push origin main
63+
64+
if ($LASTEXITCODE -ne 0) {
65+
Write-Error "Git push failed."
66+
}
67+
}
68+
69+
Write-Host ""
70+
Write-Host "Commit workflow completed successfully." -ForegroundColor Green

‎scripts/commit_ready.ps1‎

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
$ErrorActionPreference = "Stop"
2+
$hasBlockingIssue = $false
3+
4+
function Write-Section($title) {
5+
Write-Host ""
6+
Write-Host "[$title]" -ForegroundColor Yellow
7+
}
8+
9+
function Flag-Blocking($message) {
10+
Write-Host $message -ForegroundColor Red
11+
$script:hasBlockingIssue = $true
12+
}
13+
14+
Write-Host ""
15+
Write-Host "=== SkunkScrape Commit Readiness Check ===" -ForegroundColor Cyan
16+
17+
Write-Section "Tooling"
18+
if (Get-Command python -ErrorAction SilentlyContinue) {
19+
python --version
20+
} else {
21+
Flag-Blocking "Python not found on PATH."
22+
}
23+
24+
if (Get-Command git -ErrorAction SilentlyContinue) {
25+
git --version
26+
} else {
27+
Flag-Blocking "Git not found on PATH."
28+
}
29+
30+
Write-Section "Key Files"
31+
$requiredPaths = @(
32+
".\main.py",
33+
".\pyproject.toml",
34+
".\README.md",
35+
".\skunkscrape\plugins\manifest.json",
36+
".\tests\test_manifest.py",
37+
".\tests\test_smart_contact_crawler.py",
38+
".\tests\test_main.py"
39+
)
40+
41+
foreach ($path in $requiredPaths) {
42+
if (Test-Path $path) {
43+
Write-Host "[OK] $path" -ForegroundColor Green
44+
} else {
45+
Flag-Blocking "[MISS] $path"
46+
}
47+
}
48+
49+
Write-Section "Pytest"
50+
try {
51+
python -m pytest
52+
if ($LASTEXITCODE -eq 0) {
53+
Write-Host "Test suite passed." -ForegroundColor Green
54+
} else {
55+
Flag-Blocking "Test suite failed."
56+
}
57+
}
58+
catch {
59+
Flag-Blocking "Pytest execution failed: $($_.Exception.Message)"
60+
}
61+
62+
Write-Section "Merge Conflict Markers"
63+
$conflicts = git grep -nE '^(<<<<<<<|=======|>>>>>>>)' 2>$null
64+
if ($conflicts) {
65+
Flag-Blocking "Merge conflict markers found:"
66+
$conflicts | ForEach-Object { Write-Host $_ -ForegroundColor Red }
67+
} else {
68+
Write-Host "No merge conflict markers found." -ForegroundColor Green
69+
}
70+
71+
Write-Section "README Sanity Check"
72+
if (Test-Path ".\README.md") {
73+
$readmeHead = Get-Content ".\README.md" -TotalCount 5
74+
$looksWrong = $false
75+
76+
foreach ($line in $readmeHead) {
77+
if ($line -match '^\s*(import |from\s+\w+\s+import )') {
78+
$looksWrong = $true
79+
}
80+
}
81+
82+
if ($looksWrong) {
83+
Flag-Blocking "README.md appears to contain Python code instead of markdown."
84+
} else {
85+
Write-Host "README.md looks sane." -ForegroundColor Green
86+
}
87+
}
88+
89+
Write-Section "Tracked Artefact Risk"
90+
$artefactPaths = @(
91+
".\__pycache__",
92+
".\skunkscrape.egg-info",
93+
".\.pytest_cache",
94+
".\data\logs",
95+
".\data\output"
96+
)
97+
98+
foreach ($path in $artefactPaths) {
99+
if (Test-Path $path) {
100+
Write-Host "[WARN] Present: $path" -ForegroundColor DarkYellow
101+
}
102+
}
103+
104+
Write-Section "Git Status"
105+
$gitStatus = git status --short
106+
if ($gitStatus) {
107+
$gitStatus | ForEach-Object { Write-Host $_ }
108+
} else {
109+
Write-Host "Working tree clean." -ForegroundColor Green
110+
}
111+
112+
Write-Section "Ignored Files Check"
113+
$ignored = git status --ignored --short 2>$null
114+
if ($ignored) {
115+
Write-Host "Ignored file summary available." -ForegroundColor DarkGray
116+
} else {
117+
Write-Host "No ignored file output." -ForegroundColor DarkGray
118+
}
119+
120+
Write-Host ""
121+
if ($hasBlockingIssue) {
122+
Write-Host "Commit readiness check completed with blocking issues." -ForegroundColor Red
123+
exit 1
124+
} else {
125+
Write-Host "Commit readiness check passed." -ForegroundColor Green
126+
exit 0
127+
}

‎scripts/repo_status.ps1‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
Write-Host ""
4+
Write-Host "=== SkunkScrape Repo Status ===" -ForegroundColor Cyan
5+
6+
# Python
7+
Write-Host ""
8+
Write-Host "[Python]" -ForegroundColor Yellow
9+
if (Get-Command python -ErrorAction SilentlyContinue) {
10+
python --version
11+
} else {
12+
Write-Host "Python not found on PATH." -ForegroundColor Red
13+
}
14+
15+
# Key files
16+
Write-Host ""
17+
Write-Host "[Key Paths]" -ForegroundColor Yellow
18+
$paths = @(
19+
".\main.py",
20+
".\pyproject.toml",
21+
".\README.md",
22+
".\skunkscrape",
23+
".\skunkscrape\plugins\manifest.json",
24+
".\tests",
25+
".\scripts"
26+
)
27+
28+
foreach ($path in $paths) {
29+
if (Test-Path $path) {
30+
Write-Host "[OK] $path" -ForegroundColor Green
31+
} else {
32+
Write-Host "[MISS] $path" -ForegroundColor Red
33+
}
34+
}
35+
36+
# Tests
37+
Write-Host ""
38+
Write-Host "[Tests]" -ForegroundColor Yellow
39+
try {
40+
python -m pytest
41+
if ($LASTEXITCODE -eq 0) {
42+
Write-Host "Test suite passed." -ForegroundColor Green
43+
} else {
44+
Write-Host "Test suite failed." -ForegroundColor Red
45+
}
46+
}
47+
catch {
48+
Write-Host "Pytest execution failed: $($_.Exception.Message)" -ForegroundColor Red
49+
}
50+
51+
# Git status
52+
Write-Host ""
53+
Write-Host "[Git Status]" -ForegroundColor Yellow
54+
if (Get-Command git -ErrorAction SilentlyContinue) {
55+
git status --short
56+
} else {
57+
Write-Host "Git not found on PATH." -ForegroundColor Red
58+
}
59+
60+
# Recent log files
61+
Write-Host ""
62+
Write-Host "[Recent Logs]" -ForegroundColor Yellow
63+
if (Test-Path ".\data\logs") {
64+
Get-ChildItem ".\data\logs" -File |
65+
Sort-Object LastWriteTime -Descending |
66+
Select-Object -First 5 Name, LastWriteTime, Length |
67+
Format-Table -AutoSize
68+
} else {
69+
Write-Host "No data\logs folder found." -ForegroundColor DarkYellow
70+
}
71+
72+
# Recent crawler outputs
73+
Write-Host ""
74+
Write-Host "[Recent Outputs]" -ForegroundColor Yellow
75+
if (Test-Path ".\data\output\smart_contact_crawler") {
76+
Get-ChildItem ".\data\output\smart_contact_crawler" -File |
77+
Sort-Object LastWriteTime -Descending |
78+
Select-Object -First 5 Name, LastWriteTime, Length |
79+
Format-Table -AutoSize
80+
} else {
81+
Write-Host "No smart_contact_crawler output folder found." -ForegroundColor DarkYellow
82+
}
83+
84+
Write-Host ""
85+
Write-Host "Repo status check complete." -ForegroundColor Cyan

0 commit comments

Comments
 (0)