# This workflow validates code generation and API export integrity by running # the relevant scripts and ensuring they complete without producing changes. name: Code integrity checks on: pull_request: paths: - 'codegen/**' - 'specification/**' - 'OpenAI/src/**' - 'OpenAI.Responses/src/**' - 'package.json' - 'global.json' - 'package-lock.json' - '.github/workflows/integrity-checks.yml' - 'scripts/Invoke-CodeGen.ps1' - 'scripts/Export-Api.ps1' - 'api/**' - 'Directory.Build.targets' - 'tests/Snippets/**' - 'README.md' - 'scripts/Update-Snippets.ps1' types: [opened, reopened, synchronize] workflow_dispatch: permissions: contents: read jobs: validate-codegen: name: Validate code generation runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Node.js uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 with: node-version: '22.x' - name: Set up .NET uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 with: # Use the version specified in global.json global-json-file: global.json - name: Run Invoke-CodeGen script shell: pwsh run: | Write-Host "Running code generation validation..." ./scripts/Invoke-CodeGen.ps1 -Clean if ($LASTEXITCODE -ne 0) { Write-Error "Code generation failed with exit code: $LASTEXITCODE" exit $LASTEXITCODE } Write-Host "Code generation completed successfully!" - name: Check for uncommitted changes uses: ./.github/actions/check-uncommitted-changes with: error-message: "Code generation produced changes. Please run './scripts/Invoke-CodeGen.ps1' locally and commit the results." - name: Run codegen visitor tests run: dotnet test codegen/generator/test/ --configuration Release --logger "trx;LogFilePrefix=codegen" --results-directory ${{github.workspace}}/artifacts/test-results ${{ env.version_suffix_args}} - name: Upload artifacts uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 if: ${{ !cancelled() }} with: name: build-artifacts path: ${{github.workspace}}/artifacts validate-api-export: name: Validate API export runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up .NET uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 with: # Use the version specified in global.json global-json-file: global.json - name: Run Export-Api script shell: pwsh run: | Write-Host "Running API export validation..." ./scripts/Export-Api.ps1 if ($LASTEXITCODE -ne 0) { Write-Error "API export failed with exit code: $LASTEXITCODE" exit $LASTEXITCODE } Write-Host "API export completed successfully!" - name: Check for uncommitted changes uses: ./.github/actions/check-uncommitted-changes with: error-message: "API export produced changes. Please run './scripts/Export-Api.ps1' locally and commit the results." validate-snippets: name: Validate documentation snippets runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up .NET uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 with: # Use the version specified in global.json global-json-file: global.json - name: Run Update-Snippets script shell: pwsh run: | Write-Host "Running snippet update validation..." ./scripts/Update-Snippets.ps1 if ($LASTEXITCODE -ne 0) { Write-Error "Snippet update failed with exit code: $LASTEXITCODE" exit $LASTEXITCODE } Write-Host "Snippet update completed successfully!" - name: Check for uncommitted changes uses: ./.github/actions/check-uncommitted-changes with: error-message: "Documentation snippets are out of date. Please run './scripts/Update-Snippets.ps1' locally and commit the results."