Improve examples and documentation

This commit is contained in:
Shivam Mathur 2019-12-28 00:23:51 +05:30
parent de32d8b95f
commit 8e1cde2d0a
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
19 changed files with 61 additions and 25 deletions

View File

@ -13,7 +13,7 @@
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a> <a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
</p> </p>
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 ## Contents
@ -50,7 +50,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|7.4|`Stable`|`Active`| |7.4|`Stable`|`Active`|
|8.0|`Experimental`|`In development`| |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 ## :cloud: OS/Platform Support
@ -70,19 +70,9 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
## :wrench: Tools 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` `composer`, `codeception`, `deployer`, `pecl`, `phpcbf`, `phpcpd`, `php-cs-fixer`, `phpcs`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`
- `phpcs`
- `phpcbf`
- `phpcpd`
- `phpstan`
- `phpmd`
- `codeception`
- `phpunit`
- `deployer`
- `prestissimo`
- `pecl`
```yml ```yml
uses: shivammathur/setup-php@v1 uses: shivammathur/setup-php@v1
@ -91,6 +81,8 @@ with:
tools: php-cs-fixer, phpunit tools: php-cs-fixer, phpunit
``` ```
**Note:** `composer` is setup by default, so that is not required to be specified.
## :signal_strength: Coverage support ## :signal_strength: Coverage support
### Xdebug ### 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. Consider disabling the coverage using this PHP action for these reasons.
- You are not generating coverage reports while testing. - 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. - You are using `phpdbg` for running your tests.
```yaml ```yaml
@ -203,6 +195,7 @@ jobs:
- `PECL` is installed by default with this version on `ubuntu`. - `PECL` is installed by default with this version on `ubuntu`.
- Some extensions might not support this version currently. - 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 [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 ```yaml
steps: steps:
@ -233,7 +226,7 @@ You can persist composer's internal cache directory using the [`action/cache`](h
- name: Cache dependencies - name: Cache dependencies
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- 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 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 ### 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. 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.

View File

@ -22,6 +22,8 @@ jobs:
- uses: actions/cache@v1 - uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -24,6 +24,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies - name: Install dependencies

View File

@ -48,6 +48,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -50,6 +50,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -26,6 +26,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -48,6 +48,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -50,6 +50,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -26,6 +26,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -30,6 +30,8 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
# For phalcon 3.x, use
# php-versions: ['7.0', '7.1', '7.2', '7.3']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
@ -46,6 +48,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -31,6 +31,8 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
# For phalcon 3.x, use
# php-versions: ['7.0', '7.1', '7.2', '7.3']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
@ -47,6 +49,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -39,6 +39,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install yarn dependencies - name: Install yarn dependencies

View File

@ -24,6 +24,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies - name: Install dependencies

View File

@ -28,6 +28,7 @@ jobs:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, mysql extensions: mbstring, xml, ctype, iconv, mysql
coverage: xdebug #optional coverage: xdebug #optional
tools: phpunit
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)" run: echo "::set-output name=dir::$(composer config cache-files-dir)"
@ -35,6 +36,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies
@ -48,6 +51,4 @@ jobs:
env: env:
DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony
- name: Run Tests - name: Run Tests
run: | run: phpunit --coverage-text
composer require phpunit
php bin/phpunit --coverage-text

View File

@ -28,6 +28,7 @@ jobs:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, pgsql extensions: mbstring, xml, ctype, iconv, pgsql
coverage: xdebug #optional coverage: xdebug #optional
tools: phpunit
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)" run: echo "::set-output name=dir::$(composer config cache-files-dir)"
@ -35,6 +36,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies
@ -48,6 +51,4 @@ jobs:
env: env:
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:${{ job.services.postgres.ports[5432] }}/postgres?charset=UTF-8 DATABASE_URL: postgres://postgres:postgres@127.0.0.1:${{ job.services.postgres.ports[5432] }}/postgres?charset=UTF-8
- name: Run Tests - name: Run Tests
run: | run: phpunit --coverage-text
composer require phpunit
php bin/phpunit --coverage-text

View File

@ -19,6 +19,7 @@ jobs:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv extensions: mbstring, xml, ctype, iconv
coverage: xdebug #optional coverage: xdebug #optional
tools: phpunit
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)" run: echo "::set-output name=dir::$(composer config cache-files-dir)"
@ -26,6 +27,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies
@ -33,6 +36,4 @@ jobs:
composer require symfony/orm-pack composer require symfony/orm-pack
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Run Tests - name: Run Tests
run: | run: phpunit --coverage-text
composer require phpunit
php bin/phpunit --coverage-text

View File

@ -45,6 +45,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -45,6 +45,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -24,6 +24,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} 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') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies - name: Install dependencies