Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 21 additions & 2 deletions .github/workflows/build-ci-atlas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ on:
push:
pull_request:

env:
MONGODB_EXT_V1: mongodb-1.21.0
MONGODB_EXT_V2: mongodb-mongodb/mongo-php-driver@v2.x

jobs:
build:
runs-on: "${{ matrix.os }}"

name: "PHP ${{ matrix.php }} Laravel ${{ matrix.laravel }} Atlas"
name: "PHP/${{ matrix.php }} Laravel/${{ matrix.laravel }} Driver/${{ matrix.driver }}"

strategy:
matrix:
Expand All @@ -21,6 +25,13 @@ jobs:
laravel:
- "11.*"
- "12.*"
driver:
- 1
include:
- php: "8.4"
laravel: "12.*"
os: "ubuntu-latest"
driver: 2

steps:
- uses: "actions/checkout@v4"
Expand All @@ -39,11 +50,19 @@ jobs:
run: |
docker exec --tty mongodb mongosh --eval "db.runCommand({ serverStatus: 1 })"

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}
key: "extcache-v1"

- name: "Installing php"
uses: "shivammathur/setup-php@v2"
with:
php-version: ${{ matrix.php }}
extensions: "curl,mbstring,xdebug"
extensions: "curl,mbstring,xdebug,${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}"
coverage: "xdebug"
tools: "composer"

Expand Down
25 changes: 23 additions & 2 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ on:
push:
pull_request:

env:
MONGODB_EXT_V1: mongodb-1.21.0
MONGODB_EXT_V2: mongodb-mongodb/mongo-php-driver@v2.x

jobs:
build:
runs-on: "${{ matrix.os }}"

name: "PHP ${{ matrix.php }} Laravel ${{ matrix.laravel }} MongoDB ${{ matrix.mongodb }} ${{ matrix.mode }}"
name: "PHP/${{ matrix.php }} Laravel/${{ matrix.laravel }} Driver/${{ matrix.driver }} Server/${{ matrix.mongodb }} ${{ matrix.mode }}"

strategy:
matrix:
Expand All @@ -29,12 +33,21 @@ jobs:
- "10.*"
- "11.*"
- "12.*"
driver:
- 1
include:
- php: "8.1"
laravel: "10.*"
mongodb: "5.0"
mode: "low-deps"
os: "ubuntu-latest"
driver: 1.x
driver_version: "1.21.0"
- php: "8.4"
laravel: "12.*"
mongodb: "8.0"
os: "ubuntu-latest"
driver: 2
exclude:
- php: "8.1"
laravel: "11.*"
Expand All @@ -59,11 +72,19 @@ jobs:
if [ "${{ matrix.mongodb }}" = "4.4" ]; then MONGOSH_BIN="mongo"; else MONGOSH_BIN="mongosh"; fi
docker exec --tty mongodb $MONGOSH_BIN --eval "db.runCommand({ serverStatus: 1 })"

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}
key: "extcache-v1"

- name: "Installing php"
uses: "shivammathur/setup-php@v2"
with:
php-version: ${{ matrix.php }}
extensions: "curl,mbstring,xdebug"
extensions: "curl,mbstring,xdebug,${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}"
coverage: "xdebug"
tools: "composer"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:

env:
PHP_VERSION: "8.2"
PHP_VERSION: "8.4"
DRIVER_VERSION: "stable"

jobs:
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ on:
env:
PHP_VERSION: "8.2"
DRIVER_VERSION: "stable"
MONGODB_EXT_V1: mongodb-1.21.0
MONGODB_EXT_V2: mongodb-mongodb/mongo-php-driver@v2.x

jobs:
phpstan:
name: "PHP/${{ matrix.php }} Driver/${{ matrix.driver }}"
runs-on: "ubuntu-22.04"
continue-on-error: true
strategy:
Expand All @@ -24,6 +27,10 @@ jobs:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
driver:
- 1
- 2
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -35,11 +42,19 @@ jobs:
run: |
echo CHECKED_OUT_SHA=$(git rev-parse HEAD) >> $GITHUB_ENV

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}
key: "extcache-v1"

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, mbstring
extensions: "curl,mbstring,${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}"
tools: composer:v2
coverage: none

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
"license": "MIT",
"require": {
"php": "^8.1",
"ext-mongodb": "^1.21",
"ext-mongodb": "^1.21|^2",
"composer-runtime-api": "^2.0.0",
"illuminate/cache": "^10.36|^11|^12",
"illuminate/container": "^10.0|^11|^12",
"illuminate/database": "^10.30|^11|^12",
"illuminate/events": "^10.0|^11|^12",
"illuminate/support": "^10.0|^11|^12",
"mongodb/mongodb": "^1.21",
"mongodb/mongodb": "^1.21|^2",
"symfony/http-foundation": "^6.4|^7"
},
"require-dev": {
Expand Down
4 changes: 2 additions & 2 deletions src/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use MongoDB\Builder\Type\QueryInterface;
use MongoDB\Builder\Type\SearchOperatorInterface;
use MongoDB\Driver\CursorInterface;
use MongoDB\Driver\Exception\WriteException;
use MongoDB\Driver\Exception\BulkWriteException;
use MongoDB\Laravel\Connection;
use MongoDB\Laravel\Helpers\QueriesRelationships;
use MongoDB\Laravel\Query\AggregationBuilder;
Expand Down Expand Up @@ -285,7 +285,7 @@ public function createOrFirst(array $attributes = [], array $values = [])

try {
return $this->create(array_merge($attributes, $values));
} catch (WriteException $e) {
} catch (BulkWriteException $e) {
if ($e->getCode() === self::DUPLICATE_KEY_ERROR) {
return $this->where($attributes)->first() ?? throw $e;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function testFindWithTimeout()
$id = DB::table('users')->insertGetId(['name' => 'John Doe']);

$subscriber = new class implements CommandSubscriber {
public function commandStarted(CommandStartedEvent $event)
public function commandStarted(CommandStartedEvent $event): void
{
if ($event->getCommandName() !== 'find') {
return;
Expand All @@ -171,11 +171,11 @@ public function commandStarted(CommandStartedEvent $event)
Assert::assertSame(1000, $event->getCommand()->maxTimeMS);
}

public function commandFailed(CommandFailedEvent $event)
public function commandFailed(CommandFailedEvent $event): void
{
}

public function commandSucceeded(CommandSucceededEvent $event)
public function commandSucceeded(CommandSucceededEvent $event): void
{
}
};
Expand Down
Loading
Loading