Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add gh actions #3

Merged
merged 74 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
89f66f6
license format
bou3108 Dec 6, 2023
9446b59
add github actions
bou3108 Dec 6, 2023
18f9867
add REAME.md
bou3108 Dec 6, 2023
6d65abc
add license header
bou3108 Dec 6, 2023
2ebf8bf
add license format on generated classes
bou3108 Dec 6, 2023
989c2a4
add license header
bou3108 Dec 6, 2023
5e5fae5
rename artifact
bou3108 Dec 6, 2023
bd8c201
fix action
bou3108 Dec 6, 2023
5e4cfd2
fix action
bou3108 Dec 6, 2023
8f88e00
fix action
bou3108 Dec 6, 2023
3acb148
fix action
bou3108 Dec 6, 2023
8db97d7
Merge remote-tracking branch 'origin/feat/add-gh-action' into feat/ad…
bou3108 Dec 6, 2023
9109328
fix action
bou3108 Dec 6, 2023
654be45
Update generate-model.yaml
romainfd Dec 7, 2023
555c802
sudo !!
bou3108 Dec 7, 2023
25d4aa0
⚙️ Auto-génération des classes et des specs
bou3108 Dec 7, 2023
f63770b
Create .gitignore
bou3108 Dec 7, 2023
b54b518
⚙️ Auto-génération des classes et des specs
bou3108 Dec 7, 2023
13ae133
Merge branch 'main' into feat/add-gh-action
romainfd Dec 9, 2023
ade5585
⚙️ Auto-génération des classes et des specs
romainfd Dec 9, 2023
f62c989
fix createCase.location.freetext
bou3108 Dec 12, 2023
121c5e3
Rename models.xlsx to model.xlsx
bou3108 Dec 12, 2023
562d877
⚙️ Auto-génération des classes et des specs
bou3108 Dec 12, 2023
521361a
move tests in generate model action
bou3108 Dec 12, 2023
9de2996
⚙️ Auto-génération des classes et des specs
bou3108 Dec 12, 2023
11541d8
add report
bou3108 Dec 12, 2023
c2fc34e
add jacoco
bou3108 Dec 12, 2023
2f7064d
Merge remote-tracking branch 'origin/feat/add-gh-action' into feat/ad…
bou3108 Dec 12, 2023
bb493d1
⚙️ Auto-génération des classes et des specs
bou3108 Dec 12, 2023
b8ee40f
Update generate-model.yaml
bou3108 Dec 12, 2023
eceb700
⚙️ Auto-génération des classes et des specs
bou3108 Dec 12, 2023
a8e0217
ignore build
bou3108 Dec 12, 2023
7740fb6
Merge remote-tracking branch 'origin/feat/add-gh-action' into feat/ad…
bou3108 Dec 12, 2023
d7172c0
rm test action (already in other action)
bou3108 Dec 12, 2023
5223cbf
⚙️ Auto-génération des classes et des specs
bou3108 Dec 12, 2023
8745e55
downgrade checkout version
bou3108 Dec 12, 2023
980c6d0
Merge remote-tracking branch 'origin/feat/add-gh-action' into feat/ad…
bou3108 Dec 12, 2023
eeff202
⚙️ Auto-génération des classes et des specs
bou3108 Dec 12, 2023
8754fd7
Delete .gradle directory
bou3108 Dec 12, 2023
0b85b42
Delete build directory
bou3108 Dec 12, 2023
d7da9e9
⚙️ Auto-génération des classes et des specs
bou3108 Dec 12, 2023
578c9fd
Delete generator/classes directory
bou3108 Dec 12, 2023
1633e0d
⚙️ Auto-génération des classes et des specs
bou3108 Dec 12, 2023
0e76478
Update .gitignore
bou3108 Dec 12, 2023
b630116
Delete coveragereport directory
bou3108 Dec 12, 2023
b7c5d2c
Delete reportgeneratortool directory
bou3108 Dec 12, 2023
cd4990b
Update generate-model.yaml
bou3108 Dec 12, 2023
bb81964
Update generate-model.yaml
bou3108 Dec 12, 2023
fdf5f08
⚙️ Auto-génération des classes et des specs
bou3108 Dec 12, 2023
63a20b4
rm generated annotation
bou3108 Dec 12, 2023
8e9af6d
Merge remote-tracking branch 'origin/feat/add-gh-action' into feat/ad…
bou3108 Dec 12, 2023
cc53d62
⚙️ Auto-génération des classes et des specs
bou3108 Dec 12, 2023
ee96a15
change recipient wrapper to singular
bou3108 Dec 13, 2023
0de50b9
⚙️ Auto-génération des classes et des specs
bou3108 Dec 13, 2023
19d73dd
change recipient wrapper to singular
bou3108 Dec 13, 2023
c01f417
⚙️ Auto-génération des classes et des specs
bou3108 Dec 13, 2023
528d541
add UTs in generator
bou3108 Dec 13, 2023
72d67c7
⚙️ Auto-génération des classes et des specs
bou3108 Dec 13, 2023
2cbbaa3
fix action
bou3108 Dec 13, 2023
f0752a6
Merge remote-tracking branch 'origin/feat/add-gh-action' into feat/ad…
bou3108 Dec 13, 2023
4e14f26
⚙️ Auto-génération des classes et des specs
bou3108 Dec 13, 2023
5f1f932
fix action
bou3108 Dec 13, 2023
c776232
⚙️ Auto-génération des classes et des specs
bou3108 Dec 13, 2023
c7c85df
fix parser
bou3108 Dec 13, 2023
27ff5f6
fix parser
bou3108 Dec 13, 2023
2321143
fix parser
bou3108 Dec 13, 2023
678a8b4
⚙️ Auto-génération des classes et des specs
bou3108 Dec 13, 2023
a6faac8
fix parser
bou3108 Dec 13, 2023
99f10bf
⚙️ Auto-génération des classes et des specs
bou3108 Dec 13, 2023
989cc77
fix parser
bou3108 Dec 13, 2023
0004ee5
⚙️ Auto-génération des classes et des specs
bou3108 Dec 13, 2023
e026dee
fix broken tests
bou3108 Dec 13, 2023
4119322
⚙️ Auto-génération des classes et des specs
bou3108 Dec 13, 2023
0cbfa73
Merging and rerunning generator
romainfd Dec 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/generate-model.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: generate-model

on:
pull_request:
branches:
- '**'

env:
SCHEMAS: "RC-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: 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: 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

- 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 }}
romainfd marked this conversation as resolved.
Show resolved Hide resolved
min-coverage-overall: 40
min-coverage-changed-files: 60
romainfd marked this conversation as resolved.
Show resolved Hide resolved

- 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/ReportGenerator-GitHub-Action@5.1.23
with:
reports: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml
targetdir: coveragereport
romainfd marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
.idea/
.gradle/**
generator/classes/**
.idea/
build/**
reportgeneratortool/**
coveragereport/**
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<h1 align="center">Hub Santé - librairie Modèles</h1>
<p align="center">
<img alt="Version" src="https://img.shields.io/badge/version-0.3-blue.svg?cacheSeconds=2592000" />
<a href="#" target="_blank">
<img alt="License: Apache-2.0" src="https://img.shields.io/badge/License-Apache_2.0-yellow.svg" />
</a>
</p>

> Librairie du modèle de données utilisé par le projet SAMU-Hub-Santé (Plateforme d'échanges de messages asynchrones entre les acteurs de l'urgence)

🏠 [Page d'accueil](https://github.com/ansforge/SAMU-Hub-Modeles)

## Usage

Cette librairie est utilisée par le projet [SAMU-Hub-Santé](https://github/.com/ansforge/SAMU-Hub-Sante).

Elle contient les classes Java permettant de manipuler les messages échangés entre les acteurs de l'urgence, ainsi que quelques utilitaires (pour les opérations de sérialisation/désérialisation ou de validation notamment).

Les json-schemas sont disponibles dans le répertoire [src/main/resources/json-schema](src/main/resources/json-schema).
Des exemples de messages sont disponibles dans le répertoire [src/main/resources/sample/valid](src/main/resources/sample/valid).

Les spécifications du modèle de données sont disponibles sur le [site du projet SAMU-Hub-Santé](https://hub.esante.gouv.fr/).

## Auteur

👤 **ANS > Equipe Hub Santé**

* Site web de l'équipe : https://hub.esante.gouv.fr/
* Site web du programme : https://esante.gouv.fr/si-samu

## 🤝 Contribuer

Les contributions, *issues* & *pull requests* sont les bienvenues !
<br />N'hésitez pas à utiliser notre [page d'*issues*](https://github.com/ansforge/SAMU-Hub-Modeles/issues).

## Montrez votre support

Mettez une ⭐️ si ce projet vous a aidé !

***
_Ce README est inspiré de [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_
13 changes: 11 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ plugins {
id 'java'
id 'maven-publish'
id 'com.github.hierynomus.license' version '0.16.1'
id 'jacoco'
}

group = 'com.hubsante'
version = '0.2.6-SNAPSHOT'
version = '0.3.0-SNAPSHOT'

java {
toolchain {
Expand Down Expand Up @@ -33,8 +34,16 @@ dependencies {
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
}

jacocoTestReport {
reports {
html.required = true
xml.required = true
}
}

tasks.named('test') {
useJUnitPlatform()
finalizedBy jacocoTestReport
}

license {
Expand All @@ -60,7 +69,7 @@ publishing {
repositories {
maven {
name = 'GitHubPackages'
url = 'https://maven.pkg.github.com/ansforge/SAMU-Hub-Sante'
url = 'https://maven.pkg.github.com/ansforge/SAMU-Hub-Modeles'
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
Expand Down
16 changes: 10 additions & 6 deletions csv_parser/csv_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@ def get_params_from_sheet(sheet):
def get_nomenclature(elem):
# filename to target (.csv format)
nomenclature_name = elem['Détails de format'][14:]
path_file = os.path.join("..", "nomenclature_parser", "out", "latest", "csv", nomenclature_name + ".csv")
# ToDo: ajouter un bloc dans le else pour détecter des https:// et aller chercher les nomenclatures publiées en ligne (MOS/NOs par exemple)
if os.path.exists(path_file):
df_nomenclature = pd.read_csv(path_file, sep=";", keep_default_na=False, na_values=['_'], encoding="utf-8")
path_file = ''
for filename in os.listdir(os.path.join("..", "nomenclature_parser", "out", "latest", "csv")):
if filename.startswith(nomenclature_name):
path_file = os.path.join("..", "nomenclature_parser", "out", "latest", "csv", filename)

if path_file != '':
df_nomenclature = pd.read_csv(path_file, sep=",", keep_default_na=False, na_values=['_'], encoding="utf-8")
L_ret = df_nomenclature["code"].values.tolist()
else:
print(f'{path_file} does not exist. Cannot load associated nomenclature.')
else :
# ToDo: ajouter un bloc dans le else pour détecter des https:// et aller chercher les nomenclatures publiées en ligne (MOS/NOs par exemple)
print(f'{nomenclature_name} does not exist. Cannot load associated nomenclature.')
return []
return L_ret

Expand Down
Empty file modified csv_parser/model.xlsx
100755 → 100644
Empty file.
Loading
Loading