forked from Koboo/en2do
-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (55 loc) · 1.85 KB
/
test.yml
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
name: Java CI with Gradle and MongoDB
permissions: write-all
on:
push:
jobs:
test-and-build:
runs-on: ubuntu-latest
timeout-minutes: 0
permissions:
contents: read
services:
mongodb:
image: mongo:8.0
ports:
- 27017:27017
options: >-
--health-cmd="mongosh --eval 'db.runCommand({ping: 1})'"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
- name: Install MongoDB Shell (mongosh)
run: |
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt-get update
sudo apt-get install -y mongodb-mongosh
- name: Wait for MongoDB to Start
run: |
for i in {1..10}; do
if mongosh --host localhost --port 27017 --eval "db.runCommand({ping: 1})"; then
echo "MongoDB is ready!";
exit 0;
fi;
sleep 3;
done;
echo "MongoDB did not become ready in time!" && exit 1;
- name: Create Test Database
run: |
mongosh --host localhost --port 27017 <<EOF
use testdb
db.test.insertOne({ initialized: true });
EOF
- name: Test with Gradle Wrapper
run: gradle test --no-daemon --stacktrace --info
- name: Build with Gradle Wrapper and ShadowJar
run: gradle shadowJar