Skip to content

PHPORM-266 Run tests on Atlas Local #3216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- "5.0"
- "6.0"
- "7.0"
- "Atlas"
php:
- "8.1"
- "8.2"
Expand All @@ -45,15 +46,24 @@ jobs:
- uses: "actions/checkout@v4"

- name: "Create MongoDB Replica Set"
if: ${{ matrix.mongodb != 'Atlas' }}
run: |
docker run --name mongodb -p 27017:27017 -e MONGO_INITDB_DATABASE=unittest --detach mongo:${{ matrix.mongodb }} mongod --replSet rs --setParameter transactionLifetimeLimitSeconds=5

if [ "${{ matrix.mongodb }}" = "4.4" ]; then MONGOSH_BIN="mongo"; else MONGOSH_BIN="mongosh"; fi
until docker exec --tty mongodb $MONGOSH_BIN 127.0.0.1:27017 --eval "db.runCommand({ ping: 1 })"; do
sleep 1
sleep 1
done
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\" }]})"

- name: "Create MongoDB Atlas Local"
if: ${{ matrix.mongodb == 'Atlas' }}
run: |
docker run --name mongodb -p 27017:27017 --detach mongodb/mongodb-atlas-local:latest
until docker exec --tty mongodb mongosh 127.0.0.1:27017 --eval "db.runCommand({ ping: 1 })"; do
sleep 1
done

- name: "Show MongoDB server status"
run: |
if [ "${{ matrix.mongodb }}" = "4.4" ]; then MONGOSH_BIN="mongo"; else MONGOSH_BIN="mongosh"; fi
Expand Down Expand Up @@ -91,6 +101,10 @@ jobs:
$([[ "${{ matrix.mode }}" == low-deps ]] && echo ' --prefer-lowest') \
$([[ "${{ matrix.mode }}" == ignore-php-req ]] && echo ' --ignore-platform-req=php+')
- name: "Run tests"
run: "./vendor/bin/phpunit --coverage-clover coverage.xml"
env:
MONGODB_URI: 'mongodb://127.0.0.1/?replicaSet=rs'
run: |
if [ "${{ matrix.mongodb }}" = "Atlas" ]; then
export MONGODB_URI="mongodb://127.0.0.1:27017/"
else
export MONGODB_URI="mongodb://127.0.0.1:27017/?replicaSet=rs"
fi
./vendor/bin/phpunit --coverage-clover coverage.xml
Loading