From b767e83307987215eaa2802e949e2b446d446091 Mon Sep 17 00:00:00 2001 From: Olivier Laviale Date: Sat, 20 Jan 2024 12:59:12 +0100 Subject: [PATCH] Test against PHP 8.3 --- .editorconfig | 2 +- .gitattributes | 9 +- .github/workflows/code-style.yml | 16 ++-- .github/workflows/static-analysis.yml | 12 +-- .github/workflows/test.yml | 11 +-- .gitignore | 2 +- CODE_OF_CONDUCT.md | 8 +- CONTRIBUTING.md | 4 +- Dockerfile | 7 +- LICENSE | 2 +- Makefile | 42 +++++---- README.md | 18 ++-- composer.json | 118 +++++++++++++------------- docker-compose.yaml | 33 ++++++- phpunit.xml | 11 ++- tests/sandbox/.gitignore | 2 +- 16 files changed, 168 insertions(+), 129 deletions(-) diff --git a/.editorconfig b/.editorconfig index 616af73..8a52e07 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,5 +8,5 @@ insert_final_newline = true indent_style = space indent_size = 4 -[*.yml] +[{*.yaml,*.yml,*.neon,*.json}] indent_size = 2 diff --git a/.gitattributes b/.gitattributes index 8277603..2391959 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,13 @@ +* text=auto + +.editorconfig export-ignore .gitattributes export-ignore +.github export-ignore .gitignore export-ignore -.travis.yml export-ignore +docker-compose.yml export-ignore +Dockerfile export-ignore Makefile export-ignore +phpcs.xml +phpstan.neon export-ignore phpunit.xml export-ignore tests/ export-ignore diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index 7bf1c95..66a1b3d 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -5,17 +5,17 @@ on: - pull_request jobs: - phpstan: - name: PHPCS - runs-on: ubuntu-20.04 + phpcs: + runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install PHP uses: shivammathur/setup-php@v2 with: - php-version: "8.1" + coverage: none + php-version: "8.3" ini-values: memory_limit=-1 - tools: composer:v2, phpcs - - name: Run PHPCS - run: phpcs + tools: phpcs, cs2pr + - name: Run PHP Code Sniffer + run: phpcs -q --report=checkstyle | cs2pr diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index abea39b..6a87b5e 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -6,19 +6,19 @@ on: jobs: phpstan: - name: PHPStan - runs-on: ubuntu-20.04 + name: phpstan + runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install PHP uses: shivammathur/setup-php@v2 with: - php-version: "8.1" + php-version: "8.3" ini-values: memory_limit=-1 tools: composer:v2 - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ~/.composer/cache @@ -28,5 +28,5 @@ jobs: - name: Install dependencies run: composer install --no-interaction --no-progress - - name: Run PHPStan + - name: Analyze run: vendor/bin/phpstan diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 60741ef..66681cc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,25 +7,26 @@ on: jobs: phpunit: name: phpunit - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: matrix: php-version: - "8.1" - "8.2" + - "8.3" steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install PHP uses: shivammathur/setup-php@v2 with: coverage: xdebug php-version: "${{ matrix.php-version }}" - ini-values: apc.enable_cli=1, memory_limit=-1 + ini-values: memory_limit=-1 tools: composer:v2 extensions: apcu - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ~/.composer/cache @@ -40,7 +41,7 @@ jobs: run: make test-coveralls - name: Upload code coverage - if: ${{ matrix.php-version == '8.1' }} + if: ${{ matrix.php-version == '8.3' }} env: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | diff --git a/.gitignore b/.gitignore index 4edb3d9..14010f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -.phpunit.result.cache +.phpunit.cache build composer.lock vendor diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index d8e2efa..5ef93b0 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,4 +1,3 @@ - # Contributor Covenant Code of Conduct ## Our Pledge @@ -61,7 +60,7 @@ representative at an online or offline event. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at -[INSERT CONTACT METHOD]. +. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the @@ -119,11 +118,11 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0]. -Community Impact Guidelines were inspired by +Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. For answers to common questions about this code of conduct, see the FAQ at -[https://www.contributor-covenant.org/faq][FAQ]. Translations are available +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations]. [homepage]: https://www.contributor-covenant.org @@ -131,4 +130,3 @@ at [https://www.contributor-covenant.org/translations][translations]. [Mozilla CoC]: https://github.com/mozilla/diversity [FAQ]: https://www.contributor-covenant.org/faq [translations]: https://www.contributor-covenant.org/translations - diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ecaa88a..33bc016 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,13 +2,13 @@ Contributions are **welcome** and will be fully **credited**. -We accept contributions via Pull Requests on [Github](https://github.com/ICanBoogie/Inflector). +We accept contributions via Pull Requests. ## Pull Requests - **Code style** — We're following a [Coding Standard][]. Check the code style with `make lint`. - **Code health** — We're using [PHPStan][] to analyse the code, with maximum scrutiny. Check the code with `make lint`. -- **Add tests!** — Your contribution won't be accepted if it doesn't have tests. +- **Add tests!** — Your contribution won't be accepted if it does not have tests. - **Document any change in behaviour** — Make sure the `README.md` and any other relevant documentation are kept up-to-date. - **Consider our release cycle** — We follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not diff --git a/Dockerfile b/Dockerfile index b45bf29..41e1145 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ -FROM php:8.1-cli-buster +ARG PHP_VERSION +FROM php:${PHP_VERSION}-cli-bookworm RUN apt-get update && \ apt-get install -y autoconf pkg-config && \ - pecl channel-update pecl.php.net && \ + pecl channel-update pecl.php.net && \ pecl install xdebug && \ docker-php-ext-enable opcache xdebug @@ -22,7 +23,7 @@ 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 && \ + 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 diff --git a/LICENSE b/LICENSE index 4f57d56..379f5e9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ The icanboogie/bind-symfony-dependency-injection package is free software. It is released under the terms of the following BSD License. -Copyright (c) 2017-2022 by Olivier Laviale +Copyright (c) 2017-2024 by Olivier Laviale All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/Makefile b/Makefile index f1c3faf..5fb34d5 100644 --- a/Makefile +++ b/Makefile @@ -12,40 +12,48 @@ usage: vendor: @composer install -.PHONY: update -update: - @composer update - -.PHONY: autoload -autoload: vendor - @composer dump-autoload +# testing +.PHONY: test-dependencies test-dependencies: vendor .PHONY: test -test: test-dependencies clean-sandbox - @$(PHPUNIT) +test: test-dependencies test-cleanup + @$(PHPUNIT) $(ARGS) .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-cleanup +test-cleanup: + @rm -rf tests/sandbox/* .PHONY: test-container -test-container: - @-docker-compose run --rm app bash +test-container: test-container-81 + +.PHONY: test-container-81 +test-container-81: + @-docker-compose run --rm app81 bash + @docker-compose down -v + +.PHONY: test-container-82 +test-container-82: + @-docker-compose run --rm app82 bash + @docker-compose down -v + +.PHONY: test-container-83 +test-container-83: + @-docker-compose run --rm app83 bash @docker-compose down -v .PHONY: lint lint: @XDEBUG_MODE=off phpcs -s @XDEBUG_MODE=off vendor/bin/phpstan - -.PHONY: clean-sandbox -clean-sandbox: - @rm -f ./tests/sandbox/* diff --git a/README.md b/README.md index 57f77fa..1e4c5b6 100644 --- a/README.md +++ b/README.md @@ -133,16 +133,16 @@ return fn(ConfigBuilder $config) => $config The project is continuously tested by [GitHub actions](https://github.com/ICanBoogie/bind-symfony-dependency-injection/actions). -[![Tests](https://github.com/ICanBoogie/bind-symfony-dependency-injection/workflows/test/badge.svg?branch=master)](https://github.com/ICanBoogie/bind-symfony-dependency-injection/actions?query=workflow%3Atest) -[![Static Analysis](https://github.com/ICanBoogie/bind-symfony-dependency-injection/workflows/static-analysis/badge.svg?branch=master)](https://github.com/ICanBoogie/bind-symfony-dependency-injection/actions?query=workflow%3Astatic-analysis) -[![Code Style](https://github.com/ICanBoogie/bind-symfony-dependency-injection/workflows/code-style/badge.svg?branch=master)](https://github.com/ICanBoogie/bind-symfony-dependency-injection/actions?query=workflow%3Acode-style) +[![Tests](https://github.com/ICanBoogie/bind-symfony-dependency-injection/workflows/test/badge.svg)](https://github.com/ICanBoogie/bind-symfony-dependency-injection/actions?query=workflow%3Atest) +[![Static Analysis](https://github.com/ICanBoogie/bind-symfony-dependency-injection/workflows/static-analysis/badge.svg)](https://github.com/ICanBoogie/bind-symfony-dependency-injection/actions?query=workflow%3Astatic-analysis) +[![Code Style](https://github.com/ICanBoogie/bind-symfony-dependency-injection/workflows/code-style/badge.svg)](https://github.com/ICanBoogie/bind-symfony-dependency-injection/actions?query=workflow%3Acode-style) ## Code of Conduct -This project adheres to a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project and its -community, you are expected to uphold this code. +This project adheres to a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in +this project and its community, you are expected to uphold this code. @@ -152,14 +152,6 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details. -## Testing - -Run `make test-container` to create and log into the test container, then run `make test` to run the -test suite. Alternatively, run `make test-coverage` to run the test suite with test coverage. Open -`build/coverage/index.html` to see the breakdown of the code coverage. - - - ## License **icanboogie/bind-symfony-dependency-injection** is released under the [BSD-3-Clause](LICENSE). diff --git a/composer.json b/composer.json index a3f1198..be71261 100644 --- a/composer.json +++ b/composer.json @@ -1,61 +1,61 @@ { - "name": "icanboogie/bind-symfony-dependency-injection", - "type": "library", - "version": "6.0", - "description": "Binds symfony/dependency-injection to ICanBoogie", - "keywords": [ - "dependency", - "injection" - ], - "homepage": "https://icanboogie.org/", - "license": "BSD-3-Clause", - "authors": [ - { - "name": "Olivier Laviale", - "email": "olivier.laviale@gmail.com", - "homepage": "https://olvlvl.com/", - "role": "Developer" - } - ], - "support": { - "issues": "https://github.com/ICanBoogie/bind-symfony-dependency-injection/issues", - "source": "https://github.com/ICanBoogie/bind-symfony-dependency-injection" - }, - "minimum-stability": "dev", - "prefer-stable": true, - "config": { - "sort-packages": true - }, - "require": { - "php": ">=8.1", - "icanboogie/icanboogie": "^6.0", - "olvlvl/symfony-dependency-injection-proxy": "^5.0", - "symfony/config": "^6.3", - "symfony/yaml": "^6.3" - }, - "require-dev": { - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^10.3" - }, - "autoload": { - "psr-4": { - "ICanBoogie\\Binding\\SymfonyDependencyInjection\\": "src" - } - }, - "autoload-dev": { - "psr-4": { - "Test\\ICanBoogie\\Binding\\SymfonyDependencyInjection\\": "tests/src" - } - }, - "scripts": { - "post-autoload-dump": "ICanBoogie\\Autoconfig\\Hooks::on_autoload_dump" - }, - "extra": { - "icanboogie": { - "config-path": "config", - "config-constructor": { - "ICanBoogie\\Binding\\SymfonyDependencyInjection\\Config": "ICanBoogie\\Binding\\SymfonyDependencyInjection\\ConfigBuilder" - } - } - } + "name": "icanboogie/bind-symfony-dependency-injection", + "type": "library", + "version": "6.0", + "description": "Binds symfony/dependency-injection to ICanBoogie", + "keywords": [ + "dependency", + "injection" + ], + "homepage": "https://icanboogie.org/", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Olivier Laviale", + "email": "olivier.laviale@gmail.com", + "homepage": "https://olvlvl.com/", + "role": "Developer" + } + ], + "support": { + "issues": "https://github.com/ICanBoogie/bind-symfony-dependency-injection/issues", + "source": "https://github.com/ICanBoogie/bind-symfony-dependency-injection" + }, + "config": { + "sort-packages": true + }, + "minimum-stability": "dev", + "prefer-stable": true, + "require": { + "php": ">=8.1", + "icanboogie/icanboogie": "^6.0", + "olvlvl/symfony-dependency-injection-proxy": "^5.0", + "symfony/config": "^6.3", + "symfony/yaml": "^6.3" + }, + "require-dev": { + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^10.5" + }, + "autoload": { + "psr-4": { + "ICanBoogie\\Binding\\SymfonyDependencyInjection\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Test\\ICanBoogie\\Binding\\SymfonyDependencyInjection\\": "tests/src" + } + }, + "scripts": { + "post-autoload-dump": "ICanBoogie\\Autoconfig\\Hooks::on_autoload_dump" + }, + "extra": { + "icanboogie": { + "config-path": "config", + "config-constructor": { + "ICanBoogie\\Binding\\SymfonyDependencyInjection\\Config": "ICanBoogie\\Binding\\SymfonyDependencyInjection\\ConfigBuilder" + } + } + } } diff --git a/docker-compose.yaml b/docker-compose.yaml index 7456271..cafee08 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,9 +1,36 @@ --- version: "3.2" services: - app: - build: . + app81: + build: + context: . + args: + PHP_VERSION: "8.1" + environment: + PHP_IDE_CONFIG: 'serverName=icanboogie-bind-symfony-dependency-injection' volumes: - .:/app:delegated - - ~/.composer:/root/.composer + - ~/.composer:/root/.composer:delegated + working_dir: /app + app82: + build: + context: . + args: + PHP_VERSION: "8.2" + environment: + PHP_IDE_CONFIG: 'serverName=icanboogie-bind-symfony-dependency-injection' + volumes: + - .:/app:delegated + - ~/.composer:/root/.composer:delegated + working_dir: /app + app83: + build: + context: . + args: + PHP_VERSION: "8.3" + environment: + PHP_IDE_CONFIG: 'serverName=icanboogie-bind-symfony-dependency-injection' + volumes: + - .:/app:delegated + - ~/.composer:/root/.composer:delegated working_dir: /app diff --git a/phpunit.xml b/phpunit.xml index 7f50b6c..626489e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,8 +1,13 @@ @@ -11,7 +16,7 @@ - ./src + src diff --git a/tests/sandbox/.gitignore b/tests/sandbox/.gitignore index c1aefd2..d6b7ef3 100644 --- a/tests/sandbox/.gitignore +++ b/tests/sandbox/.gitignore @@ -1,2 +1,2 @@ -.gitignore +* !.gitignore