Skip to content

Commit 844bfc9

Browse files
authored
Merge pull request #205 from imi-ms/v3.3.0
v3.3.0 Release
2 parents ddd57c4 + 348dcc3 commit 844bfc9

File tree

1,061 files changed

+386253
-41297
lines changed

Some content is hidden

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

1,061 files changed

+386253
-41297
lines changed

.env

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ MYSQL_MOPAT_AUDIT_URL=jdbc:mysql://db-container:3306/moPat_audit?autoReconnect=t
1313

1414
# Local volume paths
1515
HL7_VOLUME=./data/export/HL7
16-
FHIR_VOLUME=./data/export/HL7
17-
ODM_VOLUME=./data/export/HL7
16+
FHIR_VOLUME=./data/export/FHIR
17+
ODM_VOLUME=./data/export/ODM
18+
REDCAP_VOLUME=./data/export/REDCap
1819
UPLOAD_VOLUME=./data/upload
1920
IMAGES_VOLUME=./data/images
2021
CONFIG_DIR=/etc/mopat

.github/docker_testenv/.env

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# .env file
2+
# DB settings
3+
# !!! ADJUST THESE SETTINGS !!!
4+
MYSQL_ROOT_PASSWORD=root
5+
MYSQL_USER=mopat
6+
MYSQL_PASSWORD=mopat
7+
PEPPER=AdP5ktlaIVaon53yJg8zEZSnFr33Dinil69ZtZMTWXubKMUEpfyNvOgWLdwNLhedY3WT5TVcqgg
8+
9+
# DB Connection settings - The hostname is corresponding to the container name of the db
10+
MYSQL_MOPAT_URL=jdbc:mysql://db-container:3306/moPat?autoReconnect=true&useUnicode=true&useEncoding=true&characterEncoding=UTF-8
11+
MYSQL_MOPAT_USER_URL=jdbc:mysql://db-container:3306/moPat_user?autoReconnect=true&useUnicode=true&useEncoding=true&characterEncoding=UTF-8
12+
MYSQL_MOPAT_AUDIT_URL=jdbc:mysql://db-container:3306/moPat_audit?autoReconnect=true&useUnicode=true&useEncoding=true&characterEncoding=UTF-8
13+
14+
# Local volume paths
15+
HL7_VOLUME=./data/export/HL7
16+
FHIR_VOLUME=./data/export/FHIR
17+
ODM_VOLUME=./data/export/ODM
18+
UPLOAD_VOLUME=./data/upload
19+
IMAGES_VOLUME=./data/images
20+
CONFIG_DIR=/etc/mopat
21+
22+
# Path for the database data
23+
DB_DATA_PATH=./data/db
24+
25+
# Port configuration
26+
WEBAPP_PORT=8080

.github/docker_testenv/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM maven:3.9.11-eclipse-temurin-17-noble as builder
2+
WORKDIR /app
3+
COPY pom.xml .
4+
COPY src ./src
5+
COPY .git ./.git
6+
RUN mvn -B -f pom.xml dependency:go-offline
7+
RUN mvn -B install -DskipTests
8+
FROM tomcat:10-jdk17-temurin-noble
9+
RUN rm -rf /usr/local/tomcat/webapps/*
10+
COPY src/main/resources/docker-server.xml /usr/local/tomcat/conf/server.xml
11+
COPY --from=builder /app/target/*.war /usr/local/tomcat/webapps/ROOT.war
12+
EXPOSE 8080
13+
CMD ["catalina.sh", "run"]
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
services:
2+
db-container:
3+
image: mariadb
4+
restart: always
5+
environment:
6+
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
7+
MYSQL_USER: ${MYSQL_USER}
8+
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
9+
MYSQL_DATABASE: initDb
10+
ports:
11+
- "127.0.0.1:3306:3306"
12+
volumes:
13+
- ${DB_DATA_PATH}:/var/lib/mysql
14+
- ./db:/docker-entrypoint-initdb.d
15+
16+
webapp-container:
17+
build:
18+
context: ../..
19+
dockerfile: .github/docker_testenv/Dockerfile
20+
depends_on:
21+
- db-container
22+
ports:
23+
- "127.0.0.1:${WEBAPP_PORT}:8080"
24+
volumes:
25+
- ${HL7_VOLUME}:/var/lib/tomcat10/export/HL7
26+
- ${FHIR_VOLUME}:/var/lib/tomcat10/export/FHIR
27+
- ${ODM_VOLUME}:/var/lib/tomcat10/export/ODM
28+
- ${UPLOAD_VOLUME}:/var/lib/tomcat10/upload
29+
- ${IMAGES_VOLUME}:/var/lib/tomcat10/images
30+
- ${CONFIG_DIR}:/etc/mopat
31+
- ./src/main/resources/docker-server.xml:/usr/local/tomcat/conf/server.xml:ro
32+
environment:
33+
- MYSQL_USER=${MYSQL_USER}
34+
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
35+
- MYSQL_MOPAT_URL=${MYSQL_MOPAT_URL}
36+
- MYSQL_MOPAT_USER_URL=${MYSQL_MOPAT_USER_URL}
37+
- MYSQL_MOPAT_AUDIT_URL=${MYSQL_MOPAT_AUDIT_URL}
38+
- PEPPER=${PEPPER}

.github/workflows/pr-checks.yml

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
name: test
2+
3+
on: pull_request
4+
5+
jobs:
6+
unit-tests:
7+
permissions:
8+
checks: write
9+
pull-requests: write
10+
runs-on: ubuntu-latest
11+
outputs:
12+
unittest-results: ${{ steps.decode-results.outputs.content }}
13+
services:
14+
mariadb:
15+
image: mariadb:latest
16+
env:
17+
MARIADB_ROOT_PASSWORD: root
18+
ports:
19+
- 3306:3306
20+
options: >-
21+
--health-cmd="healthcheck.sh
22+
--connect
23+
--innodb_initialized"
24+
--health-interval=10s
25+
--health-timeout=5s
26+
--health-retries=3
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Set up JDK
31+
uses: actions/setup-java@v4
32+
with:
33+
java-version: '17'
34+
distribution: 'temurin'
35+
cache: 'maven'
36+
37+
- name: Install MySQL client and Load Database Schema
38+
run: |
39+
sudo apt-get update
40+
sudo apt-get install -y default-mysql-client
41+
mysql -h 127.0.0.1 -u root --password=root -e "CREATE USER IF NOT EXISTS 'mopat'@'%' IDENTIFIED BY 'mopat';"
42+
mysql -h 127.0.0.1 -u root --password=root -e "GRANT ALL PRIVILEGES ON *.* TO 'mopat'@'%'; FLUSH PRIVILEGES;"
43+
mysql -h 127.0.0.1 -u root --password=root < db/installationInitTest.sql
44+
45+
- name: Test with Maven
46+
run: mvn -B test --file pom.xml
47+
48+
- name: Publish Test Report
49+
id: testReport
50+
uses: mikepenz/action-junit-report@v5
51+
if: success() || failure() # always run even if the previous step fails
52+
with:
53+
report_paths: '**/target/surefire-reports/*.xml'
54+
55+
- name: Decode results
56+
id: decode-results
57+
if: always() && github.event_name == 'pull_request'
58+
run: |
59+
echo "<details><summary>🧪 Unit Test Results</summary>" >> unit-results.md
60+
echo "${{ steps.testReport.outputs.summary }}" >> unit-results.md
61+
echo "</details>" >> unit-results.md
62+
# Save content as output
63+
echo "content<<EOF" >> $GITHUB_OUTPUT
64+
cat unit-results.md >> $GITHUB_OUTPUT
65+
echo "EOF" >> $GITHUB_OUTPUT
66+
67+
68+
selenium-tests:
69+
permissions:
70+
checks: write
71+
pull-requests: write
72+
73+
runs-on: ubuntu-latest
74+
outputs:
75+
selenium-results: ${{ steps.decode-results.outputs.content }}
76+
77+
steps:
78+
# Checkout the repository
79+
- name: Check out the repository
80+
uses: actions/checkout@v4
81+
82+
# Set up Docker
83+
- name: Set up Docker Buildx
84+
uses: docker/setup-buildx-action@v3
85+
86+
# Pull the Chrome image
87+
- name: Pull Selenoid Chrome Image
88+
run: docker pull selenoid/chrome:latest
89+
90+
# Setup Docker-Compose
91+
- name: Docker Compose Action
92+
uses: hoverkraft-tech/compose-action@v2.0.2
93+
with:
94+
compose-file: "selenium/docker-compose.yml"
95+
96+
# Wait for the server to be ready before running tests
97+
- name: Wait for the application to be ready
98+
run: |
99+
until curl --output /dev/null --silent --head --fail http://localhost:8080; do
100+
echo 'Waiting for the application to be ready...'
101+
sleep 5
102+
done
103+
until curl --output /dev/null --silent --head --fail http://localhost:4444/status; do
104+
echo 'Waiting for Selenoid to be ready...'
105+
sleep 5
106+
done
107+
108+
# Set up Python and run Selenium tests
109+
- name: Set up Python
110+
uses: actions/setup-python@v4
111+
with:
112+
python-version: '3.13' # Specify the version of Python you are using
113+
114+
- name: Install dependencies
115+
run: pip install -r selenium/requirements.txt # Ensure your Selenium and other dependencies are listed here
116+
117+
- name: Run Selenium tests
118+
run: |
119+
python3 selenium/selenium_tests.py > test-results.log
120+
121+
- name: Save results to env
122+
if: always() && github.event_name == 'pull_request'
123+
id: test_report
124+
run: echo "SELENIUM_TEST_SUMMARY=$(base64 -w 0 test-results.log)" >> $GITHUB_ENV
125+
126+
# Install GitHub CLI
127+
- name: Install GitHub CLI
128+
run: sudo apt-get update && sudo apt-get install -y gh
129+
130+
- name: Decode results
131+
id: decode-results
132+
if: always() && github.event_name == 'pull_request'
133+
run: |
134+
decoded_results=$(echo "${{ env.SELENIUM_TEST_SUMMARY }}" | base64 --decode)
135+
echo "<details><summary>🌐 Selenium Test Results</summary>" > selenium_block.md
136+
echo "$decoded_results" >> selenium_block.md
137+
echo "</details>" >> selenium_block.md
138+
# Save content as output
139+
echo "content<<EOF" >> $GITHUB_OUTPUT
140+
cat selenium_block.md >> $GITHUB_OUTPUT
141+
echo "EOF" >> $GITHUB_OUTPUT
142+
143+
trivy-scan:
144+
runs-on: ubuntu-latest
145+
outputs:
146+
trivy-results: ${{ steps.trivy-table.outputs.content }}
147+
permissions:
148+
contents: read
149+
pull-requests: write
150+
151+
steps:
152+
- name: Checkout code
153+
uses: actions/checkout@v5
154+
155+
- name: Set up Docker Buildx
156+
uses: docker/setup-buildx-action@v3
157+
158+
- name: Build Docker images with docker compose
159+
working-directory: ./.github/docker_testenv
160+
run: |
161+
docker compose build
162+
163+
- name: Run Trivy vulnerability scanner on image
164+
id: trivy
165+
uses: aquasecurity/trivy-action@0.34.2
166+
env:
167+
TRIVY_DISABLE_VEX_NOTICE: "true"
168+
with:
169+
image-ref: docker_testenv-webapp-container:latest
170+
format: json
171+
exit-code: 0
172+
output: trivy-report.json
173+
174+
- name: Convert Trivy JSON to Markdown table (split OS vs app)
175+
id: trivy-table
176+
run: |
177+
# Check if any vulnerabilities exist
178+
if ! jq -e '.Results[].Vulnerabilities | select(length > 0)' trivy-report.json > /dev/null; then
179+
echo "✅ No vulnerabilities found!" >> trivy-comment.md
180+
exit 0
181+
fi
182+
183+
#####################################
184+
# 🐳 1️⃣ Base Image Vulnerabilities (os-pkgs)
185+
#####################################
186+
187+
os_total=$(jq '[.Results[] | select(.Class=="os-pkgs") | .Vulnerabilities[]?] | length' trivy-report.json)
188+
os_with_fixes=$(jq '[.Results[] | select(.Class=="os-pkgs") | .Vulnerabilities[]? | select(.FixedVersion != null and .FixedVersion != "")] | length' trivy-report.json)
189+
190+
echo "<details><summary>🐳 Base Image Vulnerabilities: $os_total vulnerabilities found, $os_with_fixes with fixes</summary>" >> trivy-comment.md
191+
echo "" >> trivy-comment.md
192+
193+
jq -r '
194+
[ .Results[]
195+
| select(.Class == "os-pkgs")
196+
| .Vulnerabilities[]?
197+
]
198+
| select(length > 0)
199+
| group_by(.PkgName)
200+
| sort_by(.[0].PkgName)
201+
| .[]
202+
| "#### 📦 Package: \([.[0].PkgName])\n"
203+
+ "| Severity | Vulnerability ID | Installed Version | Fixed Version |\n"
204+
+ "|-----------|------------------|------------------|----------------|\n"
205+
+ (map("| \(.Severity) | \(.VulnerabilityID) | \(.InstalledVersion) | \(.FixedVersion // "-") |") | join("\n"))
206+
+ "\n"
207+
' trivy-report.json >> trivy-comment.md
208+
209+
echo "</details>" >> trivy-comment.md
210+
echo "" >> trivy-comment.md
211+
212+
#####################################
213+
# ☕️ 2️⃣ Tomcat / Java / Library Vulnerabilities
214+
#####################################
215+
216+
app_total=$(jq '[.Results[] | select(.Class!="os-pkgs") | .Vulnerabilities[]?] | length' trivy-report.json)
217+
app_with_fixes=$(jq '[.Results[] | select(.Class!="os-pkgs") | .Vulnerabilities[]? | select(.FixedVersion != null and .FixedVersion != "")] | length' trivy-report.json)
218+
219+
echo "<details><summary>☕️ Application / Library Vulnerabilities: $app_total vulnerabilities found, $app_with_fixes with fixes</summary>" >> trivy-comment.md
220+
echo "" >> trivy-comment.md
221+
222+
jq -r '
223+
[ .Results[]
224+
| select(.Class != "os-pkgs")
225+
| .Vulnerabilities[]?
226+
]
227+
| select(length > 0)
228+
| group_by(.PkgName)
229+
| sort_by(.[0].PkgName)
230+
| .[]
231+
| "#### 📦 Package: \([.[0].PkgName])\n"
232+
+ "| Severity | Vulnerability ID | Installed Version | Fixed Version |\n"
233+
+ "|-----------|------------------|------------------|----------------|\n"
234+
+ (map("| \(.Severity) | \(.VulnerabilityID) | \(.InstalledVersion) | \(.FixedVersion // "-") |") | join("\n"))
235+
+ "\n"
236+
' trivy-report.json >> trivy-comment.md
237+
238+
echo "</details>" >> trivy-comment.md
239+
# Save content as output
240+
echo "content<<EOF" >> $GITHUB_OUTPUT
241+
cat trivy-comment.md >> $GITHUB_OUTPUT
242+
echo "EOF" >> $GITHUB_OUTPUT
243+
comment:
244+
runs-on: ubuntu-latest
245+
needs: [unit-tests, selenium-tests, trivy-scan]
246+
if: always()
247+
permissions:
248+
contents: read
249+
pull-requests: write
250+
steps:
251+
- name: Post PR comment
252+
uses: peter-evans/create-or-update-comment@v4
253+
with:
254+
issue-number: ${{ github.event.pull_request.number }}
255+
body: |
256+
### Test Results
257+
258+
${{ needs.unit-tests.outputs.unittest-results }}
259+
260+
${{ needs.selenium-tests.outputs.selenium-results }}
261+
262+
### Vulnerability Scan Results
263+
264+
${{ needs.trivy-scan.outputs.trivy-results }}
265+
266+
env:
267+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)