From 2a27d940744a2a1075140e1e536d2121dcb125ee Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 22 Feb 2023 13:07:05 +0000 Subject: [PATCH 01/17] Allow CI to install older PHPUnit for legacy PHP --- .github/workflows/phpunit.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 7874e0d5..e376c6ee 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -10,14 +10,20 @@ jobs: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - # https://github.com/marketplace/actions/setup-php-action#tada-php-support - php-versions: - - '7.3' - - '7.4' - - '8.0' - - '8.1' - - '8.2' + include: + # https://github.com/marketplace/actions/setup-php-action#tada-php-support + - php-version: "7.3" + - php-version: "7.4" + - php-version: "8.0" + - php-version: "8.1" + - php-version: "8.2" + # TODO: for older PHP versions we want to explicitly state the PHPUnit version to be used + - php-version: "5.3" + - php-version: "5.4" + - php-version: "5.5" + - php-version: "5.6" steps: - name: Install s3cmd @@ -46,7 +52,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-versions }} + php-version: ${{ matrix.php-version }} - name: Get composer cache directory id: composer-cache-directory From bfc5e841ed78d94b16aa2cdb76d309bd3635621b Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 22 Feb 2023 13:14:48 +0000 Subject: [PATCH 02/17] Install a specific PHPUnit version (if provided) --- .github/workflows/phpunit.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index e376c6ee..d5fbd61e 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -20,10 +20,21 @@ jobs: - php-version: "8.1" - php-version: "8.2" # TODO: for older PHP versions we want to explicitly state the PHPUnit version to be used + # https://phpunit.de/supported-versions.html - php-version: "5.3" + phpunit: "4" - php-version: "5.4" + phpunit: "4" - php-version: "5.5" + phpunit: "4" - php-version: "5.6" + phpunit: "5" + - php-version: "7.0" + phpunit: "5" + - php-version: "7.1" + phpunit: "5" + - php-version: "7.2" + phpunit: "8" steps: - name: Install s3cmd @@ -67,7 +78,14 @@ jobs: restore-keys: | php-${{ matrix.php-versions }}-composer + - name: Install a specific PHPUnit version + if: ${{ matrix.phpunit }} + run: | + set -x + composer require --ignore-platform-req phpunit/phpunit^${{ matrix.phpunit }} + - name: Compose setup + if: ${{ matrix.phpunit }} == null run: | composer validate composer check-platform-reqs @@ -75,6 +93,7 @@ jobs: composer install --no-interaction --ignore-platform-req=php+ - name: Archive the project + if: matrix.php-versions == '8.0' run: | set -x composer archive --file archive From 113616324b3973da5a228e29fcaf1d36fbe3de8e Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 22 Feb 2023 13:17:00 +0000 Subject: [PATCH 03/17] composer require --ignore-platform-reqs --- .github/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index d5fbd61e..ced6105e 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -82,7 +82,7 @@ jobs: if: ${{ matrix.phpunit }} run: | set -x - composer require --ignore-platform-req phpunit/phpunit^${{ matrix.phpunit }} + composer require --ignore-platform-reqs phpunit/phpunit^${{ matrix.phpunit }} - name: Compose setup if: ${{ matrix.phpunit }} == null From fc3e2076d2e97675d6f5a2f90fbd999f742a13e4 Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 22 Feb 2023 13:19:36 +0000 Subject: [PATCH 04/17] composer require --ignore-platform-reqs phpunit/phpunit:${{ matrix.phpunit }} --- .github/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index ced6105e..8a10c7ad 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -82,7 +82,7 @@ jobs: if: ${{ matrix.phpunit }} run: | set -x - composer require --ignore-platform-reqs phpunit/phpunit^${{ matrix.phpunit }} + composer require --ignore-platform-reqs phpunit/phpunit:${{ matrix.phpunit }} - name: Compose setup if: ${{ matrix.phpunit }} == null From 0c5027392654aebfd73551afb1cc70461bc0f231 Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 22 Feb 2023 13:22:09 +0000 Subject: [PATCH 05/17] composer require --with-all-dependencies --- .github/workflows/phpunit.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 8a10c7ad..5d072e8d 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -82,7 +82,8 @@ jobs: if: ${{ matrix.phpunit }} run: | set -x - composer require --ignore-platform-reqs phpunit/phpunit:${{ matrix.phpunit }} + composer --version + composer require --dev --ignore-platform-reqs --with-all-dependencies phpunit/phpunit:${{ matrix.phpunit }} - name: Compose setup if: ${{ matrix.phpunit }} == null From 3b4b6f54d981264339ef3c739b74c1e18393cdd2 Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 22 Feb 2023 13:28:48 +0000 Subject: [PATCH 06/17] composer: provide semver constraint for PHPUnit composer require -W phpunit/phpunit:^5 will install v5.2.7 (the latest from a given major) --- .github/workflows/phpunit.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 5d072e8d..fb9fccd3 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -78,18 +78,22 @@ jobs: restore-keys: | php-${{ matrix.php-versions }}-composer + - name: Composer validation + if: matrix.php-versions == '8.0' + run: | + composer validate + composer check-platform-reqs + - name: Install a specific PHPUnit version if: ${{ matrix.phpunit }} run: | set -x composer --version - composer require --dev --ignore-platform-reqs --with-all-dependencies phpunit/phpunit:${{ matrix.phpunit }} + composer require --dev --ignore-platform-reqs --with-all-dependencies phpunit/phpunit:^${{ matrix.phpunit }} - - name: Compose setup - if: ${{ matrix.phpunit }} == null + - name: Install Composer dependencies + if: ${{ ! matrix.phpunit }} run: | - composer validate - composer check-platform-reqs # if a package requires php: ^7, then the option --ignore-platform-req=php+ would allow installing on PHP8 composer install --no-interaction --ignore-platform-req=php+ From 3f6b5f6efa9fffc5ac241b5e4bee25047477cdc7 Mon Sep 17 00:00:00 2001 From: macbre Date: Wed, 22 Feb 2023 13:56:34 +0000 Subject: [PATCH 07/17] testGetObjectInfo: make this code valid for PHP 7.0+ --- tests/S3Test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/S3Test.php b/tests/S3Test.php index 7ad97396..06923bcc 100644 --- a/tests/S3Test.php +++ b/tests/S3Test.php @@ -25,10 +25,10 @@ public function testGetBucket() { /** * @param string $uri - * @param ?int $expectedSize + * @param int|null $expectedSize * @dataProvider getObjectInfoProvider */ - public function testGetObjectInfo( string $uri, ?int $expectedSize ) { + public function testGetObjectInfo( string $uri, $expectedSize ) { $obj = S3::getObjectInfo( $this->s3Bucket, $uri ); if ($expectedSize === null) { From 6ba432a9e42813ec4cdbb31188370954dd358682 Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 22 Feb 2023 14:01:27 +0000 Subject: [PATCH 08/17] Generate and upload the coverage for PHP 8.0 only --- .github/workflows/phpunit.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index fb9fccd3..b6d87b03 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -5,7 +5,12 @@ on: pull_request: jobs: - test: + test: + env: + S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} + S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }} + S3_BUCKET: test.macbre.net + S3_REGION: eu-west-1 runs-on: ubuntu-latest @@ -105,19 +110,17 @@ jobs: tar -tvf archive.tar - name: Test the code - env: - S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} - S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }} - S3_BUCKET: test.macbre.net - S3_REGION: eu-west-1 - - run: | - composer run coverage + if: matrix.php-versions != '8.0' + run: composer run test - - name: Upload coverage results to Coveralls + - name: Report the code coverage and upload it to Coveralls if: matrix.php-versions == '8.0' env: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + set -x + + composer run coverage + composer global require php-coveralls/php-coveralls php-coveralls --coverage_clover=.coverage.xml --json_path=/tmp/coverage.json -v From 162e2701cef6a49732b522b635c38453a98a8bc5 Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 22 Feb 2023 14:05:12 +0000 Subject: [PATCH 09/17] Update phpunit.yml --- .github/workflows/phpunit.yml | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index b6d87b03..b536bc35 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -83,12 +83,6 @@ jobs: restore-keys: | php-${{ matrix.php-versions }}-composer - - name: Composer validation - if: matrix.php-versions == '8.0' - run: | - composer validate - composer check-platform-reqs - - name: Install a specific PHPUnit version if: ${{ matrix.phpunit }} run: | @@ -102,19 +96,28 @@ jobs: # if a package requires php: ^7, then the option --ignore-platform-req=php+ would allow installing on PHP8 composer install --no-interaction --ignore-platform-req=php+ + - name: Test the code + if: matrix.php-version != '8.0' + run: composer run test + + # + # PHP 8.0.x specific tasks follow + # - name: Archive the project - if: matrix.php-versions == '8.0' + if: matrix.php-version == '8.0' run: | set -x composer archive --file archive tar -tvf archive.tar - - name: Test the code - if: matrix.php-versions != '8.0' - run: composer run test + - name: Composer validation + if: matrix.php-version == '8.0' + run: | + composer validate + composer check-platform-reqs - name: Report the code coverage and upload it to Coveralls - if: matrix.php-versions == '8.0' + if: matrix.php-version == '8.0' env: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | From 634dce3b7c11811e178f38038debb8e4b277d3f2 Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 22 Feb 2023 14:16:07 +0000 Subject: [PATCH 10/17] Enable xdebug only for PHP 8.0 -> code coverage is run for that version --- .github/workflows/phpunit.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index b536bc35..5989bee7 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -22,6 +22,7 @@ jobs: - php-version: "7.3" - php-version: "7.4" - php-version: "8.0" + coverage: "xdebug" - php-version: "8.1" - php-version: "8.2" # TODO: for older PHP versions we want to explicitly state the PHPUnit version to be used @@ -65,10 +66,13 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Install PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} + # https://github.com/shivammathur/setup-php#signal_strength-coverage-support + coverage: ${{ matrix.coverage }} # enable xdebug only for PHP 8.0 -> code coverage is run for that version - name: Get composer cache directory id: composer-cache-directory From 98a81fa1efd3a51f954b46add662b2b74944a0f9 Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 22 Feb 2023 14:21:00 +0000 Subject: [PATCH 11/17] PHP 7.0: do not install xdebug as phpunit fails with the exit code 2 --- .github/workflows/phpunit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 5989bee7..106c62f9 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -37,6 +37,7 @@ jobs: phpunit: "5" - php-version: "7.0" phpunit: "5" + coverage: "none" # do not install xdebug as phpunit fails with the exit code 2 - php-version: "7.1" phpunit: "5" - php-version: "7.2" From f203adc7fb89053ea57fecfadc887ddcbd0161d2 Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 22 Feb 2023 14:27:12 +0000 Subject: [PATCH 12/17] PHPUnit: install a specific version without any dependencies from composer.json --- .github/workflows/phpunit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 106c62f9..c1d58871 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -92,6 +92,7 @@ jobs: if: ${{ matrix.phpunit }} run: | set -x + rm composer* composer --version composer require --dev --ignore-platform-reqs --with-all-dependencies phpunit/phpunit:^${{ matrix.phpunit }} From 45cb7abac6c2fcec51dd5610c857ce3cd04c1cdc Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 22 Feb 2023 14:29:54 +0000 Subject: [PATCH 13/17] Use composer exec to run PHPUnit --- .github/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index c1d58871..0c3209fb 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -104,7 +104,7 @@ jobs: - name: Test the code if: matrix.php-version != '8.0' - run: composer run test + run: composer exec phpunit -- -vvv --testdox # # PHP 8.0.x specific tasks follow From de0d846cb07a0bff12e559ce98447fd854e3e537 Mon Sep 17 00:00:00 2001 From: macbre Date: Wed, 22 Feb 2023 14:35:33 +0000 Subject: [PATCH 14/17] We can now state with confidence that PHP5.3+ is supported --- composer.json | 4 ++-- composer.lock | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 7ef909f2..dcd37c4a 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "elecena/amazon-s3-php-class", - "description": "A standalone Amazon S3 (REST) client for PHP 7.3+ using CURL that does not require PEAR.", + "description": "A standalone Amazon S3 (REST) client for PHP 5.3+ using CURL that does not require PEAR.", "type": "library", "homepage": "https://github.com/elecena/amazon-s3-php-class", "license": "BSD-2-Clause", @@ -15,7 +15,7 @@ } ], "require": { - "php": ">=7.3", + "php": ">=5.3", "ext-curl": "*", "ext-simplexml": "*" }, diff --git a/composer.lock b/composer.lock index fb2b8044..f7cf167b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e6430fd4fd3b675107e7e810bd4cc097", + "content-hash": "29eb968f0fce0432cd3a25efdc815ba1", "packages": [], "packages-dev": [ { @@ -2346,7 +2346,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.3", + "php": ">=5.3", "ext-curl": "*", "ext-simplexml": "*" }, From 7efc4efce17aa5134a252a95640a68d799019858 Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 22 Feb 2023 14:36:28 +0000 Subject: [PATCH 15/17] composer run test --- .github/workflows/phpunit.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 0c3209fb..106c62f9 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -92,7 +92,6 @@ jobs: if: ${{ matrix.phpunit }} run: | set -x - rm composer* composer --version composer require --dev --ignore-platform-reqs --with-all-dependencies phpunit/phpunit:^${{ matrix.phpunit }} @@ -104,7 +103,7 @@ jobs: - name: Test the code if: matrix.php-version != '8.0' - run: composer exec phpunit -- -vvv --testdox + run: composer run test # # PHP 8.0.x specific tasks follow From 50cda37564c0b2627f4ca03377c8053f337f9f4a Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 22 Feb 2023 14:40:58 +0000 Subject: [PATCH 16/17] composer require --update-with-all-dependencies --- .github/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 106c62f9..6eff6e54 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -93,7 +93,7 @@ jobs: run: | set -x composer --version - composer require --dev --ignore-platform-reqs --with-all-dependencies phpunit/phpunit:^${{ matrix.phpunit }} + composer require --dev --ignore-platform-reqs --update-with-all-dependencies phpunit/phpunit:^${{ matrix.phpunit }} - name: Install Composer dependencies if: ${{ ! matrix.phpunit }} From c89626c438c2563678ccd7f4ed5dc035f028d985 Mon Sep 17 00:00:00 2001 From: Maciej Brencz Date: Wed, 22 Feb 2023 14:48:06 +0000 Subject: [PATCH 17/17] Downgrade guzzlehttp/guzzle when forcing an older PHPUnit Should fix PHP Parse error: syntax error, unexpected ':', expecting '{' in /home/runner/work/amazon-s3-php-class/amazon-s3-php-class/vendor/symfony/deprecation-contracts/function.php on line 23 --- .github/workflows/phpunit.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 6eff6e54..16bb9d28 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -93,7 +93,11 @@ jobs: run: | set -x composer --version - composer require --dev --ignore-platform-reqs --update-with-all-dependencies phpunit/phpunit:^${{ matrix.phpunit }} + + # https://packagist.org/packages/guzzlehttp/guzzle#v3.8.1 + composer require --dev --ignore-platform-reqs --update-with-all-dependencies \ + phpunit/phpunit:^${{ matrix.phpunit }} \ + guzzlehttp/guzzle:v3.8.1 - name: Install Composer dependencies if: ${{ ! matrix.phpunit }}