-
-
Notifications
You must be signed in to change notification settings - Fork 16
55 lines (46 loc) · 1.37 KB
/
mongo-test.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
name: MongoDB Replica Set Unit Tests
on:
push:
branches:
- feat/test_framework
jobs:
test:
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:latest
ports:
- 27017:27017
options: >-
--network-alias mongodb
mongod --replSet rs0
env:
MONGO_INITDB_ROOT_USERNAME: olake
MONGO_INITDB_ROOT_PASSWORD: olake
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install MongoDB client
run: sudo apt-get install -y mongodb-clients
- name: Wait for MongoDB to start
run: |
echo "Waiting for MongoDB to start..."
until nc -z localhost 27017; do sleep 1; done
- name: Initialize MongoDB Replica Set
run: |
mongo "mongodb://olake:olake@localhost:27017/admin" --eval 'rs.initiate({
_id: "rs0",
members: [
{ _id: 0, host: "localhost:27017" }
]
})'
- name: Wait for replica set readiness
run: |
echo "Waiting for replica set to become primary..."
until mongo "mongodb://olake:olake@localhost:27017/admin" --eval 'rs.status().myState' | grep 1; do
sleep 1
done
- name: Run tests
run: |
echo "Running tests..."
go test -v ./drivers/mongodb/internal