Skip to content

[ AUTO ] Model Tracker #1515

[ AUTO ] Model Tracker

[ AUTO ] Model Tracker #1515

name: generate-model
on:
pull_request:
branches:
- '**'
workflow_dispatch:
env:
SCHEMAS: "RC-EDA RS-EDA EMSI GEO-POS GEO-REQ GEO-RES RC-REF RS-ERROR RS-RI RS-DR RS-RR RPIS RS-EDA-MAJ RS-SR TECHNICAL TECHNICAL_NOREQ"
jobs:
generate:
runs-on: ubuntu-latest
env:
JAVA_POST_PROCESS_FILE: "/usr/bin/clang-format -i"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check for changes requiring running the parser
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
parsing_required:
- '**/csv_parser.py'
- '**/uml_generator.py'
- '**/workflow.py'
- '**/model.xlsx'
- '**/nomenclature_parser/**'
- '**/json_schema2xsd/**'
test_case_parsing_required:
- '**/test_case_generator.py'
- '**/workflow.py'
- '**/test-cases-15-15.xlsx'
- name: Install Graphviz
if: steps.filter.outputs.parsing_required == 'true'
uses: ts-graphviz/setup-graphviz@v1
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install python requirements
working-directory: ./csv_parser
if: steps.filter.outputs.parsing_required == 'true' || steps.filter.outputs.test_case_parsing_required == 'true'
run: pip install -r ./requirements.txt
- name: Run csv_parser and collect OpenAPI & JSON Schemas
working-directory: ./csv_parser
if: steps.filter.outputs.parsing_required == 'true'
run: python workflow.py --stage parser_and_mv
- name: Run test_case_generator and move the folder test-cases to src/main/resources/sample/test-cases
working-directory: ./csv_parser
if: steps.filter.outputs.test_case_parsing_required == 'true'
run: |
rm -r ./out/test-cases || true
python workflow.py --stage test_case_parser
rm -r ../src/main/resources/test-cases || true
mv ./out/test-cases ../src/main/resources/
- name: Install JDK 11
uses: actions/setup-java@v4
if: steps.filter.outputs.parsing_required == 'true'
with:
java-version: '11'
distribution: 'temurin'
- name: Generate XSDs
working-directory: ./csv_parser/json_schema2xsd
if: steps.filter.outputs.parsing_required == 'true'
run: gradle run
- name: Move XSDs to src
working-directory: ./csv_parser/json_schema2xsd
if: steps.filter.outputs.parsing_required == 'true'
run: |
rm out/RS-ERROR.xsd
mv out/*.xsd ../../src/main/resources/xsd/
- name: Remove input JSON Schemas
working-directory: ./csv_parser/json_schema2xsd
if: steps.filter.outputs.parsing_required == 'true'
run: |
rm src/main/resources/*.json
- 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/RC-DE/RC-DE.generator-config.json --skip-validate-spec
npx @openapitools/openapi-generator-cli generate -c ./config/RC-DE/RC-DE.distributionElement.generator-config.json --skip-validate-spec
IFS=' ' read -ra SCHEMAS_ARRAY <<< "$SCHEMAS"
for SCHEMA in "${SCHEMAS_ARRAY[@]}"; do
if [ "$SCHEMA" != "RS-EDA-MAJ" ]; then
npx @openapitools/openapi-generator-cli generate -c ./config/$SCHEMA/$SCHEMA.generator-config.json --skip-validate-spec
fi
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/rcde || 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
rm -r ./src/main/java/com/hubsante/model/geolocation || true
rm -r ./src/main/java/com/hubsante/model/resources || true
rm -r ./src/main/java/com/hubsante/model/rpis || true
rm -r ./src/main/java/com/hubsante/model/technical || true
rm -r ./generator/classes/src/main/java/com/hubsante/model/report/ErrorCode.java || 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: Generate XML files
run: |
./gradlew generateXml
- 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 TECHNICAL tests
run: ./gradlew test --info -Ptechnical=true
- name: Build and run REAL MESSAGES 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/[email protected]
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/[email protected]
with:
reports: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml
targetdir: coveragereport