Kaynağa Gözat

Build tweaks

Jordi Boggiano 5 yıl önce
ebeveyn
işleme
ec146b38bd

+ 12 - 12
.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"

+ 6 - 1
.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

+ 2 - 1
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",

+ 1 - 0
phpstan.neon.dist

@@ -2,6 +2,7 @@ parameters:
     level: 5
 
     treatPhpDocTypesAsCertain: false
+    reportUnmatchedIgnoredErrors: false
 
     paths:
         - src/

+ 1 - 1
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', '<=');
     }
 
     /**

+ 1 - 1
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));
     }

+ 1 - 1
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')