From 93e9c2fa5fa1eea177a16b322bc6dbcff681ece5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Desv=C3=A9?= Date: Fri, 24 May 2024 17:33:08 +0200 Subject: [PATCH 1/6] Run CI on multiple PHP versions --- .../workflows/{code-coverage.yaml => ci.yml} | 27 +++++++++----- .github/workflows/php.yml | 36 ------------------- README.md | 2 +- composer.json | 2 +- 4 files changed, 20 insertions(+), 47 deletions(-) rename .github/workflows/{code-coverage.yaml => ci.yml} (68%) delete mode 100644 .github/workflows/php.yml diff --git a/.github/workflows/code-coverage.yaml b/.github/workflows/ci.yml similarity index 68% rename from .github/workflows/code-coverage.yaml rename to .github/workflows/ci.yml index 52f60816..4a354fbf 100644 --- a/.github/workflows/code-coverage.yaml +++ b/.github/workflows/ci.yml @@ -1,18 +1,27 @@ -name: PHPUnit Coverage Report +name: Continuous integration on: + workflow_dispatch: ~ push: - branches: [develop, main] + branches: + - develop + - main pull_request: - branches: [develop, main] - workflow_dispatch: ~ + branches: + - develop + - main jobs: ci: + name: Linting, tests and coverage runs-on: ubuntu-22.04 - defaults: - run: - working-directory: ./ + + strategy: + matrix: + php-version: + - 8.1 + - 8.2 + - 8.3 steps: - uses: actions/checkout@v4 @@ -20,8 +29,8 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 5.6 - tools: composer:v1 + php-version: ${{ matrix.php-version }} + tools: composer:v2 - name: Validate composer.json and composer.lock run: composer validate diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml deleted file mode 100644 index 6e1e7b46..00000000 --- a/.github/workflows/php.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: PHP Lint and unit tests - -on: - push: - branches: [main] - pull_request: - branches: [main] - workflow_dispatch: ~ - -jobs: - ci: - runs-on: ubuntu-22.04 - defaults: - run: - working-directory: ./ - - steps: - - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 5.6 - tools: composer:v1 - - - name: Validate composer.json and composer.lock - run: composer validate - - - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-suggest - - - name: Ensure source code is linted - run: ./vendor/bin/phpcs src - - - name: Ensure unit test are green - run: ./vendor/bin/phpunit -c phpunit.ci.xml diff --git a/README.md b/README.md index 77609ddb..eea3d897 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you find yourself needing to use some endpoints that are not yet implemented, Installation ------------ -The Alma PHP API Client library requires at least PHP 5.6. +The Alma PHP API Client library is tested against all recently supported PHP versions. A modern, [supported PHP version](https://www.php.net/supported-versions.php) is highly recommended. ### Composer diff --git a/composer.json b/composer.json index c6434a71..060c58bc 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "version": "2.0.7", "type": "library", "require": { - "php": "^5.6 || ~7.0 || ~7.1 || ~7.2 || ~7.3 || ~7.4 || ~8.0 || ~8.1 || ~8.2", + "php": "^5.6 || ~7.0 || ~7.1 || ~7.2 || ~7.3 || ~7.4 || ~8.0 || ~8.1 || ~8.2 || ~8.3", "psr/log": "^1 || ^2 || ^3", "ext-curl": "*", "ext-json": "*", From d8b34f9e66169ed4d14505e05c300b2ca1a31baf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Desv=C3=A9?= Date: Fri, 24 May 2024 17:35:36 +0200 Subject: [PATCH 2/6] Remove fail-fast strategy --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a354fbf..35563ca2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,7 @@ jobs: runs-on: ubuntu-22.04 strategy: + fail-fast: false matrix: php-version: - 8.1 From 492da72db27b292c4a74dc6f2ecdac57518cd0ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Desv=C3=A9?= Date: Fri, 24 May 2024 17:38:08 +0200 Subject: [PATCH 3/6] Add more PHP versions --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35563ca2..b0131c16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,13 @@ jobs: fail-fast: false matrix: php-version: + - 5.6 + - 7.0 + - 7.1 + - 7.2 + - 7.3 + - 7.4 + - 8.0 - 8.1 - 8.2 - 8.3 From 944767af850bec3989ab31d3fc235bf018e8973b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Desv=C3=A9?= Date: Fri, 24 May 2024 17:52:33 +0200 Subject: [PATCH 4/6] Setup configuration file depending on the PHP version used --- .github/workflows/ci.yml | 52 ++++++++++++++++++++++++++++++---------- phpunit.dist.legacy.xml | 4 ++-- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0131c16..44151b4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,25 +19,48 @@ jobs: strategy: fail-fast: false matrix: - php-version: - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - 7.3 - - 7.4 - - 8.0 - - 8.1 - - 8.2 - - 8.3 + php: + - version: 5.6 + unittest-version: Legacy + xml-file: phpunit.dist.legacy.xml + - version: 7.0 + unittest-version: PHP7_0 + xml-file: phpunit.dist.legacy.xml + - version: 7.1 + unittest-version: PHP7_0 + xml-file: phpunit.dist.legacy.xml + - version: 7.2 + unittest-version: PHP7_2 + xml-file: phpunit.dist.legacy.xml + - version: 7.3 + unittest-version: PHP7_2 + xml-file: phpunit.dist.legacy.xml + - version: 7.4 + unittest-version: PHP7_2 + xml-file: phpunit.dist.legacy.xml + - version: 8.0 + unittest-version: PHP7_2 + xml-file: phpunit.dist.legacy.xml + - version: 8.1 + unittest-version: PHP8_1 + xml-file: phpunit.dist.xml + - version: 8.2 + unittest-version: PHP8_1 + xml-file: phpunit.dist.xml + - version: 8.3 + unittest-version: PHP8_1 + xml-file: phpunit.dist.xml steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: false - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-version }} + php-version: ${{ matrix.php.version }} tools: composer:v2 - name: Validate composer.json and composer.lock @@ -46,6 +69,9 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-progress --no-suggest + - name: Prepare unittests configuration + run: sed 's/{MYVERSION}/${{ matrix.php.unittest-version }}/g' ${{ matrix.php.xml-file }} > phpunit.xml + - name: Ensure source code is linted run: ./vendor/bin/phpcs src diff --git a/phpunit.dist.legacy.xml b/phpunit.dist.legacy.xml index c8b23594..d8303b8b 100644 --- a/phpunit.dist.legacy.xml +++ b/phpunit.dist.legacy.xml @@ -13,10 +13,10 @@ - tests/Unit/{MYVERSION} + tests/Unit/PHP7_2 - tests/Integration/{MYVERSION} + tests/Integration/PHP7_2 From b04390e933e6d26219b0644dc732d7b4ef32fd18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Desv=C3=A9?= Date: Fri, 24 May 2024 18:00:22 +0200 Subject: [PATCH 5/6] Use proper ci phpunit xml file --- .github/workflows/ci.yml | 12 +----------- phpunit.ci.xml | 4 ++-- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44151b4a..e650bc94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,34 +22,24 @@ jobs: php: - version: 5.6 unittest-version: Legacy - xml-file: phpunit.dist.legacy.xml - version: 7.0 unittest-version: PHP7_0 - xml-file: phpunit.dist.legacy.xml - version: 7.1 unittest-version: PHP7_0 - xml-file: phpunit.dist.legacy.xml - version: 7.2 unittest-version: PHP7_2 - xml-file: phpunit.dist.legacy.xml - version: 7.3 unittest-version: PHP7_2 - xml-file: phpunit.dist.legacy.xml - version: 7.4 unittest-version: PHP7_2 - xml-file: phpunit.dist.legacy.xml - version: 8.0 unittest-version: PHP7_2 - xml-file: phpunit.dist.legacy.xml - version: 8.1 unittest-version: PHP8_1 - xml-file: phpunit.dist.xml - version: 8.2 unittest-version: PHP8_1 - xml-file: phpunit.dist.xml - version: 8.3 unittest-version: PHP8_1 - xml-file: phpunit.dist.xml steps: - name: Checkout repository @@ -70,7 +60,7 @@ jobs: run: composer install --prefer-dist --no-progress --no-suggest - name: Prepare unittests configuration - run: sed 's/{MYVERSION}/${{ matrix.php.unittest-version }}/g' ${{ matrix.php.xml-file }} > phpunit.xml + run: sed -i 's/{MYVERSION}/${{ matrix.php.unittest-version }}/g' phpunit.ci.xml - name: Ensure source code is linted run: ./vendor/bin/phpcs src diff --git a/phpunit.ci.xml b/phpunit.ci.xml index 9e3d4842..891c8802 100644 --- a/phpunit.ci.xml +++ b/phpunit.ci.xml @@ -11,8 +11,8 @@ stopOnFailure = "true"> - - tests/Unit/Legacy + + tests/Unit/{MYVERSION} From 27485a2572f85267c5db73d13eec6972d1d6e834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Desv=C3=A9?= Date: Mon, 27 May 2024 14:04:10 +0200 Subject: [PATCH 6/6] Revert change in phpunit.dist.legacy.xml --- phpunit.dist.legacy.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit.dist.legacy.xml b/phpunit.dist.legacy.xml index d8303b8b..c8b23594 100644 --- a/phpunit.dist.legacy.xml +++ b/phpunit.dist.legacy.xml @@ -13,10 +13,10 @@ - tests/Unit/PHP7_2 + tests/Unit/{MYVERSION} - tests/Integration/PHP7_2 + tests/Integration/{MYVERSION}