1+ # This workflow validates changes made to the codegen folder by running code generation
2+ # and ensuring the process completes successfully without errors.
3+ name : CodeGen Validation
4+
5+ on :
6+ pull_request :
7+ paths :
8+ - ' codegen/**'
9+ - ' .github/workflows/codegen-validation.yml'
10+ - ' scripts/Invoke-CodeGen.ps1'
11+ types : [opened, reopened, synchronize]
12+ workflow_dispatch :
13+
14+ jobs :
15+ validate-codegen :
16+ name : Validate Code Generation
17+ runs-on : ubuntu-latest
18+
19+ steps :
20+ - name : Checkout code
21+ uses : actions/checkout@v4
22+
23+ - name : Setup Node.js
24+ uses : actions/setup-node@v4
25+ with :
26+ node-version : ' 22.x'
27+
28+ - name : Setup .NET
29+ uses : actions/setup-dotnet@v4
30+ with :
31+ # Use the version specified in global.json
32+ global-json-file : global.json
33+
34+ - name : Run CodeGen Script
35+ shell : pwsh
36+ run : |
37+ Write-Host "Running code generation validation..."
38+ ./scripts/Invoke-CodeGen.ps1
39+
40+ if ($LASTEXITCODE -ne 0) {
41+ Write-Error "Code generation failed with exit code: $LASTEXITCODE"
42+ exit $LASTEXITCODE
43+ }
44+
45+ Write-Host "Code generation completed successfully!"
46+
47+ - name : Check for uncommitted changes
48+ run : |
49+ # Check if there are any changes to tracked files after code generation
50+ if ! git diff --quiet; then
51+ echo "::error::Code generation produced uncommitted changes. Please run the codegen script locally and commit the results."
52+ echo "Changed files:"
53+ git diff --name-only
54+ echo "Diff details:"
55+ git diff
56+ exit 1
57+ fi
58+
59+ # Also check for untracked files that might have been generated
60+ if [ -n "$(git ls-files --others --exclude-standard)" ]; then
61+ echo "::error::Code generation produced untracked files. Please review and commit them if they should be included."
62+ echo "Untracked files:"
63+ git ls-files --others --exclude-standard
64+ exit 1
65+ fi
66+
67+ echo "No uncommitted changes detected - code generation is up to date!"
0 commit comments