Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2b2c70a

Browse files
authored
Split Atlas tests into a distinct workflow matrix (#3245)
1 parent 19ed55e commit 2b2c70a

File tree

4 files changed

+85
-25
lines changed

4 files changed

+85
-25
lines changed

‎.github/workflows/build-ci-atlas.yml‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: "Atlas CI"
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
runs-on: "${{ matrix.os }}"
10+
11+
name: "PHP ${{ matrix.php }} Laravel ${{ matrix.laravel }} Atlas"
12+
13+
strategy:
14+
matrix:
15+
os:
16+
- "ubuntu-latest"
17+
php:
18+
- "8.2"
19+
- "8.3"
20+
- "8.4"
21+
laravel:
22+
- "11.*"
23+
24+
steps:
25+
- uses: "actions/checkout@v4"
26+
27+
- name: "Create MongoDB Atlas Local"
28+
run: |
29+
docker run --name mongodb -p 27017:27017 --detach mongodb/mongodb-atlas-local:latest
30+
until docker exec --tty mongodb mongosh --eval "db.runCommand({ ping: 1 })"; do
31+
sleep 1
32+
done
33+
until docker exec --tty mongodb mongosh --eval "db.createCollection('connection_test') && db.getCollection('connection_test').createSearchIndex({mappings:{dynamic: true}})"; do
34+
sleep 1
35+
done
36+
37+
- name: "Show MongoDB server status"
38+
run: |
39+
docker exec --tty mongodb mongosh --eval "db.runCommand({ serverStatus: 1 })"
40+
41+
- name: "Installing php"
42+
uses: "shivammathur/setup-php@v2"
43+
with:
44+
php-version: ${{ matrix.php }}
45+
extensions: "curl,mbstring,xdebug"
46+
coverage: "xdebug"
47+
tools: "composer"
48+
49+
- name: "Show Docker version"
50+
if: ${{ runner.debug }}
51+
run: "docker version && env"
52+
53+
- name: "Restrict Laravel version"
54+
run: "composer require --dev --no-update 'laravel/framework:${{ matrix.laravel }}'"
55+
56+
- name: "Download Composer cache dependencies from cache"
57+
id: "composer-cache"
58+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
59+
60+
- name: "Cache Composer dependencies"
61+
uses: "actions/cache@v4"
62+
with:
63+
path: ${{ steps.composer-cache.outputs.dir }}
64+
key: "${{ matrix.os }}-composer-${{ hashFiles('**/composer.json') }}"
65+
restore-keys: "${{ matrix.os }}-composer-"
66+
67+
- name: "Install dependencies"
68+
run: |
69+
composer update --no-interaction
70+
71+
- name: "Run tests"
72+
run: |
73+
export MONGODB_URI="mongodb://127.0.0.1:27017/?directConnection=true"
74+
./vendor/bin/phpunit --coverage-clover coverage.xml --group atlas-search

‎.github/workflows/build-ci.yml‎

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ jobs:
1111
name: "PHP ${{ matrix.php }} Laravel ${{ matrix.laravel }} MongoDB ${{ matrix.mongodb }} ${{ matrix.mode }}"
1212

1313
strategy:
14-
# Tests with Atlas fail randomly
15-
fail-fast: false
1614
matrix:
1715
os:
1816
- "ubuntu-latest"
@@ -21,11 +19,12 @@ jobs:
2119
- "5.0"
2220
- "6.0"
2321
- "7.0"
24-
- "Atlas"
22+
- "8.0"
2523
php:
2624
- "8.1"
2725
- "8.2"
2826
- "8.3"
27+
- "8.4"
2928
laravel:
3029
- "10.*"
3130
- "11.*"
@@ -38,7 +37,6 @@ jobs:
3837
- php: "8.4"
3938
laravel: "11.*"
4039
mongodb: "7.0"
41-
mode: "ignore-php-req"
4240
os: "ubuntu-latest"
4341
exclude:
4442
- php: "8.1"
@@ -48,31 +46,19 @@ jobs:
4846
- uses: "actions/checkout@v4"
4947

5048
- name: "Create MongoDB Replica Set"
51-
if: ${{ matrix.mongodb != 'Atlas' }}
5249
run: |
5350
docker run --name mongodb -p 27017:27017 -e MONGO_INITDB_DATABASE=unittest --detach mongo:${{ matrix.mongodb }} mongod --replSet rs --setParameter transactionLifetimeLimitSeconds=5
5451
5552
if [ "${{ matrix.mongodb }}" = "4.4" ]; then MONGOSH_BIN="mongo"; else MONGOSH_BIN="mongosh"; fi
56-
until docker exec --tty mongodb $MONGOSH_BIN 127.0.0.1:27017 --eval "db.runCommand({ ping: 1 })"; do
57-
sleep 1
58-
done
59-
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\" }]})"
60-
61-
- name: "Create MongoDB Atlas Local"
62-
if: ${{ matrix.mongodb == 'Atlas' }}
63-
run: |
64-
docker run --name mongodb -p 27017:27017 --detach mongodb/mongodb-atlas-local:latest
65-
until docker exec --tty mongodb mongosh 127.0.0.1:27017 --eval "db.runCommand({ ping: 1 })"; do
66-
sleep 1
67-
done
68-
until docker exec --tty mongodb mongosh 127.0.0.1:27017 --eval "db.createCollection('connection_test') && db.getCollection('connection_test').createSearchIndex({mappings:{dynamic: true}})"; do
53+
until docker exec --tty mongodb $MONGOSH_BIN --eval "db.runCommand({ ping: 1 })"; do
6954
sleep 1
7055
done
56+
sudo docker exec --tty mongodb $MONGOSH_BIN --eval "rs.initiate({\"_id\":\"rs\",\"members\":[{\"_id\":0,\"host\":\"127.0.0.1:27017\" }]})"
7157
7258
- name: "Show MongoDB server status"
7359
run: |
7460
if [ "${{ matrix.mongodb }}" = "4.4" ]; then MONGOSH_BIN="mongo"; else MONGOSH_BIN="mongosh"; fi
75-
docker exec --tty mongodb $MONGOSH_BIN 127.0.0.1:27017 --eval "db.runCommand({ serverStatus: 1 })"
61+
docker exec --tty mongodb $MONGOSH_BIN --eval "db.runCommand({ serverStatus: 1 })"
7662
7763
- name: "Installing php"
7864
uses: "shivammathur/setup-php@v2"
@@ -107,9 +93,5 @@ jobs:
10793
$([[ "${{ matrix.mode }}" == ignore-php-req ]] && echo ' --ignore-platform-req=php+')
10894
- name: "Run tests"
10995
run: |
110-
if [ "${{ matrix.mongodb }}" = "Atlas" ]; then
111-
export MONGODB_URI="mongodb://127.0.0.1:27017/"
112-
else
113-
export MONGODB_URI="mongodb://127.0.0.1:27017/?replicaSet=rs"
114-
fi
115-
./vendor/bin/phpunit --coverage-clover coverage.xml
96+
export MONGODB_URI="mongodb://127.0.0.1:27017/?replicaSet=rs"
97+
./vendor/bin/phpunit --coverage-clover coverage.xml --exclude-group atlas-search

‎tests/AtlasSearchTest.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use MongoDB\Driver\Exception\ServerException;
1212
use MongoDB\Laravel\Schema\Builder;
1313
use MongoDB\Laravel\Tests\Models\Book;
14+
use PHPUnit\Framework\Attributes\Group;
1415

1516
use function array_map;
1617
use function assert;
@@ -21,6 +22,7 @@
2122
use function usleep;
2223
use function usort;
2324

25+
#[Group('atlas-search')]
2426
class AtlasSearchTest extends TestCase
2527
{
2628
private array $vectors;

‎tests/Scout/ScoutIntegrationTest.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use MongoDB\Laravel\Tests\TestCase;
1313
use Override;
1414
use PHPUnit\Framework\Attributes\Depends;
15+
use PHPUnit\Framework\Attributes\Group;
1516

1617
use function array_merge;
1718
use function count;
@@ -21,6 +22,7 @@
2122
use function sprintf;
2223
use function usleep;
2324

25+
#[Group('atlas-search')]
2426
class ScoutIntegrationTest extends TestCase
2527
{
2628
#[Override]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /