|
| 1 | +$ErrorActionPreference = "Stop" |
| 2 | + |
| 3 | +$root = Split-Path -Parent $PSScriptRoot |
| 4 | +Set-Location $root |
| 5 | + |
| 6 | +$checkpointKinds = @("projects", "assessments") |
| 7 | +$languages = @("cpp", "csharp", "go", "python") |
| 8 | +$requiredMainByLanguage = @{ |
| 9 | + csharp = "main.cs" |
| 10 | + go = "main.go" |
| 11 | + python = "main.py" |
| 12 | +} |
| 13 | + |
| 14 | +$failures = @() |
| 15 | +$checkpointCount = 0 |
| 16 | + |
| 17 | +foreach ($language in $languages) { |
| 18 | + $langRoot = Join-Path $root "languages/$language" |
| 19 | + if (-not (Test-Path $langRoot)) { |
| 20 | + continue |
| 21 | + } |
| 22 | + |
| 23 | + foreach ($kind in $checkpointKinds) { |
| 24 | + $kindPath = Join-Path $langRoot $kind |
| 25 | + if (-not (Test-Path $kindPath)) { |
| 26 | + continue |
| 27 | + } |
| 28 | + |
| 29 | + $checkpointDirs = Get-ChildItem -Path $kindPath -Directory |
| 30 | + foreach ($checkpoint in $checkpointDirs) { |
| 31 | + $checkpointCount++ |
| 32 | + |
| 33 | + $readmePath = Join-Path $checkpoint.FullName "README.md" |
| 34 | + if (-not (Test-Path $readmePath)) { |
| 35 | + $failures += "$($checkpoint.FullName): missing README.md" |
| 36 | + } |
| 37 | + |
| 38 | + if ($requiredMainByLanguage.ContainsKey($language)) { |
| 39 | + $mainPath = Join-Path $checkpoint.FullName $requiredMainByLanguage[$language] |
| 40 | + if (-not (Test-Path $mainPath)) { |
| 41 | + $failures += "$($checkpoint.FullName): missing $($requiredMainByLanguage[$language])" |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + if ($language -eq "csharp") { |
| 46 | + $csprojFiles = Get-ChildItem -Path $checkpoint.FullName -Filter *.csproj -File |
| 47 | + if ($csprojFiles.Count -eq 0) { |
| 48 | + $failures += "$($checkpoint.FullName): missing .csproj file" |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +if ($checkpointCount -eq 0) { |
| 56 | + Write-Host "No checkpoint directories found for completeness validation." |
| 57 | + exit 1 |
| 58 | +} |
| 59 | + |
| 60 | +if ($failures.Count -gt 0) { |
| 61 | + Write-Host "Checkpoint completeness validation failed:" |
| 62 | + $failures | ForEach-Object { Write-Host " - $_" } |
| 63 | + exit 1 |
| 64 | +} |
| 65 | + |
| 66 | +Write-Host "Checkpoint completeness validation passed for $checkpointCount checkpoint directories." |
0 commit comments