Skip to content

Commit c6dcc46

Browse files
authored
Add Maven CI workflow with MongoDB service
1 parent 360417e commit c6dcc46

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

.github/workflows/maven-ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Java CI with Maven
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
# MongoDB service for integration tests
14+
services:
15+
mongo:
16+
image: mongo:7.0
17+
ports:
18+
- 27017:27017
19+
env:
20+
MONGO_INITDB_ROOT_USERNAME: fluxgate
21+
MONGO_INITDB_ROOT_PASSWORD: fluxgate123
22+
MONGO_INITDB_DATABASE: fluxgate
23+
# healthcheck (optional but recommended)
24+
options: >-
25+
--health-cmd "mongosh --username fluxgate --password fluxgate123 --authenticationDatabase admin --eval 'db.adminCommand(\"ping\")'"
26+
--health-interval=10s
27+
--health-timeout=5s
28+
--health-retries=5
29+
30+
# Mongodb
31+
env:
32+
FLUXGATE_MONGO_URI: "mongodb://fluxgate:fluxgate123@localhost:27017/fluxgate?authSource=admin"
33+
FLUXGATE_MONGO_DB: "fluxgate"
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
39+
- name: Set up JDK
40+
uses: actions/setup-java@v4
41+
with:
42+
java-version: '21'
43+
distribution: 'temurin'
44+
cache: maven
45+
46+
- name: Run tests with Maven
47+
run: mvn -B test --file pom.xml
48+
49+
# Optional: dependency graph for Dependabot etc.
50+
- name: Update dependency graph
51+
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6

0 commit comments

Comments
 (0)