Skip to content

Commit 429d5d0

Browse files
build: add codegen CI validation workflow
1 parent 6bb8493 commit 429d5d0

File tree

1 file changed

+72
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)