Skip to content

Génération automatique des xsd #228

Génération automatique des xsd

Génération automatique des xsd #228

Workflow file for this run

name: generate-model
on:
pull_request:
branches:
- '**'
workflow_dispatch:
env:
SCHEMAS: "RC-EDA RS-EDA EMSI"
jobs:
generate:
runs-on: ubuntu-latest
env:
JAVA_POST_PROCESS_FILE: "/usr/bin/clang-format -i"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Graphviz
uses: ts-graphviz/setup-graphviz@v1
- name: Install python requirements
working-directory: ./csv_parser
run: pip install -r ./requirements.txt
- name: Run csv_parser and collect OpenAPI & JSON Schemas
working-directory: ./csv_parser
run: python workflow.py --stage parser_and_mv
- name: Install JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
- name: generate XSDs
working-directory: ./csv_parser/json_schema2xsd
run: gradle run
- name: copy XSDs to src
working-directory: ./csv_parser/json_schema2xsd
run: |
cp out/* ../../src/main/resources/json-schema/
- name: Install node env 🏗
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install openapi-generator-cli
run: npm install -g @openapitools/openapi-generator-cli
- name: Install linter
run: sudo apt install -y clang-format
- name: Generate Java classes
working-directory: ./generator
run: |
npx @openapitools/openapi-generator-cli generate -c ./config/common/common.generator-config.json --skip-validate-spec
npx @openapitools/openapi-generator-cli generate -c ./config/common/common.wrapper.generator-config.json --skip-validate-spec
npx @openapitools/openapi-generator-cli generate -c ./config/common/common.usecase.generator-config.json --skip-validate-spec
npx @openapitools/openapi-generator-cli generate -c ./config/common/common.distributionElement.generator-config.json --skip-validate-spec
IFS=' ' read -ra SCHEMAS_ARRAY <<< "$SCHEMAS"
for SCHEMA in "${SCHEMAS_ARRAY[@]}"; do
npx @openapitools/openapi-generator-cli generate -c ./config/$SCHEMA/$SCHEMA.generator-config.json --skip-validate-spec
npx @openapitools/openapi-generator-cli generate -c ./config/$SCHEMA/$SCHEMA.usecase.generator-config.json --skip-validate-spec
npx @openapitools/openapi-generator-cli generate -c ./config/$SCHEMA/$SCHEMA.wrapper.generator-config.json --skip-validate-spec
done
- name: Replace src/ with generated classes
run: |
rm -r ./src/main/java/com/hubsante/model/common || true
rm -r ./src/main/java/com/hubsante/model/cisu || true
rm -r ./src/main/java/com/hubsante/model/health || true
rm -r ./src/main/java/com/hubsante/model/emsi || true
cp -r ./generator/classes/src/main/java/com/hubsante/model/* ./src/main/java/com/hubsante/model/
- name: Grant execute permission for Gradlew
run: chmod +x ./gradlew
- name: Apply license
run: ./gradlew licenseFormat
- name: Commit and push changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: ⚙️ Auto-génération des classes et des specs
- name: Build and run tests
run: ./gradlew test --info
# Ref.: https://github.com/gradle/gradle-build-action/issues/619#issuecomment-1453244157
- name: Upload test report
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-report
path: build/reports/tests/test/**
- name: Add coverage to PR
id: jacoco
uses: madrapps/jacoco-report@v1.3
with:
paths: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 40
min-coverage-changed-files: 60
- name: Setup .NET Core # Required to execute ReportGenerator
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x
dotnet-quality: 'ga'
- name: Run ReportGenerator for test coverage
uses: danielpalme/ReportGenerator-GitHub-Action@5.1.23
with:
reports: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml
targetdir: coveragereport