Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schedule CI run weekly to keep it in check #19

Merged
merged 26 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
61c7f7e
Schedule CI run weekly to keep it in check
Jean85 Mar 14, 2024
d441da2
Upgrade (and pin) PHPStan
Jean85 Mar 14, 2024
95d0d05
Try to solve deprecations
Jean85 Mar 14, 2024
1f26f39
Parametrize Docker image to run with other versions
Jean85 Mar 14, 2024
bc158ea
Fix Docker OhMyZsh installation
Jean85 Mar 13, 2024
26ab795
Rationalize CI jobs by locking Symfony major and ext-mongodb versions…
Jean85 Mar 14, 2024
58823e7
Fix Symfony parameter in matrix
Jean85 Mar 14, 2024
76a25f6
Merge branch '1.x' into check-ci
Jean85 Mar 14, 2024
8ed2482
Merge branch '1.x' into check-ci
Jean85 Mar 14, 2024
f9cbe52
Revert wrong CS change that breaks tests
Jean85 Mar 14, 2024
3d1c112
Remove duplicate PHP label in job name
Jean85 Mar 14, 2024
569216f
Fix Docker config for newer PHP versions
starred-gijs Mar 13, 2024
f90f93b
Suppress serializer deprecations for Symfony 6
Jean85 Mar 14, 2024
ce2bb7c
Solve MessageHandlerInterface deprecation
Jean85 Mar 14, 2024
c1161f7
Disable Symfony 7, will do in #18
Jean85 Mar 14, 2024
5b33c84
Fix RedeliveryStamp deprecations on 5.4
Jean85 Mar 14, 2024
5e0a27b
Fix Xdebug 3 config
Jean85 Mar 14, 2024
58be964
Fix ObjectNormalizerDecorator compat with Symfony 4.4
Jean85 Mar 14, 2024
e832310
Allow plugin required in prefer-lowest
Jean85 Mar 14, 2024
988901d
Fix newer CI job
Jean85 Mar 14, 2024
b0208e5
Use Composer 1 in prefer-lowest
Jean85 Mar 14, 2024
a82af0a
Relax phpstan/extension-installer constraint to allow Composer v1
Jean85 Mar 14, 2024
8e792b2
Pin newer PHP version for PHPStan and fix its errors
Jean85 Mar 14, 2024
861323c
Bump Symfony Flex
Jean85 Mar 14, 2024
97a4581
Relax PHPStan baseline rule to match whenever possible
Jean85 Mar 14, 2024
7886c8d
Bump Symfony at first patch for prefer-lowest to avoid bug on handler…
Jean85 Mar 14, 2024
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
41 changes: 30 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
push:
branches:
- 1.x
schedule:
- cron: "42 3 * * 1"

jobs:
tests:
Expand All @@ -21,26 +23,43 @@ jobs:

strategy:
matrix:
composer: ['composer:v2']
dependencies: ['highest']
description: ['Tests']
php:
- 8.1
- 8.0
- 7.4
php: ['8.3']
mongodb: ['1.17.2']
include:
- description: Tests - Symfony 5.4 LTS
php: 7.4
symfony: '5.4.*'
- description: Tests - Symfony 4.4 LTS
# TODO - Symfony 7
# - description: Tests - Symfony 6.4
# php: 8.3
# symfony-version: '7.*'
# mongodb: '1.17.2' # latest
- description: Tests - Symfony 6.4
php: 8.2
symfony-version: '6.4.*'
mongodb: '1.15.3' # 1.15 introduced PHP 8.2 support
- description: Tests - Symfony 5.4
php: 8.1
symfony-version: '5.4.*'
mongodb: '1.12.1' # 1.12 introduced PHP 8.1 support
- description: Tests - Symfony 5.4
php: 8.0
symfony-version: '5.4.*'
- description: Tests - Symfony 4.4
php: 7.4
mongodb: ['1.9.2']
symfony-version: '4.4.*'
- description: Prefer lowest
composer: 'composer:v1'
dependencies: 'lowest'
php: 7.4
symfony-version: '4.4.*'
symfony-version: '^4.4.1'
mongodb: '1.2.0'
deprecations: disabled
- description: Infection
mongodb: ['1.9.2']
php: 7.4
symfony-version: '4.4.*'

env:
MONGO_HOST: localhost
Expand All @@ -54,7 +73,7 @@ jobs:
php-version: ${{ matrix.php }}
extensions: mongodb
coverage: xdebug2
tools: flex
tools: flex,${{ matrix.composer }}
- name: Allow unstable dependencies
run: composer config minimum-stability dev
if: matrix.symfony-version == 'dev-master'
Expand All @@ -71,7 +90,7 @@ jobs:
SYMFONY_DEPRECATIONS_HELPER: ${{ matrix.deprecations }}
- name: Run mutation testing
if: matrix.description == 'Infection'
run: vendor/bin/infection --show-mutations --min-msi=84
run: vendor/bin/infection --show-mutations
- name: Upload code coverage
if: matrix.description != 'Infection'
uses: codecov/codecov-action@v1
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
push:
branches:
- 1.x
schedule:
- cron: "42 3 * * 1"

jobs:
job:
Expand All @@ -20,14 +22,16 @@ jobs:

name: ${{ matrix.description }}
runs-on: ubuntu-latest
env:
SYMFONY_REQUIRE: '6.4.*'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: mongodb
php-version: 8.2
extensions: mongodb-1.17.2
- name: Install dependencies
uses: "ramsey/composer-install@v1"
- run: ${{ matrix.script }}
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
"facile-it/facile-coding-standard": "^1.2",
"facile-it/symfony-functional-testcase": "^1.0",
"infection/infection": ">=0.18",
"jangregor/phpstan-prophecy": "^0.8.0",
"jangregor/phpstan-prophecy": "^1.0",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12.25",
"phpstan/phpstan-phpunit": "^0.12.8",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "1.10.62",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^9.5.2",
"symfony/browser-kit": "^4.4 || ^5.0 || ^6.0",
"symfony/flex": "^1.12",
"symfony/flex": "^1.21.6 || ^2.0",
"symfony/phpunit-bridge": "^5.2.4",
"symfony/property-access": "^4.4 || ^5.0 || ^6.0",
"symfony/property-info": "^4.4 || ^5.0 || ^6.0",
Expand All @@ -59,6 +59,7 @@
"allow-plugins": {
"facile-it/facile-coding-standard": true,
"infection/extension-installer": true,
"ocramius/package-versions": true,
"phpstan/extension-installer": true,
"symfony/flex": true
}
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.override.yml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
version: "3.1"

services:
php:
environment:
XDEBUG_SESSION: PHPSTORM
# XDEBUG_MODE: debug
mongo:
ports:
- 27017:27017
6 changes: 5 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ version: "3.1"

services:
php:
image: local.example.com/php:${PHP_VERSION:-latest}
build:
context: docker/
volumes:
- ./:/home/user-dev/project
tty: true
environment:
XDEBUG_START_WITH_REQUEST: 'yes'
XDEBUG_HOST: host.docker.internal

depends_on:
- mongo
mongo:
image: mongo:3.4.2
image: mongo:4.4
tmpfs:
- /data/db:uid=1001
environment:
Expand Down
14 changes: 8 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
FROM php:7.4-alpine
ARG PHP_VERSION=7.4
FROM php:${PHP_VERSION}-alpine

RUN apk --no-cache add \
$PHPIZE_DEPS \
curl \
git \
less \
libzip-dev \
linux-headers \
nano \
openssl-dev \
supervisor \
zip \
zsh

RUN pecl install mongodb-1.9.0 \
ARG MONGO_VERSION=1.9.2
RUN pecl install mongodb-${MONGO_VERSION} \
&& docker-php-ext-enable mongodb

RUN pecl install xdebug-2.9.7 \
ARG XDEBUG_VERSION=2.9.7
RUN pecl install xdebug-${XDEBUG_VERSION} \
&& docker-php-ext-enable xdebug

COPY config/php.ini /usr/local/etc/php/conf.d/

#COMPOSER
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN adduser -u 1000 -G wheel -D user-dev -s /bin/zsh
USER user-dev

#Zsh minimal installation
RUN git clone --depth=1 git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
ADD config/.zshrc /root/
ADD config/.zshrc /home/user-dev/

Expand Down
13 changes: 0 additions & 13 deletions docker/config/php.ini

This file was deleted.

3 changes: 2 additions & 1 deletion infection.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"logs": {
"text": "infection.log"
},
"minMsi": 84,
"mutators": {
"@default": true
}
}
}
49 changes: 47 additions & 2 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,20 +1,65 @@
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Messenger\\\\Stamp\\\\RedeliveryStamp\\:\\:getExceptionMessage\\(\\)\\.$#"
count: 1
path: src/Extension/DocumentEnhancer/FirstErrorMessageEnhancer.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Messenger\\\\Stamp\\\\RedeliveryStamp\\:\\:getExceptionMessage\\(\\)\\.$#"
count: 1
path: src/Extension/DocumentEnhancer/LastErrorMessageEnhancer.php

-
message: "#^Method Facile\\\\MongoDbMessenger\\\\Transport\\\\Connection\\:\\:find\\(\\) should return MongoDB\\\\Model\\\\BSONDocument\\|null but returns array\\|object\\|null\\.$#"
count: 1
path: src/Transport/Connection.php

-
message: "#^Method Facile\\\\MongoDbMessenger\\\\Transport\\\\Connection\\:\\:findBy\\(\\) should return iterable\\<MongoDB\\\\Model\\\\BSONDocument\\>&MongoDB\\\\Driver\\\\Cursor but returns MongoDB\\\\Driver\\\\Cursor\\.$#"
message: "#^Method Facile\\\\MongoDbMessenger\\\\Transport\\\\Connection\\:\\:findBy\\(\\) should return iterable\\<MongoDB\\\\Model\\\\BSONDocument\\>&MongoDB\\\\Driver\\\\Cursor but returns#"
count: 1
path: src/Transport/Connection.php

-
message: "#^Parameter \\#1 \\$enhancer of method Facile\\\\MongoDbMessenger\\\\Transport\\\\Connection\\:\\:addDocumentEnhancer\\(\\) expects Facile\\\\MongoDbMessenger\\\\Extension\\\\DocumentEnhancer, object\\|null given\\.$#"
message: "#^Method Facile\\\\MongoDbMessenger\\\\Transport\\\\Connection\\:\\:send\\(\\) should return MongoDB\\\\BSON\\\\ObjectId but returns mixed\\.$#"
count: 1
path: src/Transport/Connection.php

-
message: "#^Method Facile\\\\MongoDbMessenger\\\\Transport\\\\TransportFactory\\:\\:buildConfiguration\\(\\) should return array\\{connection_name\\: string, collection_name\\: string, queue_name\\: string, redeliver_timeout\\: int, document_enhancers\\: array\\<string\\>, resettable\\: 0\\|1\\|bool\\} but returns non\\-empty\\-array\\<int\\|string, mixed\\>\\.$#"
count: 1
path: src/Transport/TransportFactory.php

-
message: "#^Parameter \\#1 \\$enhancers of method Facile\\\\MongoDbMessenger\\\\Transport\\\\TransportFactory\\:\\:validateDocumentEnhancers\\(\\) expects array\\<string\\>, mixed given\\.$#"
count: 1
path: src/Transport/TransportFactory.php

-
message: "#^Strict comparison using \\=\\=\\= between object and null will always evaluate to false\\.$#"
count: 1
path: src/Transport/TransportFactory.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Messenger\\\\Stamp\\\\RedeliveryStamp\\:\\:getExceptionMessage\\(\\)\\.$#"
count: 2
path: src/Util/RedeliveryStampExtractor.php

-
message: "#^Method Facile\\\\MongoDbMessenger\\\\Tests\\\\End2End\\\\App\\\\ObjectNormalizerDecorator\\:\\:normalize\\(\\) return type with generic class ArrayObject does not specify its types\\: TKey, TValue$#"
count: 1
path: tests/End2End/App/ObjectNormalizerDecorator.php

-
message: "#^Method Facile\\\\MongoDbMessenger\\\\Tests\\\\End2End\\\\App\\\\ObjectNormalizerDecorator\\:\\:normalize\\(\\) should return \\(ArrayObject&iterable\\)\\|bool\\|float\\|int\\|string\\|null but returns array\\|ArrayObject\\|bool\\|float\\|int\\|string\\|null\\.$#"
count: 1
path: tests/End2End/App/ObjectNormalizerDecorator.php

-
message: "#^Parameter \\#1 \\$id of method Facile\\\\MongoDbMessenger\\\\Transport\\\\MongoDbUnresettableTransport\\:\\:find\\(\\) expects MongoDB\\\\BSON\\\\ObjectId\\|string, mixed given\\.$#"
count: 1
path: tests/Functional/Transport/MongoDbTransportTest.php

-
message: "#^Constructor of class Facile\\\\MongoDbMessenger\\\\Tests\\\\Stubs\\\\NotInstantiableDocumentEnhancer has an unused parameter \\$bar\\.$#"
count: 1
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ parameters:
dynamicConstantNames:
- Symfony\Component\HttpKernel\Kernel::VERSION_ID
ignoreErrors:
- /no value type specified in iterable type MongoDB\\Model\\BSONDocument\./
- /^Access to an undefined property MongoDB\\Model\\BSONDocument::\$\w+\.$/
includes:
- phpstan-baseline.neon
2 changes: 1 addition & 1 deletion src/Transport/MongoDbUnresettableTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(Connection $connection, SerializerInterface $seriali
*
* @return array{0?: Envelope}
*/
public function get(): iterable
public function get(): array
{
return $this->getReceiver()->get();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Transport/Receiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public function __construct(Connection $connection, SerializerInterface $seriali
/**
* @return array{0?: Envelope}
*/
public function get(): iterable
public function get(): array
{
$document = $this->connection->get();

if ($document === null) {
return [];
}

yield from [$this->createEnvelope($document)];
return [$this->createEnvelope($document)];
}

public function ack(Envelope $envelope): void
Expand Down
11 changes: 8 additions & 3 deletions src/Transport/TransportFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
use Symfony\Component\Messenger\Exception\InvalidArgumentException;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
use Symfony\Component\Messenger\Transport\TransportInterface;

/**
* @template-implements TransportFactoryInterface<MongoDbUnresettableTransport>
*/
final class TransportFactory implements TransportFactoryInterface
{
private const DEFAULT_OPTIONS = [
Expand Down Expand Up @@ -53,7 +55,7 @@ public function supports(string $dsn, array $options): bool
/**
* @param array<string, mixed> $options
*/
public function createTransport(string $dsn, array $options, SerializerInterface $serializer): TransportInterface
public function createTransport(string $dsn, array $options, SerializerInterface $serializer): MongoDbUnresettableTransport
{
$configuration = $this->buildConfiguration($dsn, $options);

Expand Down Expand Up @@ -90,10 +92,13 @@ private function addDocumentEnhancers(Connection $connection, array $options): v
if ($this->isServiceDefinition($name)) {
$enhancer = $this->container->get(ltrim($name, '@'));
} else {
/** @var DocumentEnhancer $enhancer */
$enhancer = new $name();
}

if (! $enhancer instanceof DocumentEnhancer) {
throw new \InvalidArgumentException('Expecting DocumentEnhancer, got ' . get_debug_type($enhancer));
}

$connection->addDocumentEnhancer($enhancer);
}
}
Expand Down
12 changes: 12 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
"composer/xdebug-handler": {
"version": "1.4.3"
},
"doctrine/annotations": {
"version": "1.14",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.0",
"ref": "a2759dd6123694c8d901d0ec80006e044c2e6457"
},
"files": [
"config/routes/annotations.yaml"
]
},
"doctrine/instantiator": {
"version": "1.3.1"
},
Expand Down
Loading
Loading