From 3815d0e6cc564fce1177ddb145f722972a4214e6 Mon Sep 17 00:00:00 2001 From: Tomas Norre Mikkelsen Date: Mon, 4 Mar 2024 09:33:33 +0100 Subject: [PATCH 1/5] CI Add PHPUnit 10 and PHP 8.3 --- .../workflows/exercise-tests-phpunit-10.yml | 45 +++++++++++++++++++ composer.json | 4 +- 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/exercise-tests-phpunit-10.yml diff --git a/.github/workflows/exercise-tests-phpunit-10.yml b/.github/workflows/exercise-tests-phpunit-10.yml new file mode 100644 index 00000000..46460e80 --- /dev/null +++ b/.github/workflows/exercise-tests-phpunit-10.yml @@ -0,0 +1,45 @@ +name: Exercise tests with PHPUnit 10 + +on: + workflow_dispatch: + push: + branches: + - main + - master + pull_request: + +jobs: + test: + name: PHP ${{ matrix.php-version }} - ${{ matrix.os }} - ${{ github.event_name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + php-version: [8.1, 8.2, 8.3] + os: [ubuntu-22.04, windows-2022, macOS-12] + + steps: + - name: Set git line endings + if: ${{ matrix.os == 'windows-2022' }} + run: | + git config --system core.autocrlf false + git config --system core.eol lf + + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + + - uses: shivammathur/setup-php@6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d + with: + php-version: ${{ matrix.php-version }} + extensions: gmp + + - name: Install dependencies + shell: bash + run: | + curl -Lo ./bin/phpunit-10.phar https://phar.phpunit.de/phpunit-10.phar + chmod +x bin/phpunit-10.phar + + - name: Test exercises\ + shell: bash + env: + PHPUNIT_BIN: 'bin/phpunit-10.phar' + run: bin/test.sh diff --git a/composer.json b/composer.json index 38dd195f..6ffb0f8e 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,8 @@ } }, "require-dev": { - "php": "^7.4|^8.0", - "phpunit/phpunit": "^9.6", + "php": "^8.0", + "phpunit/phpunit": "^9.6 || ^10.5", "slevomat/coding-standard": "^8.14.1", "squizlabs/php_codesniffer": "^3.9" }, From f1a56f9619bf51987f258f14e8d71fd99a40146e Mon Sep 17 00:00:00 2001 From: Tomas Norre Mikkelsen Date: Mon, 4 Mar 2024 09:58:39 +0100 Subject: [PATCH 2/5] Make dataproviders static --- exercises/practice/allergies/AllergiesTest.php | 2 +- exercises/practice/binary/BinaryTest.php | 2 +- exercises/practice/gigasecond/GigasecondTest.php | 4 ++-- .../practice/protein-translation/ProteinTranslationTest.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/practice/allergies/AllergiesTest.php b/exercises/practice/allergies/AllergiesTest.php index 7c5ebad7..4189d33a 100644 --- a/exercises/practice/allergies/AllergiesTest.php +++ b/exercises/practice/allergies/AllergiesTest.php @@ -62,7 +62,7 @@ public function testAllergiesToOneAllergen($allergicTo): void }, $otherAllergen); } - public function provideListOfAllergen(): array + public static function provideListOfAllergen(): array { require_once 'Allergies.php'; diff --git a/exercises/practice/binary/BinaryTest.php b/exercises/practice/binary/BinaryTest.php index a9ddf7dc..ae7311ff 100644 --- a/exercises/practice/binary/BinaryTest.php +++ b/exercises/practice/binary/BinaryTest.php @@ -82,7 +82,7 @@ public function testItOnlyAcceptsStringsContainingZerosAndOnes($value): void parse_binary($value); } - public function invalidValues(): array + public static function invalidValues(): array { return [ ['2'], ['12345'], ['a'], ['0abcdef'], diff --git a/exercises/practice/gigasecond/GigasecondTest.php b/exercises/practice/gigasecond/GigasecondTest.php index 6f2bee16..4bfdee03 100644 --- a/exercises/practice/gigasecond/GigasecondTest.php +++ b/exercises/practice/gigasecond/GigasecondTest.php @@ -37,7 +37,7 @@ public function dateSetup($date): DateTimeImmutable return new DateTimeImmutable($date, $UTC); } - public function inputAndExpectedDates(): array + public static function inputAndExpectedDates(): array { return [ ['2011-04-25', '2043-01-01 01:46:40'], @@ -48,7 +48,7 @@ public function inputAndExpectedDates(): array ]; } - public function inputDates(): array + public static function inputDates(): array { return [ ['2011-04-25'], diff --git a/exercises/practice/protein-translation/ProteinTranslationTest.php b/exercises/practice/protein-translation/ProteinTranslationTest.php index d5452d30..f53799e1 100644 --- a/exercises/practice/protein-translation/ProteinTranslationTest.php +++ b/exercises/practice/protein-translation/ProteinTranslationTest.php @@ -174,7 +174,7 @@ public function testTranslationStopsIfStopCodonInMiddleOfSixCodonSequence(): voi ); } - public function invalidCodonDataProvider(): array + public static function invalidCodonDataProvider(): array { return [ 'Non-existing' => ['AAA'], From 613d07d2263595414718d7eab437c39b184f2934 Mon Sep 17 00:00:00 2001 From: Tomas Norre Mikkelsen Date: Mon, 4 Mar 2024 10:07:06 +0100 Subject: [PATCH 3/5] Update after comments - iteration 1 --- .github/workflows/exercise-tests-phpunit-10.yml | 7 +++++-- composer.json | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/exercise-tests-phpunit-10.yml b/.github/workflows/exercise-tests-phpunit-10.yml index 46460e80..523f14a3 100644 --- a/.github/workflows/exercise-tests-phpunit-10.yml +++ b/.github/workflows/exercise-tests-phpunit-10.yml @@ -12,11 +12,14 @@ jobs: test: name: PHP ${{ matrix.php-version }} - ${{ matrix.os }} - ${{ github.event_name }} runs-on: ${{ matrix.os }} + continue-on-error: true strategy: fail-fast: false matrix: - php-version: [8.1, 8.2, 8.3] - os: [ubuntu-22.04, windows-2022, macOS-12] + #php-version: [8.1, 8.2, 8.3] + php-version: [8.3] + #os: [ubuntu-22.04, windows-2022, macOS-12] + os: [ubuntu-22.04] steps: - name: Set git line endings diff --git a/composer.json b/composer.json index 6ffb0f8e..97f5ea4d 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } }, "require-dev": { - "php": "^8.0", + "php": "^7.4 || ^8.0", "phpunit/phpunit": "^9.6 || ^10.5", "slevomat/coding-standard": "^8.14.1", "squizlabs/php_codesniffer": "^3.9" From 55954e72ac4cdf3b9652dd6d96acf42618b55a12 Mon Sep 17 00:00:00 2001 From: Tomas Norre Mikkelsen Date: Mon, 4 Mar 2024 10:36:34 +0100 Subject: [PATCH 4/5] Adjust to feedback from review - Iteration 2 --- .github/workflows/exercise-tests-phpunit-10.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/exercise-tests-phpunit-10.yml b/.github/workflows/exercise-tests-phpunit-10.yml index 523f14a3..257876e2 100644 --- a/.github/workflows/exercise-tests-phpunit-10.yml +++ b/.github/workflows/exercise-tests-phpunit-10.yml @@ -5,14 +5,12 @@ on: push: branches: - main - - master pull_request: jobs: test: name: PHP ${{ matrix.php-version }} - ${{ matrix.os }} - ${{ github.event_name }} runs-on: ${{ matrix.os }} - continue-on-error: true strategy: fail-fast: false matrix: @@ -41,7 +39,8 @@ jobs: curl -Lo ./bin/phpunit-10.phar https://phar.phpunit.de/phpunit-10.phar chmod +x bin/phpunit-10.phar - - name: Test exercises\ + - name: Test exercises + continue-on-error: true shell: bash env: PHPUNIT_BIN: 'bin/phpunit-10.phar' From 054b5fa1e5f6d9383040aef3b21bdc92a2241983 Mon Sep 17 00:00:00 2001 From: Tomas Norre Mikkelsen Date: Mon, 4 Mar 2024 10:38:04 +0100 Subject: [PATCH 5/5] Disable XDEBUG in testing --- .github/workflows/exercise-tests-phpunit-10.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/exercise-tests-phpunit-10.yml b/.github/workflows/exercise-tests-phpunit-10.yml index 257876e2..65658fcf 100644 --- a/.github/workflows/exercise-tests-phpunit-10.yml +++ b/.github/workflows/exercise-tests-phpunit-10.yml @@ -44,4 +44,5 @@ jobs: shell: bash env: PHPUNIT_BIN: 'bin/phpunit-10.phar' + XDEBUG_MODE: off run: bin/test.sh