Skip to content

Commit 8bd7e95

Browse files
authored
Merge pull request #568 from informatici/release_1_15_0
Merge for Release 1.15.0
2 parents ba0be14 + 8b85130 commit 8bd7e95

File tree

207 files changed

+14727
-11010
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

207 files changed

+14727
-11010
lines changed

.github/workflows/maven.yml

Lines changed: 70 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,73 @@
33

44
name: Java CI with Maven
55

6-
on: [push, pull_request]
6+
on:
7+
push:
8+
branches:
9+
- '**'
10+
pull_request:
11+
12+
env:
13+
MAVEN_ARGS: '-B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
714

815
jobs:
916
build:
1017
runs-on: ubuntu-latest
1118

1219
steps:
1320
- uses: actions/checkout@v4
14-
with:
15-
persist-credentials: false
21+
22+
- name: Debug GitHub variables
23+
run: |
24+
echo "GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME}"
25+
echo "GITHUB_HEAD_REPOSITORY: ${GITHUB_HEAD_REPOSITORY}"
26+
echo "GITHUB_HEAD_REF: ${GITHUB_HEAD_REF}"
27+
echo "GITHUB_REPOSITORY: ${GITHUB_REPOSITORY}"
28+
echo "GITHUB_REF: ${GITHUB_REF}"
29+
echo "GITHUB_ACTOR: ${GITHUB_ACTOR}"
30+
31+
- name: Determine PR source branch and fork repository
32+
id: vars
33+
run: |
34+
# Skip tag pushes entirely
35+
if [[ "$GITHUB_EVENT_NAME" == "push" && "$GITHUB_REF" != refs/heads/* ]]; then
36+
echo "Not a branch push ($GITHUB_REF). Exiting."
37+
exit 0
38+
fi
39+
40+
# Set default FORK_REPO and BRANCH_NAME values.
41+
BRANCH_NAME="${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}"
42+
43+
if [[ "$GITHUB_EVENT_NAME" == "push" && "$GITHUB_REPOSITORY" == "informatici/openhospital-api" ]]; then
44+
# For pushes to the main repository, default to the main core repo
45+
FORK_REPO="informatici/openhospital-core"
46+
else
47+
# For pull requests or other pushes, use the contributor fork if applicable
48+
if [[ -n "$GITHUB_HEAD_REPOSITORY" ]]; then
49+
FORK_REPO="$GITHUB_HEAD_REPOSITORY"
50+
else
51+
# Check if the actor's repo exists with the branch
52+
FORK_REPO="${GITHUB_ACTOR}/openhospital-core"
53+
CHECK_BRANCH_URL="https://github.com/$FORK_REPO/tree/$BRANCH_NAME"
54+
echo "Checking branch existence with: curl -s -o /dev/null -w \"%{http_code}\" $CHECK_BRANCH_URL"
55+
56+
if curl -s -o /dev/null -w "%{http_code}" "$CHECK_BRANCH_URL" | grep -q "200"; then
57+
echo "Branch $BRANCH_NAME exists in $FORK_REPO."
58+
else
59+
# Fallback to the main repository if the branch doesn’t exist in the fork
60+
FORK_REPO="informatici/openhospital-core"
61+
fi
62+
fi
63+
fi
64+
65+
# Export FORK_REPO and BRANCH_NAME to GITHUB_ENV for the next step
66+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
67+
echo "FORK_REPO=$FORK_REPO" >> $GITHUB_ENV
68+
69+
- name: Log variables
70+
run: |
71+
echo "FORK_REPO: ${{ env.FORK_REPO }}"
72+
echo "BRANCH_NAME: ${{ env.BRANCH_NAME }}"
1673
1774
- name: Set up JDK 17
1875
uses: actions/setup-java@v4
@@ -22,52 +79,17 @@ jobs:
2279
java-package: jdk
2380

2481
- name: Checkout core
25-
run: git clone --depth=50 --branch=develop https://github.com/informatici/openhospital-core.git openhospital-core
26-
27-
- name: Install core
28-
run: cd openhospital-core && mvn install -DskipTests=true && cd ..
29-
30-
- name: Generate JWT Token
31-
id: jwt
32-
run: echo "token=7DlyD1SHR5pCa4HGgTLWSYm8YQ7oRL1wpPbxyjWyHU44vUrqrooRu3lHVFSXWChesc" >> $GITHUB_OUTPUT
33-
34-
- name: Store branch name
35-
id: extract_branch
3682
run: |
37-
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
38-
echo "branch=$(echo ${GITHUB_REF##*/})" >> $GITHUB_OUTPUT
39-
elif [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
40-
echo "branch=$(echo ${GITHUB_HEAD_REF})" >> $GITHUB_OUTPUT
41-
else
42-
echo "branch=INVALID_EVENT_BRANCH_UNKNOWN" >> $GITHUB_OUTPUT
43-
fi
44-
45-
- name: Build with Maven
83+
git clone --depth=1 --no-single-branch https://github.com/${{ env.FORK_REPO }}.git openhospital-core
84+
pushd openhospital-core
85+
git checkout -B ${{ env.BRANCH_NAME }} origin/${{ env.BRANCH_NAME }} || git checkout develop
86+
popd
87+
88+
- name: Install core
4689
run: |
47-
cp rsc/application.properties.dist rsc/application.properties
48-
cp rsc/database.properties.dist rsc/database.properties
49-
cp rsc/log4j.properties.dist rsc/log4j.properties
50-
cp rsc/settings.properties.dist rsc/settings.properties
51-
sed -e "s/JWT_TOKEN_SECRET/${{ steps.jwt.outputs.token }}/g" rsc/application.properties.dist > rsc/application.properties
90+
pushd openhospital-core
5291
mvn install -DskipTests=true
53-
echo ${{ steps.extract_branch.outputs.branch }}
54-
55-
- name: Run API
56-
run: |
57-
cd target
58-
java -cp "openhospital-api-0.1.0.jar:rsc/:static/" org.springframework.boot.loader.JarLauncher &
59-
sleep 60
60-
61-
- name: Generate OpenAPI yaml
62-
run: mvn springdoc-openapi:generate -Dspringdoc.outputFileName=oh_rev.yaml
92+
popd
6393
64-
- name: Running OpenAPI Spec breaking action
65-
# run: |
66-
# tenant_id=`curl -d '{"tenant": "oh", "email": "community@open-hospital.org"}' https://register.oasdiff.com/tenants | jq -r .id`
67-
# curl -o output -X POST -F base=@openapi/oh.yaml -F revision=@openapi/oh_rev.yaml https://api.oasdiff.com/tenants/${tenant_id}/breaking-changes
68-
# cat output
69-
uses: oasdiff/oasdiff-action/breaking@main
70-
with:
71-
base: openapi/oh.yaml
72-
revision: openapi/oh_rev.yaml
73-
fail-on-diff: true
94+
- name: Build with Maven
95+
run: mvn install

.github/workflows/openapi.yml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# This workflow will build and run the application for oasdiff/oasdiff-action/breaking@main
2+
# For more information see: https://github.com/oasdiff/oasdiff-action
3+
4+
name: OpenAPI breaking changes check
5+
6+
on: [push, pull_request]
7+
8+
env:
9+
MAVEN_ARGS: '-B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
10+
11+
jobs:
12+
opeanpi:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
persist-credentials: false
19+
20+
- name: Debug GitHub variables
21+
run: |
22+
echo "GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME}"
23+
echo "GITHUB_HEAD_REPOSITORY: ${GITHUB_HEAD_REPOSITORY}"
24+
echo "GITHUB_HEAD_REF: ${GITHUB_HEAD_REF}"
25+
echo "GITHUB_REPOSITORY: ${GITHUB_REPOSITORY}"
26+
echo "GITHUB_REF: ${GITHUB_REF}"
27+
echo "GITHUB_ACTOR: ${GITHUB_ACTOR}"
28+
29+
- name: Determine PR source branch and fork repository
30+
id: vars
31+
run: |
32+
# Set default FORK_REPO and BRANCH_NAME values.
33+
BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}"
34+
35+
if [[ "$GITHUB_EVENT_NAME" == "push" && "$GITHUB_REPOSITORY" == "informatici/openhospital-api" ]]; then
36+
# For pushes to the main repository, default to the main core repo
37+
FORK_REPO="informatici/openhospital-core"
38+
else
39+
# For pull requests or other pushes, use the contributor fork if applicable
40+
if [[ -n "$GITHUB_HEAD_REPOSITORY" ]]; then
41+
FORK_REPO="$GITHUB_HEAD_REPOSITORY"
42+
else
43+
# Check if the actor's repo exists with the branch
44+
FORK_REPO="${GITHUB_ACTOR}/openhospital-core"
45+
CHECK_BRANCH_URL="https://github.com/$FORK_REPO/tree/$BRANCH_NAME"
46+
echo "Checking branch existence with: curl -s -o /dev/null -w \"%{http_code}\" $CHECK_BRANCH_URL"
47+
48+
if curl -s -o /dev/null -w "%{http_code}" "$CHECK_BRANCH_URL" | grep -q "200"; then
49+
echo "Branch $BRANCH_NAME exists in $FORK_REPO."
50+
else
51+
# Fallback to the main repository if the branch doesn’t exist in the fork
52+
FORK_REPO="informatici/openhospital-core"
53+
fi
54+
fi
55+
fi
56+
57+
# Export FORK_REPO and BRANCH_NAME to GITHUB_ENV for the next step
58+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
59+
echo "FORK_REPO=$FORK_REPO" >> $GITHUB_ENV
60+
61+
- name: Log variables
62+
run: |
63+
echo "FORK_REPO: ${{ env.FORK_REPO }}"
64+
echo "BRANCH_NAME: ${{ env.BRANCH_NAME }}"
65+
66+
- name: Set up JDK 17
67+
uses: actions/setup-java@v4
68+
with:
69+
distribution: 'zulu'
70+
java-version: 17
71+
java-package: jdk
72+
73+
- name: Checkout core
74+
run: |
75+
git clone --depth=1 --no-single-branch https://github.com/${{ env.FORK_REPO }}.git openhospital-core
76+
pushd openhospital-core
77+
git checkout -B ${{ env.BRANCH_NAME }} origin/${{ env.BRANCH_NAME }} || git checkout develop
78+
popd
79+
80+
- name: Install core
81+
run: |
82+
pushd openhospital-core
83+
mvn install -DskipTests=true
84+
popd
85+
86+
- name: Generate JWT Token
87+
id: jwt
88+
run: echo "token=7DlyD1SHR5pCa4HGgTLWSYm8YQ7oRL1wpPbxyjWyHU44vUrqrooRu3lHVFSXWChesc" >> $GITHUB_OUTPUT
89+
90+
- name: Build with Maven
91+
run: |
92+
cp rsc/database.properties.dist rsc/database.properties
93+
cp rsc/log4j2-spring.properties.dist rsc/log4j2-spring.properties
94+
cp rsc/settings.properties.dist rsc/settings.properties
95+
sed -e "s/JWT_TOKEN_SECRET/${{ steps.jwt.outputs.token }}/g" -e "s/API_HOST/localhost/g" -e "s/API_PORT/8080/g" rsc/application.properties.dist > rsc/application.properties
96+
mvn install -DskipTests=true
97+
98+
- name: Run API
99+
run: |
100+
pushd target
101+
java -cp "openhospital-api-0.1.0.jar:rsc/:static/" org.springframework.boot.loader.launch.JarLauncher &
102+
sleep 60
103+
popd
104+
105+
- name: Generate OpenAPI yaml
106+
run: |
107+
mvn springdoc-openapi:generate -Dspringdoc.outputFileName=oh_rev.yaml
108+
if [ ! -f "openapi/oh_rev.yaml" ]; then
109+
echo "Error: oh_rev.yaml was not generated. The command may have failed."
110+
exit 1
111+
fi
112+
113+
# Step 1: Check if oh_rev.yaml differs from the committed version
114+
- name: Install yq
115+
run: |
116+
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
117+
sudo chmod +x /usr/bin/yq
118+
119+
- name: Install jq
120+
run: sudo apt-get install -y jq
121+
122+
- name: Convert to JSON and sort
123+
run: |
124+
yq eval -o=json openapi/oh_rev.yaml > oh_rev.json
125+
yq eval -o=json openapi/oh.yaml > oh.json
126+
jq --sort-keys . oh_rev.json > sorted_oh_rev.json
127+
jq --sort-keys . oh.json > sorted_oh.json
128+
129+
- name: Compare JSON files
130+
if: github.event_name == 'pull_request'
131+
run: |
132+
if diff sorted_oh_rev.json sorted_oh.json; then
133+
echo "No changes in OpenAPI spec. Everything is up to date."
134+
else
135+
echo "The OpenAPI spec has changed. Please update the committed version."
136+
exit 1
137+
fi
138+
139+
# Step 2: Check for breaking changes between destination branch oh.yaml and the generated oh_rev.yaml
140+
- name: Checkout Base Branch
141+
run: |
142+
git fetch origin ${{ github.event.pull_request.base.ref }}:base_branch
143+
git checkout base_branch
144+
145+
- name: Run OpenAPI Spec breaking action
146+
id: oasdiff
147+
uses: oasdiff/oasdiff-action/breaking@main
148+
with:
149+
base: openapi/oh.yaml # destination branch oh.yaml
150+
revision: openapi/oh_rev.yaml # generated oh_rev.yaml
151+
format: detailed
152+
# fail-on-diff: false
153+
154+
- name: Show breaking changes output
155+
run: |
156+
echo "Breaking changes output: ${{ steps.oasdiff.outputs.breaking }}"
157+
if [[ "${{ steps.oasdiff.outputs.breaking }}" != "No breaking changes" ]]; then
158+
echo "Warning: Breaking changes detected."
159+
exit 1
160+
fi

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ bin
1111

1212
#Project related
1313
.env
14+
/deps/
15+
OH_API_PID
1416

1517
### STS ###
1618
.apt_generated
@@ -27,6 +29,7 @@ bin
2729
*.iws
2830
*.iml
2931
*.ipr
32+
*.pid
3033

3134
### NetBeans ###
3235
/nbproject/private/
@@ -40,3 +43,6 @@ bin
4043
.vscode
4144
/deps/
4245
OH_API_PID
46+
47+
### Git ###
48+
/**/.gitkeep

0 commit comments

Comments
 (0)