update #15
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 Docker Buildx (recommended for multi-platform builds) | |
| # This action sets up Docker Buildx, which is useful for building Docker images | |
| # and ensures better compatibility and performance for Docker operations. | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and Run Docker Compose Build Services | |
| # This step uses your docker-compose.yml to build all necessary images | |
| # and run the services defined under the 'build' profile. | |
| # --profile build: Activates only services with the 'build' profile. | |
| # --build: Forces a rebuild of images before starting containers. | |
| # --exit-code-from build: Ensures the workflow fails if the 'build' service (your orchestrator service) exits with a non-zero code. | |
| run: | | |
| docker compose --profile build up --build --exit-code-from build | |
| - name: Check for uncommitted generated changes | |
| # This step runs after the Docker Compose services have completed. | |
| # Since your docker-compose.yml uses volume mounts (e.g., .:/usr/src/xorca), | |
| # any files generated or modified within the Docker containers will be | |
| # reflected in your host repository, allowing git to detect them. | |
| run: | | |
| if git status --porcelain | grep -q .; then | |
| echo "Error: Generated code differences detected!" | |
| echo "Please run 'docker compose --profile build up --build --exit-code-from 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 |