From 7b21ef508fa36e6f3fee81bcc9aa7f60f5fef7b8 Mon Sep 17 00:00:00 2001 From: Davide Pastore Date: Wed, 29 Dec 2021 17:37:35 +0100 Subject: [PATCH 1/9] Add first CI workflow --- .github/workflows/continuous-integration.yml | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/continuous-integration.yml diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..8a1e9a0 --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,35 @@ +name: Continuous Integration + +on: [push, pull_request] + +jobs: + quality: + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: [ubuntu-latest] + # TODO Add 8.0 and 8.1 versions as well + php-versions: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] + name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + + - name: Check PHP Version + run: php -v + + - name: Install dependencies + run: composer install --no-interaction --no-progress --no-suggest --prefer-dist + + - name: PHP Unit tests + run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover + + - name: Upload code coverage data + if: ${{ matrix.php-versions }} == '7.3' + run: php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover \ No newline at end of file From 39caf3d3e0537690fafaef833e8569f7790bb360 Mon Sep 17 00:00:00 2001 From: Davide Pastore Date: Wed, 29 Dec 2021 17:56:22 +0100 Subject: [PATCH 2/9] Remove no-suggest argument --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 8a1e9a0..a038a06 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -25,7 +25,7 @@ jobs: run: php -v - name: Install dependencies - run: composer install --no-interaction --no-progress --no-suggest --prefer-dist + run: composer install --no-interaction --no-progress --prefer-dist - name: PHP Unit tests run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover From cbce163385ca846d8f590866219e9ca6cf1a87f4 Mon Sep 17 00:00:00 2001 From: Davide Pastore Date: Wed, 29 Dec 2021 18:07:05 +0100 Subject: [PATCH 3/9] Add specific test for PHP >= 7.4 --- tests/Parser/IniTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Parser/IniTest.php b/tests/Parser/IniTest.php index 4801a2e..0c616d0 100644 --- a/tests/Parser/IniTest.php +++ b/tests/Parser/IniTest.php @@ -59,12 +59,25 @@ public function testLoadInvalidIniGBH() * @covers Noodlehaus\Parser\Ini::parse() * @expectedException Noodlehaus\Exception\ParseException * @expectedExceptionMessage syntax error, unexpected $end, expecting ']' + * @requires PHP < 7.4 */ public function testLoadInvalidIni() { $this->ini->parseString(file_get_contents(__DIR__ . '/../mocks/fail/error.ini')); } + /** + * @covers Noodlehaus\Parser\Ini::parseString() + * @covers Noodlehaus\Parser\Ini::parse() + * @expectedException Noodlehaus\Exception\ParseException + * @expectedExceptionMessage syntax error, unexpected end of file, expecting ']' in Unknown on line 1 + * @requires PHP >= 7.4 + */ + public function testLoadInvalidIniForPhp74() + { + $this->ini->parseString(file_get_contents(__DIR__ . '/../mocks/fail/error.ini')); + } + /** * @covers Noodlehaus\Parser\Ini::parseFile() * @covers Noodlehaus\Parser\Ini::parseString() From 2f489ce008a46b03d658c02452e1e3714d858e92 Mon Sep 17 00:00:00 2001 From: Davide Pastore Date: Wed, 29 Dec 2021 21:42:26 +0100 Subject: [PATCH 4/9] Experiment adding condition based on PHP version --- tests/Parser/IniTest.php | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/tests/Parser/IniTest.php b/tests/Parser/IniTest.php index 0c616d0..cae6e95 100644 --- a/tests/Parser/IniTest.php +++ b/tests/Parser/IniTest.php @@ -57,24 +57,16 @@ public function testLoadInvalidIniGBH() /** * @covers Noodlehaus\Parser\Ini::parseString() * @covers Noodlehaus\Parser\Ini::parse() - * @expectedException Noodlehaus\Exception\ParseException - * @expectedExceptionMessage syntax error, unexpected $end, expecting ']' - * @requires PHP < 7.4 */ public function testLoadInvalidIni() { - $this->ini->parseString(file_get_contents(__DIR__ . '/../mocks/fail/error.ini')); - } - - /** - * @covers Noodlehaus\Parser\Ini::parseString() - * @covers Noodlehaus\Parser\Ini::parse() - * @expectedException Noodlehaus\Exception\ParseException - * @expectedExceptionMessage syntax error, unexpected end of file, expecting ']' in Unknown on line 1 - * @requires PHP >= 7.4 - */ - public function testLoadInvalidIniForPhp74() - { + if (PHP_VERSION_ID < 70400 && PHP_VERSION_ID >= 50500) { + $this->expectException(\Noodlehaus\Exception\ParseException::class); + $this->expectExceptionMessage("syntax error, unexpected \$end, expecting ']'"); + } else { + $this->expectExceptionMessage("syntax error, unexpected end of file, expecting ']' in Unknown on line 1"); + } + $this->ini->parseString(file_get_contents(__DIR__ . '/../mocks/fail/error.ini')); } From 66457feefc4ce23da30a7f6b3575b8acbaff0ae2 Mon Sep 17 00:00:00 2001 From: Davide Pastore Date: Thu, 30 Dec 2021 14:17:23 +0100 Subject: [PATCH 5/9] Use different PHPUnit syntax for PHP 5.5 --- tests/Parser/IniTest.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/Parser/IniTest.php b/tests/Parser/IniTest.php index cae6e95..c86941e 100644 --- a/tests/Parser/IniTest.php +++ b/tests/Parser/IniTest.php @@ -61,10 +61,18 @@ public function testLoadInvalidIniGBH() public function testLoadInvalidIni() { if (PHP_VERSION_ID < 70400 && PHP_VERSION_ID >= 50500) { - $this->expectException(\Noodlehaus\Exception\ParseException::class); - $this->expectExceptionMessage("syntax error, unexpected \$end, expecting ']'"); + $exceptionMessage = "syntax error, unexpected \$end, expecting ']'"; } else { - $this->expectExceptionMessage("syntax error, unexpected end of file, expecting ']' in Unknown on line 1"); + $exceptionMessage = "syntax error, unexpected end of file, expecting ']' in Unknown on line 1"; + } + + if (PHP_VERSION_ID < 50600 && PHP_VERSION_ID >= 50500) { + $this->setExpectedException( + '\Noodlehaus\Exception\ParseException', $exceptionMessage + ); + } else { + $this->expectException(\Noodlehaus\Exception\ParseException::class); + $this->expectExceptionMessage($exceptionMessage); } $this->ini->parseString(file_get_contents(__DIR__ . '/../mocks/fail/error.ini')); From 67abdf1f28a6246e5fb132daa09e03f0b236cc30 Mon Sep 17 00:00:00 2001 From: Davide Pastore Date: Thu, 30 Dec 2021 14:29:15 +0100 Subject: [PATCH 6/9] Fix if condition on last step --- .github/workflows/continuous-integration.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index a038a06..403ee53 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -20,9 +20,6 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - - - name: Check PHP Version - run: php -v - name: Install dependencies run: composer install --no-interaction --no-progress --prefer-dist @@ -31,5 +28,5 @@ jobs: run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover - name: Upload code coverage data - if: ${{ matrix.php-versions }} == '7.3' + if: ${{ matrix.php-versions == '7.3' }} run: php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover \ No newline at end of file From 16544382e5c8a1eaef6f6956baf90546e66dcc6e Mon Sep 17 00:00:00 2001 From: Davide Pastore Date: Thu, 30 Dec 2021 14:41:48 +0100 Subject: [PATCH 7/9] Use two different stages to generate coverage data --- .github/workflows/continuous-integration.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 403ee53..7b39316 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -23,8 +23,13 @@ jobs: - name: Install dependencies run: composer install --no-interaction --no-progress --prefer-dist - + - name: PHP Unit tests + if: ${{ matrix.php-versions != '7.3' }} + run: vendor/bin/phpunit + + - name: PHP Unit tests generating coverage data + if: ${{ matrix.php-versions == '7.3' }} run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover - name: Upload code coverage data From 821092d1c51c684f9d3e417d792e9863cdc8381a Mon Sep 17 00:00:00 2001 From: Davide Pastore Date: Thu, 30 Dec 2021 15:09:27 +0100 Subject: [PATCH 8/9] Replace Travis badge with GitHub Actions one --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f80e08d..cbf5b0d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Latest version][ico-version]][link-packagist] [![Software License][ico-license]][link-license] -[![Build Status][ico-travis]][link-travis] +[![Build Status][ico-gh-actions]][link-gh-actions] [![Coverage Status][ico-scrutinizer]][link-scrutinizer] [![Quality Score][ico-code-quality]][link-code-quality] [![Total Downloads][ico-downloads]][link-downloads] @@ -260,7 +260,7 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio [ico-version]: https://img.shields.io/packagist/v/hassankhan/config.svg?style=flat-square [ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square -[ico-travis]: https://img.shields.io/travis/hassankhan/config/master.svg?style=flat-square +[ico-gh-actions]: https://img.shields.io/github/workflow/status/hassankhan/config/Continuous%20Integration/master?style=flat-square [ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/hassankhan/config.svg?style=flat-square [ico-code-quality]: https://img.shields.io/scrutinizer/g/hassankhan/config.svg?style=flat-square [ico-downloads]: https://img.shields.io/packagist/dt/hassankhan/config.svg?style=flat-square @@ -268,7 +268,7 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio [link-packagist]: https://packagist.org/packages/hassankhan/config [link-license]: http://hassankhan.mit-license.org -[link-travis]: https://travis-ci.org/hassankhan/config +[link-gh-actions]: https://github.com/hassankhan/config/actions?query=workflow%3A%22Continuous+Integration%22+branch%3Amaster [link-scrutinizer]: https://scrutinizer-ci.com/g/hassankhan/config/code-structure [link-code-quality]: https://scrutinizer-ci.com/g/hassankhan/config [link-downloads]: https://packagist.org/packages/hassankhan/config From fd2adb18d22a246f5d099e50c5bec355a5afcdd5 Mon Sep 17 00:00:00 2001 From: Davide Pastore Date: Thu, 30 Dec 2021 15:13:44 +0100 Subject: [PATCH 9/9] Remove runs option for scrutinizer --- .scrutinizer.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index cf46d83..16e9f25 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -19,7 +19,6 @@ checks: tools: external_code_coverage: timeout: 600 - runs: 3 php_analyzer: true php_code_coverage: false php_code_sniffer: