chore: add generic impact for thresholds #25
Workflow file for this run
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 API Models | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'API specification version to validate (e.g., v1, v2)' | |
| required: true | |
| default: 'v1' | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Cache Maven packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2 | |
| key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: ${{ runner.os }}-m2 | |
| - name: Cache npm dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| - name: Get API version | |
| id: api-version | |
| run: | | |
| if [ "${{ github.event.inputs.version }}" != "" ]; then | |
| echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=v1" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Check Git repository state | |
| run: | | |
| echo "π Checking Git repository state..." | |
| # Check if repository is clean | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "β οΈ Warning: Repository has uncommitted changes:" | |
| git status --porcelain | |
| echo "" | |
| echo "This might affect the validation results." | |
| else | |
| echo "β Repository is clean" | |
| fi | |
| # Show current branch and commit | |
| echo "π Current branch: $(git branch --show-current)" | |
| echo "π Current commit: $(git rev-parse --short HEAD)" | |
| echo "π Commit message: $(git log -1 --pretty=format:'%s')" | |
| - name: Test Java model generation | |
| run: | | |
| echo "π¨ Testing Java model generation..." | |
| cd api-models/java | |
| mvn clean generate-sources compile -Dapi.version=${{ steps.api-version.outputs.version }} -q | |
| echo "β Java models generated successfully" | |
| - name: Test TypeScript model generation | |
| run: | | |
| echo "π¨ Testing TypeScript model generation..." | |
| cd api-models/typescript | |
| npm ci --silent | |
| npm run generate --version=${{ steps.api-version.outputs.version }} | |
| npm run build --silent | |
| echo "β TypeScript models generated successfully" | |
| - name: Validate tools configuration | |
| run: | | |
| echo "π Validating tools configuration..." | |
| cd tools | |
| npm ci --silent | |
| npm run build --silent | |
| node dist/index.js config validate --root ../ | |
| echo "β Tools configuration validated" | |
| - name: Test API model generation (no unintended file changes) | |
| run: | | |
| echo "π Testing API generation doesn't create/modify unintended files..." | |
| # Store current Git state | |
| echo "πΈ Storing current Git state..." | |
| git status --porcelain > /tmp/before_generate.txt | |
| git diff --name-only > /tmp/before_generate_diff.txt | |
| # Clean generated files to start fresh | |
| echo "π§Ή Cleaning previously generated files..." | |
| cd tools | |
| node dist/index.js api clean --type both | |
| cd .. | |
| # Run API model validation | |
| echo "π¨ Running API model validation..." | |
| cd tools | |
| node dist/index.js api validate --spec-version=${{ steps.api-version.outputs.version }} | |
| cd .. | |
| # The API model validation handles all the validation logic | |
| echo "β API model validation completed successfully" | |
| - name: Validate generated files | |
| run: | | |
| echo "π Validating generated files..." | |
| # Check Java generated files | |
| if [ -d "api-models/java/target/generated-sources/openapi" ]; then | |
| echo "β Java models generated in target/generated-sources/openapi" | |
| find api-models/java/target/generated-sources/openapi -name "*.java" | head -5 | |
| else | |
| echo "β Java models not generated" | |
| exit 1 | |
| fi | |
| # Check TypeScript generated files | |
| if [ -d "api-models/typescript/src/generated" ]; then | |
| echo "β TypeScript models generated in src/generated" | |
| find api-models/typescript/src/generated -name "*.ts" | head -5 | |
| else | |
| echo "β TypeScript models not generated" | |
| exit 1 | |
| fi | |
| echo "β All generated files validated" | |
| - name: Summary | |
| run: | | |
| echo "π API Models validation completed successfully!" | |
| echo "Version: ${{ steps.api-version.outputs.version }}" | |
| echo "β Configurations validated" | |
| echo "β Java models generated and compiled" | |
| echo "β TypeScript models generated and built" | |
| echo "β Tools configuration validated" | |
| echo "β make generate doesn't create unintended files" | |
| echo "β Generated files validated" |