-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (60 loc) · 1.92 KB
/
ci-wishlist-service.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: CI for wishlist service
on:
push:
branches:
- NSHM-9-Set-up-environment
jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: services/wishlist
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Start MongoDB service
run: |
docker run -d --name mongo \
-e MONGO_INITDB_ROOT_USERNAME=test_user \
-e MONGO_INITDB_ROOT_PASSWORD=test_password \
-e MONGO_INITDB_DATABASE=test_nshm_wishlist \
-v ${GITHUB_WORKSPACE}/services/wishlist/database/test:/docker-entrypoint-initdb.d \
-p 27017:27017 mongo:latest
- name: Wait for MongoDB to be ready
run: |
for i in {1..10}; do
if docker exec mongo mongosh --eval "printjson(db.runCommand({ ping: 1 }))" | grep -q "ok"; then
echo "MongoDB is ready!"
break
fi
echo "Waiting for MongoDB to be ready..."
sleep 5
done
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run tests and generate coverage report
run: |
mvn clean test jacoco:report
env:
MONGO_HOST: mongo
MONGO_PORT: 27017
MONGO_DB: test_nshm_wishlist
MONGO_USERNAME: test_user
MONGO_PASSWORD: test_password
WISHLIST_PORT: 8083
JWT_SECRET_KEY: test_jwt_secret_key
- name: Upload Test Coverage Report
uses: actions/upload-artifact@v3
with:
name: jacoco-report
path: target/site/jacoco/jacoco.xml