From 3b4835000b1e128f86f638758e4ec19f413c0392 Mon Sep 17 00:00:00 2001 From: Olivier Laviale Date: Sat, 16 Nov 2024 01:02:14 +0100 Subject: [PATCH] Test against PHP 8.4 --- .github/workflows/code-style.yml | 2 +- .github/workflows/static-analysis.yml | 4 ++-- .github/workflows/test.yml | 7 ++++-- .gitignore | 1 + Dockerfile | 34 +++++++++++++++++---------- Makefile | 25 +++++++++++++------- composer.json | 6 ++--- docker-compose.yaml | 21 +++++++++++++---- lib/InflectionsNotFound.php | 1 - lib/Inflector.php | 2 +- phpunit.xml => phpunit07.xml | 3 ++- phpunit10.xml | 23 ++++++++++++++++++ 12 files changed, 92 insertions(+), 37 deletions(-) rename phpunit.xml => phpunit07.xml (96%) create mode 100644 phpunit10.xml diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index d253600..7d15937 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install PHP uses: shivammathur/setup-php@v2 with: diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 2e43418..2ba2fa2 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install PHP uses: shivammathur/setup-php@v2 with: @@ -18,7 +18,7 @@ jobs: ini-values: memory_limit=-1 tools: composer:v2 - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ~/.composer/cache diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 427fc39..04b88a5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,9 +15,10 @@ jobs: - "7.2" - "7.3" - "7.4" + - "8.4" steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install PHP uses: shivammathur/setup-php@v2 with: @@ -26,7 +27,7 @@ jobs: ini-values: memory_limit=-1 tools: composer:v2 - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ~/.composer/cache @@ -39,6 +40,8 @@ jobs: - name: Run PHPUnit run: make test-coveralls + env: + PHPUNIT_VERSION: "${{ matrix.php-version == '8.4' && '10' || '07' }}" - name: Upload code coverage if: ${{ matrix.php-version == '7.1' }} diff --git a/.gitignore b/.gitignore index 073e37a..4edb3d9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.phpunit.result.cache build composer.lock vendor diff --git a/Dockerfile b/Dockerfile index 68b7a4c..ba23c0c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,28 @@ -FROM php:7.1-cli-buster +ARG PHP_TAG=7.1-cli-buster +FROM php:${PHP_TAG} -RUN docker-php-ext-enable opcache && \ - docker-php-source delete +RUN <<-EOF + docker-php-ext-enable opcache +EOF -RUN echo '\ -display_errors=On\n\ -error_reporting=E_ALL\n\ -date.timezone=UTC\n\ -' >> /usr/local/etc/php/conf.d/php.ini +RUN <<-EOF + cat <<-SHELL >> /usr/local/etc/php/conf.d/php.ini + display_errors=On + error_reporting=E_ALL + date.timezone=UTC + SHELL +EOF ENV COMPOSER_ALLOW_SUPERUSER 1 -RUN apt-get update && \ - apt-get install unzip && \ - curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet && \ - mv composer.phar /usr/local/bin/composer && \ - echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"\n' >> /root/.bashrc +RUN <<-EOF + apt-get update + apt-get install unzip + curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet + mv composer.phar /usr/local/bin/composer + cat <<-SHELL >> /root/.bashrc + export PATH="$HOME/.composer/vendor/bin:$PATH" + SHELL +EOF RUN composer global require squizlabs/php_codesniffer diff --git a/Makefile b/Makefile index 4d6b868..309f5b7 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ # customization -PACKAGE_NAME = icanboogie/inflector -PHPUNIT = vendor/bin/phpunit +PHPUNIT = vendor/bin/phpunit --configuration=phpunit$(PHPUNIT_VERSION).xml # do not edit the following lines @@ -13,24 +12,32 @@ test-dependencies: vendor .PHONY: test test: test-dependencies - @$(PHPUNIT) + @XDEBUG_MODE=none $(PHPUNIT) .PHONY: test-coverage test-coverage: test-dependencies @mkdir -p build/coverage - @$(PHPUNIT) --coverage-html build/coverage + @XDEBUG_MODE=coverage $(PHPUNIT) --coverage-html build/coverage .PHONY: test-coveralls test-coveralls: test-dependencies @mkdir -p build/logs - @$(PHPUNIT) --coverage-clover build/logs/clover.xml + @XDEBUG_MODE=coverage $(PHPUNIT) --coverage-clover build/logs/clover.xml .PHONY: test-container -test-container: - @docker-compose run --rm app bash +test-container: test-container-71 + +.PHONY: test-container-71 +test-container-71: + @-docker-compose run --rm app71 bash + @docker-compose down -v + +.PHONY: test-container-84 +test-container-84: + @-docker-compose run --rm app84 bash @docker-compose down -v .PHONY: lint lint: - @phpcs - @vendor/bin/phpstan + @XDEBUG_MODE=off phpcs -s + @XDEBUG_MODE=off vendor/bin/phpstan diff --git a/composer.json b/composer.json index e9ccf60..93d87ae 100644 --- a/composer.json +++ b/composer.json @@ -25,9 +25,9 @@ "ext-mbstring": "*" }, "require-dev": { - "icanboogie/common": "^2.0", - "phpstan/phpstan": "^0.12.92", - "phpunit/phpunit": "^7.5" + "icanboogie/common": "^2.1", + "phpstan/phpstan": "^0.12.100|^2.0", + "phpunit/phpunit": "^7.5.20|^10.0" }, "conflict": { "icanboogie/common": "<2.0" diff --git a/docker-compose.yaml b/docker-compose.yaml index f64a9ff..9653f8e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,11 +1,24 @@ --- -version: "3.2" services: - app: - build: . + app71: + build: + context: . + args: + PHP_TAG: "7.1-cli-buster" environment: PHP_IDE_CONFIG: 'serverName=icanboogie-inflector' - volumes: + PHPUNIT_VERSION: "07" + volumes: &vol - .:/app:delegated - ~/.composer:/root/.composer:delegated working_dir: /app + app84: + build: + context: . + args: + PHP_TAG: "8.4.0RC4-cli-bookworm" + environment: + PHP_IDE_CONFIG: 'serverName=icanboogie-inflector' + PHPUNIT_VERSION: "10" + volumes: *vol + working_dir: /app diff --git a/lib/InflectionsNotFound.php b/lib/InflectionsNotFound.php index 551b61a..50ceaad 100644 --- a/lib/InflectionsNotFound.php +++ b/lib/InflectionsNotFound.php @@ -15,5 +15,4 @@ class InflectionsNotFound extends LogicException { - } diff --git a/lib/Inflector.php b/lib/Inflector.php index 18a85aa..ebce967 100644 --- a/lib/Inflector.php +++ b/lib/Inflector.php @@ -67,7 +67,7 @@ public static function get(string $locale = self::DEFAULT_LOCALE): self */ private $inflections; - public function __construct(Inflections $inflections = null) + public function __construct(?Inflections $inflections = null) { $this->inflections = $inflections ?? new Inflections(); } diff --git a/phpunit.xml b/phpunit07.xml similarity index 96% rename from phpunit.xml rename to phpunit07.xml index ef48d4c..48b6aa8 100644 --- a/phpunit.xml +++ b/phpunit07.xml @@ -5,7 +5,8 @@ executionOrder="depends,defects" beStrictAboutOutputDuringTests="true" verbose="true" - colors="true"> + colors="true" +> ./tests diff --git a/phpunit10.xml b/phpunit10.xml new file mode 100644 index 0000000..dd1a687 --- /dev/null +++ b/phpunit10.xml @@ -0,0 +1,23 @@ + + + + + tests + + + + + lib + + +