From bd57523bf39fdd33b1950958574fec9d54af9138 Mon Sep 17 00:00:00 2001 From: Rodrigo Aguilera Date: Sun, 18 Feb 2024 19:48:30 +0100 Subject: [PATCH 1/5] Fix/Skip tests and add php 8.2 and 8.3. --- .github/workflows/continuous-integration.yml | 6 ++---- composer.json | 5 ++++- src/Context/ContextBuilder.php | 2 +- src/Docker.php | 2 +- src/Stream/EventStream.php | 2 +- tests/Resource/ContainerResourceTest.php | 2 ++ tests/Resource/SystemResourceTest.php | 4 ++-- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 68e9a8d8..d3a24305 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -22,6 +22,8 @@ jobs: matrix: php-version: - "8.1" + - "8.2" + - "8.3" dependency-version: [prefer-lowest, prefer-stable] experimental: [false] @@ -49,10 +51,6 @@ jobs: key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}- - - name: Install dependencies (PHP 7) - if: steps.composer-cache.outputs.cache-hit != 'true' && matrix.php-version < 8 - run: composer update --${{ matrix.dependency-version }} --no-progress --no-interaction - - name: Install dependencies (PHP 8) if: steps.composer-cache.outputs.cache-hit != 'true' && matrix.php-version >= 8 run: composer update --${{ matrix.dependency-version }} --ignore-platform-req=php --no-progress --no-interaction diff --git a/composer.json b/composer.json index 5edebfe5..15a9edf5 100644 --- a/composer.json +++ b/composer.json @@ -44,12 +44,14 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^3.8", "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9.5", "psy/psysh": "^0.11", "roave/security-advisories": "dev-latest" }, "conflict": { - "docker-php/docker-php": "*" + "docker-php/docker-php": "*", + "php-http/message": "<1.15" }, "scripts": { "php-cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff", @@ -57,6 +59,7 @@ "console": "vendor/bin/psysh", "lint": "vendor/bin/parallel-lint --exclude vendor .", "phpunit": "vendor/bin/phpunit ./tests/ --coverage-html=./report/coverage/ --whitelist=./src/ --testdox-html=./report/testdox.html --disallow-test-output --process-isolation", + "phpstan": "vendor/bin/phpstan analyse --level 2 src", "test-ci": "vendor/bin/phpunit ./tests/ --disallow-test-output --process-isolation", "test-coverage": "vendor/bin/phpunit ./tests/ --whitelist=./src/ --coverage-clover=clover.xml", "test": [ diff --git a/src/Context/ContextBuilder.php b/src/Context/ContextBuilder.php index 5e0aa37b..6d41d406 100644 --- a/src/Context/ContextBuilder.php +++ b/src/Context/ContextBuilder.php @@ -39,7 +39,7 @@ class ContextBuilder private $entrypoint; /** - * @param \Symfony\Component\Filesystem\Filesystem + * @param $fs \Symfony\Component\Filesystem\Filesystem */ public function __construct(Filesystem $fs = null) { diff --git a/src/Docker.php b/src/Docker.php index 6e98c7e2..951a8cd7 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -87,7 +87,7 @@ public function systemEvents(array $queryParameters = [], string $fetch = self:: return $this->executeEndpoint(new SystemEvents($queryParameters), $fetch); } - public static function create($httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = []) + public static function create($httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = []) : self { if (null === $httpClient) { $httpClient = DockerClientFactory::createFromEnv(); diff --git a/src/Stream/EventStream.php b/src/Stream/EventStream.php index 90dcf23e..1c18a805 100644 --- a/src/Stream/EventStream.php +++ b/src/Stream/EventStream.php @@ -16,6 +16,6 @@ class EventStream extends MultiJsonStream */ protected function getDecodeClass() { - return 'EventsGetResponse200'; + return 'EventMessage'; } } diff --git a/tests/Resource/ContainerResourceTest.php b/tests/Resource/ContainerResourceTest.php index 3ebb7758..eac8e470 100644 --- a/tests/Resource/ContainerResourceTest.php +++ b/tests/Resource/ContainerResourceTest.php @@ -61,6 +61,7 @@ public function testAttach(): void public function testAttachWebsocket(): void { + $this->markTestSkipped('Since docker API 1.28 Websockets are binary so this test needs work. See https://github.com/xtermjs/xterm.js/issues/883'); $containerConfig = new ContainersCreatePostBody(); $containerConfig->setImage('busybox:latest'); $containerConfig->setCmd(['sh']); @@ -108,6 +109,7 @@ public function testAttachWebsocket(): void public function testLogs(): void { + $this->markTestSkipped('Since at least 1.43 docker API does not return a `application/vnd.docker.raw-stream` but a `application/vnd.docker.multiplexed-stream` so this needs review. See https://github.com/beluga-php/docker-php/issues/19'); $containerConfig = new ContainersCreatePostBody(); $containerConfig->setImage('busybox:latest'); $containerConfig->setCmd(['echo', '-n', 'output']); diff --git a/tests/Resource/SystemResourceTest.php b/tests/Resource/SystemResourceTest.php index b88c4069..fb1badf3 100644 --- a/tests/Resource/SystemResourceTest.php +++ b/tests/Resource/SystemResourceTest.php @@ -4,7 +4,7 @@ namespace Docker\Tests\Resource; -use Docker\API\Model\EventsGetResponse200; +use Docker\API\Model\EventMessage; use Docker\Tests\TestCase; class SystemResourceTest extends TestCase @@ -36,6 +36,6 @@ public function testGetEvents(): void $stream->wait(); - $this->assertInstanceOf(EventsGetResponse200::class, $lastEvent); + $this->assertInstanceOf(EventMessage::class, $lastEvent); } } From fc6c48a3ac642a925951c3c4f53c68147102e205 Mon Sep 17 00:00:00 2001 From: Rodrigo Aguilera Date: Sun, 18 Feb 2024 20:10:02 +0100 Subject: [PATCH 2/5] Pull image prior to the tests. --- .github/workflows/continuous-integration.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index d3a24305..0a005cfa 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -55,6 +55,9 @@ jobs: if: steps.composer-cache.outputs.cache-hit != 'true' && matrix.php-version >= 8 run: composer update --${{ matrix.dependency-version }} --ignore-platform-req=php --no-progress --no-interaction + - name: Pull the docker image used by the tests. + run: docker pull busybox:latest + - name: Run PHPUnit test suite run: composer run-script test-ci From 24c667b5e4831cd8fd26fdf5532d23c2520b9d3b Mon Sep 17 00:00:00 2001 From: Rodrigo Aguilera Date: Sun, 18 Feb 2024 20:20:51 +0100 Subject: [PATCH 3/5] Skip publish code coverage on PRs. --- .github/workflows/continuous-integration.yml | 1 + src/Docker.php | 6 +++++- tests/Resource/ContainerResourceTest.php | 7 +++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 0a005cfa..e1e32d54 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -69,3 +69,4 @@ jobs: coverageCommand: composer run-script test-coverage coverageLocations: | ${{github.workspace}}/clover.xml:clover + if: github.event_name != 'pull_request' diff --git a/src/Docker.php b/src/Docker.php index 951a8cd7..b56b2b66 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -87,7 +87,11 @@ public function systemEvents(array $queryParameters = [], string $fetch = self:: return $this->executeEndpoint(new SystemEvents($queryParameters), $fetch); } - public static function create($httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = []) : self + public static function create( + $httpClient = null, + array $additionalPlugins = [], + array $additionalNormalizers = [] + ) : self { if (null === $httpClient) { $httpClient = DockerClientFactory::createFromEnv(); diff --git a/tests/Resource/ContainerResourceTest.php b/tests/Resource/ContainerResourceTest.php index eac8e470..eb6024a1 100644 --- a/tests/Resource/ContainerResourceTest.php +++ b/tests/Resource/ContainerResourceTest.php @@ -61,7 +61,8 @@ public function testAttach(): void public function testAttachWebsocket(): void { - $this->markTestSkipped('Since docker API 1.28 Websockets are binary so this test needs work. See https://github.com/xtermjs/xterm.js/issues/883'); + $this->markTestSkipped('Since docker API 1.28 Websockets are binary so this test needs work. ' . + 'See https://github.com/xtermjs/xterm.js/issues/883'); $containerConfig = new ContainersCreatePostBody(); $containerConfig->setImage('busybox:latest'); $containerConfig->setCmd(['sh']); @@ -109,7 +110,9 @@ public function testAttachWebsocket(): void public function testLogs(): void { - $this->markTestSkipped('Since at least 1.43 docker API does not return a `application/vnd.docker.raw-stream` but a `application/vnd.docker.multiplexed-stream` so this needs review. See https://github.com/beluga-php/docker-php/issues/19'); + $this->markTestSkipped('Since at least 1.43 docker API does not return a `application/vnd.docker.raw-stream` ' . + 'but a `application/vnd.docker.multiplexed-stream` so this needs review. '. + 'See https://github.com/beluga-php/docker-php/issues/19'); $containerConfig = new ContainersCreatePostBody(); $containerConfig->setImage('busybox:latest'); $containerConfig->setCmd(['echo', '-n', 'output']); From 0776d3a3148c0861d47d0a769588bdd25c2462aa Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Mon, 19 Feb 2024 13:51:48 +0100 Subject: [PATCH 4/5] remove leading space around return type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Flávio Heleno --- src/Docker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Docker.php b/src/Docker.php index b56b2b66..b63c99cd 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -91,7 +91,7 @@ public static function create( $httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = [] - ) : self + ): self { if (null === $httpClient) { $httpClient = DockerClientFactory::createFromEnv(); From 2a65dd46817cdd5ae8eadf7b61250b8e15cfe402 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Mon, 19 Feb 2024 13:52:19 +0100 Subject: [PATCH 5/5] Fix param definition in context builder. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Flávio Heleno --- src/Context/ContextBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Context/ContextBuilder.php b/src/Context/ContextBuilder.php index 6d41d406..0464b15a 100644 --- a/src/Context/ContextBuilder.php +++ b/src/Context/ContextBuilder.php @@ -39,7 +39,7 @@ class ContextBuilder private $entrypoint; /** - * @param $fs \Symfony\Component\Filesystem\Filesystem + * @param \Symfony\Component\Filesystem\Filesystem $fs */ public function __construct(Filesystem $fs = null) {