test: run test again #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |