Skip to content

chore: add generic impact for thresholds #25

chore: add generic impact for thresholds

chore: add generic impact for thresholds #25

Workflow file for this run

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"