add gh actions #13
Workflow file for this run
This file contains 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: generate-model | |
on: | |
pull_request: | |
branches: | |
- '**' | |
env: | |
SCHEMAS: "RC-EDA" | |
jobs: | |
generate: | |
runs-on: ubuntu-latest | |
env: | |
JAVA_POST_PROCESS_FILE: "/usr/bin/clang-format -i" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: setup Graphviz | |
uses: ts-graphviz/setup-graphviz@v1 | |
- name: Generate OpenAPI specs | |
working-directory: ./csv_parser | |
run: | | |
pip install -r ./requirements.txt | |
IFS=' ' read -ra SCHEMAS_ARRAY <<< "$SCHEMAS" | |
for SCHEMA in "${SCHEMAS_ARRAY[@]}"; do | |
python3 ./csv_parser.py -s $SCHEMA | |
mv ./out/$SCHEMA/$SCHEMA.openapi.yaml ../generator/input/$SCHEMA.openapi.yaml | |
done | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
- name: Setup 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.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.wrapper.generator-config.json --skip-validate-spec | |
done | |
- name: copy generated classes | |
run: | | |
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: Check license | |
run: ./gradlew licenseFormat | |
- name: Build and run tests | |
run: ./gradlew 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: ReportGenerator | |
uses: danielpalme/[email protected] | |
with: | |
reports: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml | |
targetdir: coveragereport | |
- name: commit and push changes | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: ⚙️ Auto-génération des classes et des specs |