diff --git a/README.md b/README.md index e3150497..63b0770c 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ PHP Versions Supported

-Setup PHP with required extensions, php.ini configuration, code-coverage support and composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this. +Setup PHP with required extensions, php.ini configuration, code-coverage support and tools like composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this. ## Contents @@ -50,7 +50,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support |7.4|`Stable`|`Active`| |8.0|`Experimental`|`In development`| -**Note:** Specifying `8.0` in `php-version` input installs a nightly build of `PHP 8.0.0-dev` with `PHP JIT` support. See [experimental setup](#experimental-setup) for more information. +**Note:** Specifying `8.0` in `php-version` input installs a nightly build of `PHP 8.0.0-dev` with `PHP JIT`, `Union Types v2` and other [new features](https://wiki.php.net/rfc#php_80 "New features implemented in PHP 8"). See [experimental setup](#experimental-setup) for more information. ## :cloud: OS/Platform Support @@ -70,19 +70,9 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support ## :wrench: Tools Support -The following tools can be setup globally using the `tools` input +The latest version of the following tools can be setup globally using the `tools` input -- `php-cs-fixer` -- `phpcs` -- `phpcbf` -- `phpcpd` -- `phpstan` -- `phpmd` -- `codeception` -- `phpunit` -- `deployer` -- `prestissimo` -- `pecl` +`composer`, `codeception`, `deployer`, `pecl`, `phpcbf`, `phpcpd`, `php-cs-fixer`, `phpcs`, `phpmd`, `phpstan`, `phpunit`, `prestissimo` ```yml uses: shivammathur/setup-php@v1 @@ -91,6 +81,8 @@ with: tools: php-cs-fixer, phpunit ``` +**Note:** `composer` is setup by default, so that is not required to be specified. + ## :signal_strength: Coverage support ### Xdebug @@ -127,7 +119,7 @@ Specify `coverage: none` to disable both `Xdebug` and `PCOV`. Consider disabling the coverage using this PHP action for these reasons. - You are not generating coverage reports while testing. -- It will disable `Xdebug`, which will have a positive impact on PHP performance. +- It will remove `Xdebug`, which will have a positive impact on PHP performance. - You are using `phpdbg` for running your tests. ```yaml @@ -203,6 +195,7 @@ jobs: - `PECL` is installed by default with this version on `ubuntu`. - Some extensions might not support this version currently. - Refer to this [RFC](https://wiki.php.net/rfc/jit "PHP JIT RFC configuration") for configuring `PHP JIT` on this version. +- Refer to this [list of RFCs](https://wiki.php.net/rfc#php_80 "List of RFCs implemented in PHP8") implemented in this version. ```yaml steps: @@ -233,7 +226,7 @@ You can persist composer's internal cache directory using the [`action/cache`](h - name: Cache dependencies uses: actions/cache@v1 with: - path: ${{ steps.composer-cache.outputs.dir }} + path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- @@ -241,6 +234,12 @@ You can persist composer's internal cache directory using the [`action/cache`](h run: composer install --prefer-dist ``` +In the above example, if you support a range of `composer` dependencies and do not commit `composer.lock`, you can use the hash of `composer.json` as the key for your cache. + +```yml +key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} +``` + ### Problem Matchers You can setup problem matchers for your `PHPUnit` output. This will scan the errors in your tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations. diff --git a/examples/bedrock.yml b/examples/bedrock.yml index 658a1787..1e55d66b 100644 --- a/examples/bedrock.yml +++ b/examples/bedrock.yml @@ -22,6 +22,8 @@ jobs: - uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install Composer dependencies diff --git a/examples/codeigniter.yml b/examples/codeigniter.yml index 3f98f315..7c22bc1c 100644 --- a/examples/codeigniter.yml +++ b/examples/codeigniter.yml @@ -24,6 +24,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install dependencies diff --git a/examples/laravel-mysql.yml b/examples/laravel-mysql.yml index 7314bc94..12e0cd1c 100644 --- a/examples/laravel-mysql.yml +++ b/examples/laravel-mysql.yml @@ -48,6 +48,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install Composer dependencies diff --git a/examples/laravel-postgres.yml b/examples/laravel-postgres.yml index 1c9769bc..7a32dfa7 100644 --- a/examples/laravel-postgres.yml +++ b/examples/laravel-postgres.yml @@ -50,6 +50,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install Composer dependencies diff --git a/examples/laravel.yml b/examples/laravel.yml index c58146b2..b63f7a4c 100644 --- a/examples/laravel.yml +++ b/examples/laravel.yml @@ -26,6 +26,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install Composer dependencies diff --git a/examples/lumen-mysql.yml b/examples/lumen-mysql.yml index 8913834d..54849a38 100644 --- a/examples/lumen-mysql.yml +++ b/examples/lumen-mysql.yml @@ -48,6 +48,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install Composer dependencies diff --git a/examples/lumen-postgres.yml b/examples/lumen-postgres.yml index 5863c1a5..fc0146a5 100644 --- a/examples/lumen-postgres.yml +++ b/examples/lumen-postgres.yml @@ -50,6 +50,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install Composer dependencies diff --git a/examples/lumen.yml b/examples/lumen.yml index e187bdd8..64618dd6 100644 --- a/examples/lumen.yml +++ b/examples/lumen.yml @@ -26,6 +26,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install Composer dependencies diff --git a/examples/phalcon-mysql.yml b/examples/phalcon-mysql.yml index 88f8d821..cb126bfe 100644 --- a/examples/phalcon-mysql.yml +++ b/examples/phalcon-mysql.yml @@ -30,6 +30,8 @@ jobs: fail-fast: false matrix: php-versions: ['7.2', '7.3', '7.4'] + # For phalcon 3.x, use + # php-versions: ['7.0', '7.1', '7.2', '7.3'] steps: - name: Checkout uses: actions/checkout@v1 @@ -46,6 +48,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install Composer dependencies diff --git a/examples/phalcon-postgres.yml b/examples/phalcon-postgres.yml index 159888ab..c0f38965 100644 --- a/examples/phalcon-postgres.yml +++ b/examples/phalcon-postgres.yml @@ -31,6 +31,8 @@ jobs: fail-fast: false matrix: php-versions: ['7.2', '7.3', '7.4'] + # For phalcon 3.x, use + # php-versions: ['7.0', '7.1', '7.2', '7.3'] steps: - name: Checkout uses: actions/checkout@v1 @@ -47,6 +49,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install Composer dependencies diff --git a/examples/sage.yml b/examples/sage.yml index b22ae0f3..d37253d7 100644 --- a/examples/sage.yml +++ b/examples/sage.yml @@ -39,6 +39,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install yarn dependencies diff --git a/examples/slim-framework.yml b/examples/slim-framework.yml index 4ef37518..5ef36613 100644 --- a/examples/slim-framework.yml +++ b/examples/slim-framework.yml @@ -24,6 +24,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install dependencies diff --git a/examples/symfony-mysql.yml b/examples/symfony-mysql.yml index e5049359..95aba36c 100644 --- a/examples/symfony-mysql.yml +++ b/examples/symfony-mysql.yml @@ -28,6 +28,7 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: mbstring, xml, ctype, iconv, mysql coverage: xdebug #optional + tools: phpunit - name: Get composer cache directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" @@ -35,6 +36,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install Composer dependencies @@ -48,6 +51,4 @@ jobs: env: DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony - name: Run Tests - run: | - composer require phpunit - php bin/phpunit --coverage-text \ No newline at end of file + run: phpunit --coverage-text \ No newline at end of file diff --git a/examples/symfony-postgres.yml b/examples/symfony-postgres.yml index aadf58b9..94aeb1fa 100644 --- a/examples/symfony-postgres.yml +++ b/examples/symfony-postgres.yml @@ -28,6 +28,7 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: mbstring, xml, ctype, iconv, pgsql coverage: xdebug #optional + tools: phpunit - name: Get composer cache directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" @@ -35,6 +36,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install Composer dependencies @@ -48,6 +51,4 @@ jobs: env: DATABASE_URL: postgres://postgres:postgres@127.0.0.1:${{ job.services.postgres.ports[5432] }}/postgres?charset=UTF-8 - name: Run Tests - run: | - composer require phpunit - php bin/phpunit --coverage-text \ No newline at end of file + run: phpunit --coverage-text \ No newline at end of file diff --git a/examples/symfony.yml b/examples/symfony.yml index 75454992..169b74f1 100644 --- a/examples/symfony.yml +++ b/examples/symfony.yml @@ -19,6 +19,7 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: mbstring, xml, ctype, iconv coverage: xdebug #optional + tools: phpunit - name: Get composer cache directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" @@ -26,6 +27,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install Composer dependencies @@ -33,6 +36,4 @@ jobs: composer require symfony/orm-pack composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader - name: Run Tests - run: | - composer require phpunit - php bin/phpunit --coverage-text \ No newline at end of file + run: phpunit --coverage-text \ No newline at end of file diff --git a/examples/yii2-mysql.yml b/examples/yii2-mysql.yml index 117a7797..ebb3b827 100644 --- a/examples/yii2-mysql.yml +++ b/examples/yii2-mysql.yml @@ -45,6 +45,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install Composer dependencies diff --git a/examples/yii2-postgres.yml b/examples/yii2-postgres.yml index 87c58f3a..03539b4b 100644 --- a/examples/yii2-postgres.yml +++ b/examples/yii2-postgres.yml @@ -45,6 +45,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install Composer dependencies diff --git a/examples/zend-framework.yml b/examples/zend-framework.yml index 4858d350..c293aeb0 100644 --- a/examples/zend-framework.yml +++ b/examples/zend-framework.yml @@ -24,6 +24,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- - name: Install dependencies