diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 5109833f..9852d780 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -40,18 +40,6 @@ jobs: php-version: "${{ matrix.php-version }}" extensions: mongodb, redis, amqp - - name: Configure sysctl limits - run: | - sudo swapoff -a - sudo sysctl -w vm.swappiness=1 - sudo sysctl -w fs.file-max=262144 - sudo sysctl -w vm.max_map_count=262144 - - - name: Runs Elasticsearch - uses: elastic/elastic-github-actions/elasticsearch@master - with: - stack-version: 7.6.0 - - name: Get composer cache directory id: composercache run: echo "::set-output name=dir::$(composer config cache-files-dir)" @@ -63,6 +51,18 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- + - name: Remove elasticsearch/elasticsearch on PHP 8 + if: "startsWith(matrix.php-version, '8.')" + run: 'composer remove elasticsearch/elasticsearch --dev --no-update' + + - name: Add require for mongodb/mongodb to make tests runnable + run: 'composer require ${{ env.COMPOSER_FLAGS }} mongodb/mongodb --dev --no-update' + + # This does not affect runtime, only tests were fixed in psr/log 1.1.2 so it's + # ok to require this only when running tests + - name: Bump required version of psr/log for tests purposes to fix the --prefer-lowest builds + run: 'composer require ${{ env.COMPOSER_FLAGS }} psr/log:^1.1.2 --no-update' + - name: "Handle lowest dependencies update" if: "contains(matrix.dependencies, 'lowest')" run: "echo \"COMPOSER_FLAGS=$COMPOSER_FLAGS --prefer-lowest\" >> $GITHUB_ENV" diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index b26a5573..434324ce 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -27,6 +27,7 @@ jobs: with: coverage: "none" php-version: "${{ matrix.php-version }}" + extensions: mongodb, redis, amqp - name: Get composer cache directory id: composercache @@ -39,8 +40,12 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- + - name: Add require for mongodb/mongodb to make tests runnable + run: 'composer require ${{ env.COMPOSER_FLAGS }} mongodb/mongodb --dev --no-update' + - name: "Install latest dependencies" - run: "composer update ${{ env.COMPOSER_FLAGS }}" + # --ignore-platform-req=php here needed as long as elasticsearch/elasticsearch does not support php 8 + run: "composer update ${{ env.COMPOSER_FLAGS }} --ignore-platform-req=php" - name: Run PHPStan run: composer phpstan diff --git a/composer.json b/composer.json index 247a6749..37a9ec58 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "require-dev": { "aws/aws-sdk-php": "^2.4.9 || ^3.0", "doctrine/couchdb": "~1.0@dev", - "elasticsearch/elasticsearch": "^6.0", + "elasticsearch/elasticsearch": "^7", + "mongodb/mongodb": "^1.8", "graylog2/gelf-php": "^1.4.2", "php-amqplib/php-amqplib": "~2.4", "php-console/php-console": "^3.1.3", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index d343ffec..a56c5030 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,6 +2,7 @@ parameters: level: 5 treatPhpDocTypesAsCertain: false + reportUnmatchedIgnoredErrors: false paths: - src/ diff --git a/src/Monolog/Formatter/MongoDBFormatter.php b/src/Monolog/Formatter/MongoDBFormatter.php index d85c58c6..9241b1b7 100644 --- a/src/Monolog/Formatter/MongoDBFormatter.php +++ b/src/Monolog/Formatter/MongoDBFormatter.php @@ -34,7 +34,7 @@ class MongoDBFormatter implements FormatterInterface $this->maxNestingLevel = max($maxNestingLevel, 0); $this->exceptionTraceAsString = $exceptionTraceAsString; - $this->isLegacyMongoExt = version_compare(phpversion('mongodb'), '1.1.9', '<='); + $this->isLegacyMongoExt = extension_loaded('mongodb') && version_compare(phpversion('mongodb'), '1.1.9', '<='); } /** diff --git a/tests/Monolog/Formatter/MongoDBFormatterTest.php b/tests/Monolog/Formatter/MongoDBFormatterTest.php index 140341b4..6a2dd04e 100644 --- a/tests/Monolog/Formatter/MongoDBFormatterTest.php +++ b/tests/Monolog/Formatter/MongoDBFormatterTest.php @@ -49,7 +49,7 @@ class MongoDBFormatterTest extends \PHPUnit\Framework\TestCase $reflTrace->setAccessible(true); $this->assertEquals($expectedTraceAsString, $reflTrace->getValue($formatter)); - $reflDepth = new\ReflectionProperty($formatter, 'maxNestingLevel'); + $reflDepth = new \ReflectionProperty($formatter, 'maxNestingLevel'); $reflDepth->setAccessible(true); $this->assertEquals($expectedTraceDepth, $reflDepth->getValue($formatter)); } diff --git a/tests/Monolog/Handler/MongoDBHandlerTest.php b/tests/Monolog/Handler/MongoDBHandlerTest.php index a21f207b..0a9a0bea 100644 --- a/tests/Monolog/Handler/MongoDBHandlerTest.php +++ b/tests/Monolog/Handler/MongoDBHandlerTest.php @@ -45,7 +45,7 @@ class MongoDBHandlerTest extends TestCase $record = $this->getRecord(); $expected = $record; - $expected['datetime'] = $record['datetime']->format(NormalizerFormatter::SIMPLE_DATE); + $expected['datetime'] = new \MongoDB\BSON\UTCDateTime((int) floor(((float) $record['datetime']->format('U.u')) * 1000)); $collection->expects($this->once()) ->method('insertOne')