Skip to content

Commit

Permalink
Update CI (#1909)
Browse files Browse the repository at this point in the history
* Update CI

* Fix deprecation warning

* Fix types
  • Loading branch information
Seldaek authored Aug 27, 2024
1 parent 884aa47 commit 23560e3
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 60 deletions.
33 changes: 12 additions & 21 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- pull_request

permissions:
contents: read # to fetch code (actions/checkout)
contents: read

jobs:
tests:
Expand Down Expand Up @@ -43,8 +43,7 @@ jobs:
composer-options: "--ignore-platform-req=php+"

steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- uses: "actions/checkout@v4"

- name: Run CouchDB
timeout-minutes: 3
Expand All @@ -58,8 +57,7 @@ jobs:
with:
mongodb-version: 5.0

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
- uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
Expand All @@ -75,8 +73,7 @@ jobs:
composer require --no-update --no-interaction --dev elasticsearch/elasticsearch:^7
composer config --no-plugins allow-plugins.ocramius/package-versions true
- name: "Update dependencies with composer"
uses: "ramsey/composer-install@v2"
- uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-options }}"
Expand Down Expand Up @@ -132,8 +129,7 @@ jobs:
es-version: "7.0.0"

steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- uses: "actions/checkout@v4"

# required for elasticsearch
- name: Configure sysctl limits
Expand All @@ -149,8 +145,7 @@ jobs:
with:
stack-version: "${{ matrix.es-version }}"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
- uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
Expand All @@ -165,8 +160,7 @@ jobs:
if: "matrix.php-version == '7.4' && matrix.dependencies == 'lowest'"
run: "composer config allow-plugins.ocramius/package-versions true"

- name: "Update dependencies with composer"
uses: "ramsey/composer-install@v2"
- uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependencies }}"

Expand All @@ -177,9 +171,9 @@ jobs:
if: "contains(matrix.dependencies, 'highest') && matrix.php-version >= '8.0'"
run: |
composer remove --no-update --dev graylog2/gelf-php ruflin/elastica elasticsearch/elasticsearch rollbar/rollbar
composer require --no-update --no-interaction --dev ruflin/elastica elasticsearch/elasticsearch:^7
composer require --no-update --no-interaction --dev ruflin/elastica:^7 elasticsearch/elasticsearch:^7
composer require --no-update psr/log:^3
composer update -W
composer update
composer exec phpunit -- --group Elasticsearch,Elastica --verbose
tests-es-8:
Expand Down Expand Up @@ -211,8 +205,7 @@ jobs:
- "8.2.0"

steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- uses: "actions/checkout@v4"

# required for elasticsearch
- name: Configure sysctl limits
Expand All @@ -228,8 +221,7 @@ jobs:
with:
stack-version: "${{ matrix.es-version }}"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
- uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
Expand All @@ -246,8 +238,7 @@ jobs:
if: "matrix.php-version == '7.4' && matrix.dependencies == 'lowest'"
run: "composer config allow-plugins.ocramius/package-versions true"

- name: "Update dependencies with composer"
uses: "ramsey/composer-install@v2"
- uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependencies }}"

Expand Down
32 changes: 20 additions & 12 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: "PHP Lint"

on:
push:
pull_request:
- push
- pull_request

permissions:
contents: read # to fetch code (actions/checkout)
contents: read

jobs:
tests:
Expand All @@ -17,19 +17,27 @@ jobs:
matrix:
php-version:
- "7.2"
- "8.3"
- "nightly"

steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- uses: actions/checkout@v4

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
- uses: shivammathur/setup-php@v2
with:
coverage: "none"
extensions: "intl"
ini-values: "memory_limit=-1"
php-version: "${{ matrix.php-version }}"
coverage: none

- name: "Lint PHP files"
run: "find src/ -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f"
run: |
hasErrors=0
for f in $(find src/ tests/ -type f -name '*.php' ! -path '*/vendor/*' ! -path '*/Fixtures/*')
do
{ error="$(php -derror_reporting=-1 -ddisplay_errors=1 -l -f $f 2>&1 1>&3 3>&-)"; } 3>&1;
if [ "$error" != "" ]; then
while IFS= read -r line; do echo "::error file=$f::$line"; done <<< "$error"
hasErrors=1
fi
done
if [ $hasErrors -eq 1 ]; then
exit 1
fi
32 changes: 9 additions & 23 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ on:
- push
- pull_request

env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"

permissions:
contents: read # to fetch code (actions/checkout)
contents: read

jobs:
tests:
Expand All @@ -22,33 +19,22 @@ jobs:
- "8.0"

steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- uses: actions/checkout@v4

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
- uses: shivammathur/setup-php@v2
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
coverage: none
extensions: mongodb, redis, amqp

- name: Get composer cache directory
id: composercache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composercache.outputs.dir }}
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"
# --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"
- uses: ramsey/composer-install@v3
with:
dependency-versions: highest
# --ignore-platform-req=php here needed as long as elasticsearch/elasticsearch does not support php 8
composer-options: '--ignore-platform-req=php'

- name: Run PHPStan
run: composer phpstan
1 change: 1 addition & 0 deletions src/Monolog/Handler/ElasticsearchHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ protected function bulkSend(array $records): void
*/
protected function createExceptionFromResponses($responses): Throwable
{
// @phpstan-ignore offsetAccess.nonOffsetAccessible
foreach ($responses['items'] ?? [] as $item) {
if (isset($item['index']['error'])) {
return $this->createExceptionFromError($item['index']['error']);
Expand Down
7 changes: 4 additions & 3 deletions src/Monolog/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class Logger implements LoggerInterface, ResettableInterface
private $logDepth = 0;

/**
* @var \WeakMap<\Fiber, int>|null Keeps track of depth inside fibers to prevent infinite logging loops
* @var \WeakMap<\Fiber<mixed, mixed, mixed, mixed>, int> Keeps track of depth inside fibers to prevent infinite logging loops
*/
private $fiberLogDepth;

Expand Down Expand Up @@ -197,7 +197,7 @@ public function __construct(string $name, array $handlers = [], array $processor

if (\PHP_VERSION_ID >= 80100) {
// Local variable for phpstan, see https://github.com/phpstan/phpstan/issues/6732#issuecomment-1111118412
/** @var \WeakMap<\Fiber, int> $fiberLogDepth */
/** @var \WeakMap<\Fiber<mixed, mixed, mixed, mixed>, int> $fiberLogDepth */
$fiberLogDepth = new \WeakMap();
$this->fiberLogDepth = $fiberLogDepth;
}
Expand Down Expand Up @@ -345,6 +345,7 @@ public function addRecord(int $level, string $message, array $context = [], ?Dat

if ($this->detectCycles) {
if (\PHP_VERSION_ID >= 80100 && $fiber = \Fiber::getCurrent()) {
// @phpstan-ignore offsetAssign.dimType
$this->fiberLogDepth[$fiber] = $this->fiberLogDepth[$fiber] ?? 0;
$logDepth = ++$this->fiberLogDepth[$fiber];
} else {
Expand Down Expand Up @@ -753,7 +754,7 @@ public function __unserialize(array $data): void

if (\PHP_VERSION_ID >= 80100) {
// Local variable for phpstan, see https://github.com/phpstan/phpstan/issues/6732#issuecomment-1111118412
/** @var \WeakMap<\Fiber, int> $fiberLogDepth */
/** @var \WeakMap<\Fiber<mixed, mixed, mixed, mixed>, int> $fiberLogDepth */
$fiberLogDepth = new \WeakMap();
$this->fiberLogDepth = $fiberLogDepth;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Monolog/SignalHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function testRegisterCallablePreviousSignalHandler($callPrevious)
$logger = new Logger('test', array($handler = new TestHandler));
$errHandler = new SignalHandler($logger);
$previousCalled = 0;
pcntl_signal(SIGURG, function ($signo, array $siginfo = null) use (&$previousCalled) {
pcntl_signal(SIGURG, function ($signo, ?array $siginfo = null) use (&$previousCalled) {
++$previousCalled;
});
$errHandler->registerSignalHandler(SIGURG, LogLevel::INFO, $callPrevious, false, false);
Expand Down

0 comments on commit 23560e3

Please sign in to comment.