diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e613e3e..cedc39f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ { - "image": "opencodeco/phpctl:php83-devcontainer", + "image": "opencodeco/phpctl:php84-devcontainer", "containerEnv": { - "PHP_VERSION": "83" + "PHP_VERSION": "84" }, "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": {}, diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index 61d9258..827e2fb 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -18,6 +18,8 @@ jobs: php-str: 8.2 - php: 83 php-str: 8.3 + - php: 84 + php-str: 8.4 steps: - diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ebbf8c7..68168fa 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -20,6 +20,9 @@ jobs: - alpine: '3.20' php: 83 without-watchr: '' + - alpine: '3.21' + php: 84 + without-watchr: '' steps: - name: Checkout diff --git a/Makefile b/Makefile index 8be10a7..a3ade9c 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,11 @@ default: build .PHONY: build build: - @parallel --line-buffer PHP_VERSION={} ./bin/phpctl build ::: 81 82 83 + @parallel --line-buffer PHP_VERSION={} ./bin/phpctl build ::: 81 82 83 84 .PHONY: test test: - @parallel --line-buffer PHP_VERSION={} COMPOSER_AUTH= TERM= ./bin/notty ./lib/bashunit ./tests/ ::: 81 82 83 + @parallel --line-buffer PHP_VERSION={} COMPOSER_AUTH= TERM= ./bin/notty ./lib/bashunit ./tests/ ::: 81 82 83 84 @[ -f phpctl.ini ] && rm phpctl.ini .PHONY: install @@ -16,4 +16,4 @@ install: .PHONY: devcontainers devcontainers: - @parallel --line-buffer PHP_VERSION={} ./src-devc/build.sh ::: 81 82 83 + @parallel --line-buffer PHP_VERSION={} ./src-devc/build.sh ::: 81 82 83 84 diff --git a/docs/commands.md b/docs/commands.md index f95efa1..32f2966 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -23,14 +23,14 @@ nav_order: 2 | `co-phpunit` | [co-phpunit](https://github.com/hyperf/testing) is a Coroutine-aware PHPUnit for testing Hyperf projects. | | `composer-require-checker` | [ComposerRequireChecker](https://github.com/maglnet/ComposerRequireChecker): A CLI tool to analyze composer dependencies and verify that no unknown symbols are used in the sources of a package. | | `couscous` | [Couscous](https://github.com/CouscousPHP/Couscous): Couscous generates a GitHub pages website from your markdown documentation. | -| `deptrac` | [Deptrac](https://github.com/qossmic/deptrac): Deptrac is a static code analysis tool for PHP that helps you communicate, visualize and enforce architectural decisions in your projects. | +| `deptrac` | [Deptrac](https://github.com/deptrac/deptrac): Deptrac is a static code analysis tool for PHP that helps you communicate, visualize and enforce architectural decisions in your projects. | | `exakat` | [Exakat](https://www.exakat.io) is a real time customizable static analyzer engine that analyse and fix code. | | `frankenphp` | [FrankenPHP](https://frankenphp.dev): the Modern PHP App Server, written in Go. | | `infection` | [Infection](https://infection.github.io) is a Mutation Testing Framework. | | `pest` | [Pest](https://pestphp.com) is a testing framework with a focus on simplicity. | | `php-cs-fixer` | [PHP Coding Standards Fixer (PHP CS Fixer)](https://cs.symfony.com/) fixes your code to follow standards. | -| `phpcbf` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. | -| `phpcs` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. | +| `phpcbf` | [PHP CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/) is an essential development tool that ensures your code remains clean and consistent. | +| `phpcs` | [PHP CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/) is an essential development tool that ensures your code remains clean and consistent. | | `phpmd` | [PHP Mess Detector](https://phpmd.org/) looks for several potential problems within your source code. | | `phpstan` | [PHPStan](https://phpstan.org/) finds bugs in your code without writing tests. It's open-source and free. | | `phpunit` | [PHPUnit](https://phpunit.de) is a programmer-oriented testing framework for PHP. | diff --git a/examples/phpunit/README.md b/examples/phpunit/README.md index d6e93bb..3ea455e 100644 --- a/examples/phpunit/README.md +++ b/examples/phpunit/README.md @@ -106,7 +106,7 @@ And everything should ok fine. The command PhpStorm should be using will be something similar to: ```text -[docker://opencodeco/phpctl:php82/]:php /opt/project/examples/phpunit/vendor/phpunit/phpunit/phpunit --configuration /opt/project/examples/phpunit/phpunit.xml --teamcity +[docker://opencodeco/phpctl:php84/]:php /opt/project/examples/phpunit/vendor/phpunit/phpunit/phpunit --configuration /opt/project/examples/phpunit/phpunit.xml --teamcity ``` --- diff --git a/rootfs/usr/local/bin/install-swoole b/rootfs/usr/local/bin/install-swoole index 3017b47..20c4d85 100755 --- a/rootfs/usr/local/bin/install-swoole +++ b/rootfs/usr/local/bin/install-swoole @@ -1,7 +1,7 @@ #!/usr/bin/env sh set -e -SWOOLE_VERSION="5.1.4" +SWOOLE_VERSION="6.0.2" echo "Installing Swoole $SWOOLE_VERSION" # Download diff --git a/rootfs/usr/local/bin/install-tools b/rootfs/usr/local/bin/install-tools index 1e59ff6..efe34eb 100755 --- a/rootfs/usr/local/bin/install-tools +++ b/rootfs/usr/local/bin/install-tools @@ -2,117 +2,125 @@ set -e box() { - local version="4.6.1" + _version="4.6.6" if [ "$PHP_VERSION" = "81" ]; then - version="4.5.1" + _version="4.5.1" fi - echo "Installing Box $version" - wget -q "https://github.com/box-project/box/releases/download/$version/box.phar" -O /usr/local/bin/box + echo "Installing Box $_version" + wget -q "https://github.com/box-project/box/releases/download/$_version/box.phar" -O /usr/local/bin/box chmod a+x /usr/local/bin/box } co_phpunit() { - local version="3.1.3" - echo "Installing co-phpunit $version" - wget -q "https://raw.githubusercontent.com/hyperf/testing/v$version/co-phpunit" -O /usr/local/bin/co-phpunit + _version="3.1.55" + echo "Installing co-phpunit $_version" + wget -q "https://raw.githubusercontent.com/hyperf/testing/v$_version/co-phpunit" -O /usr/local/bin/co-phpunit chmod a+x /usr/local/bin/co-phpunit } composer() { - local version="993f9fec74930f32f7015e71543243bf6d9b9e93" - echo "Installing Composer $version" - wget "https://raw.githubusercontent.com/composer/getcomposer.org/$version/web/installer" -O - -q | php -- --quiet + _version="e8882379a53c329ed348ca583cdc3f8ba6fc4d96" + echo "Installing Composer $_version" + wget "https://raw.githubusercontent.com/composer/getcomposer.org/$_version/web/installer" -O - -q | php -- --quiet mv composer.phar /usr/local/bin/composer chmod a+x /usr/local/bin/composer } composer_require_checker() { - local version="4.10.0" + _version="4.16.1" if [ "$PHP_VERSION" = "81" ]; then - version="4.7.1" + _version="4.7.1" fi - echo "Installing ComposerRequireChecker $version" - wget -q "https://github.com/maglnet/ComposerRequireChecker/releases/download/$version/composer-require-checker.phar" -O /usr/local/bin/composer-require-checker + echo "Installing ComposerRequireChecker $_version" + wget -q "https://github.com/maglnet/ComposerRequireChecker/releases/download/$_version/composer-require-checker.phar" -O /usr/local/bin/composer-require-checker chmod a+x /usr/local/bin/composer-require-checker } couscous() { - local version="1.10.0" - echo "Installing Couscous $version" - wget -q "https://github.com/CouscousPHP/Couscous/releases/download/$version/couscous.phar" -O /usr/local/bin/couscous + _version="1.10.0" + echo "Installing Couscous $_version" + wget -q "https://github.com/CouscousPHP/Couscous/releases/download/$_version/couscous.phar" -O /usr/local/bin/couscous chmod a+x /usr/local/bin/couscous } deptrac() { - local version="1.0.2" - echo "Installing Deptrac $version" - wget -q "https://github.com/qossmic/deptrac/releases/download/$version/deptrac.phar" -O /usr/local/bin/deptrac + _version="1.0.2" + echo "Installing Deptrac $_version" + wget -q "https://github.com/deptrac/deptrac/releases/download/$_version/deptrac.phar" -O /usr/local/bin/deptrac chmod a+x /usr/local/bin/deptrac } exakat() { - local version="2.6.2" - echo "Installing Exakat $version" - wget -q "https://www.exakat.io/versions/index.php?file=exakat-$version.phar" -O /usr/local/bin/exakat + _version="2.6.2" + echo "Installing Exakat $_version" + wget -q "https://www.exakat.io/versions/index.php?file=exakat-$_version.phar" -O /usr/local/bin/exakat chmod a+x /usr/local/bin/exakat } infection() { - local version="0.27.10" - echo "Installing Infection $version" - wget -q "https://github.com/infection/infection/releases/download/$version/infection.phar" -O /usr/local/bin/infection + _version="0.29.14" + if [ "$PHP_VERSION" = "81" ]; then + _version="0.27.10" + fi; + echo "Installing Infection $_version" + wget -q "https://github.com/infection/infection/releases/download/$_version/infection.phar" -O /usr/local/bin/infection chmod a+x /usr/local/bin/infection } php_cs_fixer() { - local version="3.51.0" - echo "Installing PHP CS Fixer $version" - wget -q "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/v$version/php-cs-fixer.phar" -O /usr/local/bin/php-cs-fixer + _version="3.75.0" + echo "Installing PHP CS Fixer $_version" + wget -q "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/v$_version/php-cs-fixer.phar" -O /usr/local/bin/php-cs-fixer chmod a+x /usr/local/bin/php-cs-fixer } phpcbf() { - local version="3.7.2" - echo "Installing PHP CodeSniffer $version (phpcbf)" - wget -q "https://github.com/squizlabs/PHP_CodeSniffer/releases/download/$version/phpcbf.phar" -O /usr/local/bin/phpcbf + _version="3.13.0" + echo "Installing PHP CodeSniffer $_version (phpcbf)" + wget -q "https://github.com/PHPCSStandards/PHP_CodeSniffer//releases/download/$_version/phpcbf.phar" -O /usr/local/bin/phpcbf chmod a+x /usr/local/bin/phpcbf } phpcs() { - local version="3.7.2" - echo "Installing PHP CodeSniffer $version (phpcs)" - wget -q "https://github.com/squizlabs/PHP_CodeSniffer/releases/download/$version/phpcs.phar" -O /usr/local/bin/phpcs + _version="3.13.0" + echo "Installing PHP CodeSniffer $_version (phpcs)" + wget -q "https://github.com/PHPCSStandards/PHP_CodeSniffer//releases/download/$_version/phpcs.phar" -O /usr/local/bin/phpcs chmod a+x /usr/local/bin/phpcs } phpmd() { - local version="2.15.0" - echo "Installing PHP Mess Detector $version" - wget -q "https://github.com/phpmd/phpmd/releases/download/$version/phpmd.phar" -O /usr/local/bin/phpmd + _version="2.15.0" + echo "Installing PHP Mess Detector $_version" + wget -q "https://github.com/phpmd/phpmd/releases/download/$_version/phpmd.phar" -O /usr/local/bin/phpmd chmod a+x /usr/local/bin/phpmd } phpstan() { - local version="1.10.59" - echo "Installing PHPStan $version" - wget -q "https://github.com/phpstan/phpstan/releases/download/$version/phpstan.phar" -O /usr/local/bin/phpstan + _version="1.12.27" + echo "Installing PHPStan $_version" + wget -q "https://github.com/phpstan/phpstan/releases/download/$_version/phpstan.phar" -O /usr/local/bin/phpstan chmod a+x /usr/local/bin/phpstan } phpunit() { - local version="11" + _version="11" if [ "$PHP_VERSION" = "81" ]; then - version="10" + _version="10" + elif [ "$PHP_VERSION" = "84" ]; then + _version="12" fi - echo "Installing PHPUnit $version" - wget -q "https://phar.phpunit.de/phpunit-$version.phar" -O /usr/local/bin/phpunit + echo "Installing PHPUnit $_version" + wget -q "https://phar.phpunit.de/phpunit-$_version.phar" -O /usr/local/bin/phpunit chmod a+x /usr/local/bin/phpunit } pint() { - local version="1.14.0" - echo "Installing Pint $version" - wget -q "https://github.com/laravel/pint/releases/download/v$version/pint.phar" -O /usr/local/bin/pint + _version="1.22.1" + if [ "$PHP_VERSION" = "81" ]; then + _version="1.14.0" + fi; + echo "Installing Pint $_version" + wget -q "https://github.com/laravel/pint/releases/download/v$_version/pint.phar" -O /usr/local/bin/pint chmod a+x /usr/local/bin/pint } @@ -123,9 +131,9 @@ psysh() { } watchr() { - local version="0.5.3" - echo "Installing watchr $version" - wget -q "https://github.com/flavioheleno/watchr/releases/download/v$version/watchr.phar" -O /usr/local/bin/watchr + _version="0.5.3" + echo "Installing watchr $_version" + wget -q "https://github.com/flavioheleno/watchr/releases/download/v$_version/watchr.phar" -O /usr/local/bin/watchr chmod a+x /usr/local/bin/watchr } diff --git a/src/docker.sh b/src/docker.sh index 9b09d8e..f484958 100644 --- a/src/docker.sh +++ b/src/docker.sh @@ -9,6 +9,26 @@ build() { without_watchr="--build-arg WITHOUT_WATCHR=1" fi + if [[ -z $ALPINE ]]; then + case $PHP_VERSION in + "81") + ALPINE=3.19 + ;; + "82") + ALPINE=3.20 + ;; + "83") + ALPINE=3.20 + ;; + "84") + ALPINE=3.21 + ;; + *) + ALPINE=3.21 + ;; + esac + fi + echo -e "Building \033[0;32m$PHPCTL_IMAGE\033[0m" # shellcheck disable=SC2068 # shellcheck disable=SC2154 @@ -16,6 +36,7 @@ build() { --build-arg PHP="$PHP_VERSION" \ --build-arg COMPOSER_AUTH="$COMPOSER_AUTH" \ --build-arg HOST_USER="$(whoami)" \ + --build-arg ALPINE="$ALPINE" \ $with_exakat \ $without_watchr \ ${build[@]} -t "$PHPCTL_IMAGE" . @@ -59,7 +80,7 @@ run() { if [ -n "$GIT_EXEC_PATH" ]; then # In a Git hook environment, we need to disable TTY allocation PHPCTL_TTY="--label=no-tty" - fi + fi # shellcheck disable=SC2046 # shellcheck disable=SC2068 diff --git a/tests/tools_test.sh b/tests/tools_test.sh index f3bc3db..f5fb1aa 100644 --- a/tests/tools_test.sh +++ b/tests/tools_test.sh @@ -25,10 +25,15 @@ function test_exakat() { } function test_infection() { - assert_matches "Infection - PHP Mutation Testing Framework version 0\.27\." "$(./bin/phpctl infection --version)" + [ "$PHP_VERSION" = "81" ] && _expected_version="0\.27\." || _expected_version="0\.29\." + assert_matches "Infection - PHP Mutation Testing Framework version ${_expected_version}" "$(./bin/phpctl infection --version)" } function test_php_cs_fixer() { + if [[ $PHP_VERSION = "84" ]]; then + # TODO: remove this when php-cs-fixer becomes stable with php 8.4 + export PHP_CS_FIXER_IGNORE_ENV=yes + fi assert_matches "PHP CS Fixer 3\." "$(./bin/phpctl php-cs-fixer --version)" } @@ -51,6 +56,8 @@ function test_phpstan() { function test_phpunit() { if [ "$PHP_VERSION" = "81" ]; then assert_matches "PHPUnit 10\." "$(./bin/phpctl phpunit --version)" + elif [ "$PHP_VERSION" = "84" ]; then + assert_matches "PHPUnit 12\." "$(./bin/phpctl phpunit --version)" else assert_matches "PHPUnit 11\." "$(./bin/phpctl phpunit --version)" fi