Skip to content

Commit 568af1e

Browse files
build: add codegen CI validation workflow
1 parent 6bb8493 commit 568af1e

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
push:
13+
branches:
14+
- main
15+
paths:
16+
- 'codegen/**'
17+
- '.github/workflows/codegen-validation.yml'
18+
- 'scripts/Invoke-CodeGen.ps1'
19+
workflow_dispatch:
20+
21+
jobs:
22+
validate-codegen:
23+
name: Validate Code Generation
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: '22.x'
34+
35+
- name: Setup .NET
36+
uses: actions/setup-dotnet@v4
37+
with:
38+
# Use the version specified in global.json
39+
global-json-file: global.json
40+
41+
- name: Run CodeGen Script
42+
shell: pwsh
43+
run: |
44+
Write-Host "Running code generation validation..."
45+
./scripts/Invoke-CodeGen.ps1
46+
47+
if ($LASTEXITCODE -ne 0) {
48+
Write-Error "Code generation failed with exit code: $LASTEXITCODE"
49+
exit $LASTEXITCODE
50+
}
51+
52+
Write-Host "Code generation completed successfully!"
53+
54+
- name: Check for uncommitted changes
55+
run: |
56+
# Check if there are any changes to tracked files after code generation
57+
if ! git diff --quiet; then
58+
echo "::error::Code generation produced uncommitted changes. Please run the codegen script locally and commit the results."
59+
echo "Changed files:"
60+
git diff --name-only
61+
echo "Diff details:"
62+
git diff
63+
exit 1
64+
fi
65+
66+
# Also check for untracked files that might have been generated
67+
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
68+
echo "::error::Code generation produced untracked files. Please review and commit them if they should be included."
69+
echo "Untracked files:"
70+
git ls-files --others --exclude-standard
71+
exit 1
72+
fi
73+
74+
echo "No uncommitted changes detected - code generation is up to date!"

0 commit comments

Comments
 (0)