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

Allow CI to install older PHPUnit for legacy PHP #43

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 15 commits
Commits
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
85 changes: 63 additions & 22 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,43 @@ 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

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"
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
# 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"
coverage: "none" # do not install xdebug as phpunit fails with the exit code 2
- php-version: "7.1"
phpunit: "5"
- php-version: "7.2"
phpunit: "8"

steps:
- name: Install s3cmd
Expand All @@ -43,10 +67,13 @@ jobs:

- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
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
Expand All @@ -61,33 +88,47 @@ jobs:
restore-keys: |
php-${{ matrix.php-versions }}-composer

- name: Compose setup
- 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 }}

- 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+

- 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-version == '8.0'
run: |
set -x
composer archive --file archive
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

- name: Composer validation
if: matrix.php-version == '8.0'
run: |
composer run coverage
composer validate
composer check-platform-reqs

- name: Upload coverage results to Coveralls
if: matrix.php-versions == '8.0'
- name: Report the code coverage and upload it to Coveralls
if: matrix.php-version == '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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -15,7 +15,7 @@
}
],
"require": {
"php": ">=7.3",
"php": ">=5.3",
"ext-curl": "*",
"ext-simplexml": "*"
},
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/S3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down