Add GH action to validate generated code #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Validate Generated Code | |
| on: | |
| pull_request: # Typically, you'd want this on PRs to catch issues before merge | |
| branches: | |
| - main # Or your default branch, e.g., 'master' | |
| push: | |
| branches: | |
| - main # Also useful on push to ensure main is always clean | |
| workflow_dispatch: # Allows manual triggering from the GitHub UI | |
| jobs: | |
| validate_generated_code: | |
| runs-on: ubuntu-latest # Or your preferred runner environment | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js and Yarn | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' # Specify your Node.js version | |
| cache: 'yarn' # Cache Yarn dependencies | |
| - name: Enable Corepack | |
| run: corepack enable # This command enables Corepack to manage package managers like Yarn 2+ | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile # Use --frozen-lockfile for CI environments | |
| - name: Build code | |
| run: yarn build | |
| - name: Check for uncommitted generated changes | |
| run: | | |
| # Check if there are any uncommitted changes after the build | |
| if git status --porcelain | grep -q .; then | |
| echo "Error: Generated code differences detected!" | |
| echo "Please run 'yarn build' locally and commit the changes." | |
| git status --porcelain # Show the specific files that are different | |
| exit 1 # Fail the workflow | |
| else | |
| echo "No differences found in generated code. Build is clean." | |
| fi |