Skip to content

Commit 3960aeb

Browse files
authored
PHPORM-266 Run tests on Atlas Local (#3216)
1 parent aae9170 commit 3960aeb

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

.github/workflows/build-ci.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
- "5.0"
2020
- "6.0"
2121
- "7.0"
22+
- "Atlas"
2223
php:
2324
- "8.1"
2425
- "8.2"
@@ -45,15 +46,24 @@ jobs:
4546
- uses: "actions/checkout@v4"
4647

4748
- name: "Create MongoDB Replica Set"
49+
if: ${{ matrix.mongodb != 'Atlas' }}
4850
run: |
4951
docker run --name mongodb -p 27017:27017 -e MONGO_INITDB_DATABASE=unittest --detach mongo:${{ matrix.mongodb }} mongod --replSet rs --setParameter transactionLifetimeLimitSeconds=5
5052
5153
if [ "${{ matrix.mongodb }}" = "4.4" ]; then MONGOSH_BIN="mongo"; else MONGOSH_BIN="mongosh"; fi
5254
until docker exec --tty mongodb $MONGOSH_BIN 127.0.0.1:27017 --eval "db.runCommand({ ping: 1 })"; do
53-
sleep 1
55+
sleep 1
5456
done
5557
sudo docker exec --tty mongodb $MONGOSH_BIN 127.0.0.1:27017 --eval "rs.initiate({\"_id\":\"rs\",\"members\":[{\"_id\":0,\"host\":\"127.0.0.1:27017\" }]})"
5658
59+
- name: "Create MongoDB Atlas Local"
60+
if: ${{ matrix.mongodb == 'Atlas' }}
61+
run: |
62+
docker run --name mongodb -p 27017:27017 --detach mongodb/mongodb-atlas-local:latest
63+
until docker exec --tty mongodb mongosh 127.0.0.1:27017 --eval "db.runCommand({ ping: 1 })"; do
64+
sleep 1
65+
done
66+
5767
- name: "Show MongoDB server status"
5868
run: |
5969
if [ "${{ matrix.mongodb }}" = "4.4" ]; then MONGOSH_BIN="mongo"; else MONGOSH_BIN="mongosh"; fi
@@ -91,6 +101,10 @@ jobs:
91101
$([[ "${{ matrix.mode }}" == low-deps ]] && echo ' --prefer-lowest') \
92102
$([[ "${{ matrix.mode }}" == ignore-php-req ]] && echo ' --ignore-platform-req=php+')
93103
- name: "Run tests"
94-
run: "./vendor/bin/phpunit --coverage-clover coverage.xml"
95-
env:
96-
MONGODB_URI: 'mongodb://127.0.0.1/?replicaSet=rs'
104+
run: |
105+
if [ "${{ matrix.mongodb }}" = "Atlas" ]; then
106+
export MONGODB_URI="mongodb://127.0.0.1:27017/"
107+
else
108+
export MONGODB_URI="mongodb://127.0.0.1:27017/?replicaSet=rs"
109+
fi
110+
./vendor/bin/phpunit --coverage-clover coverage.xml

0 commit comments

Comments
 (0)