Skip to content

Commit

Permalink
Use reusable PHP workflows in CI [master, 2.x] (#25)
Browse files Browse the repository at this point in the history
* refactor: php workflow

* feat: restore unit part
  • Loading branch information
didoda authored Sep 7, 2022
1 parent 4eb0601 commit fda3600
Showing 1 changed file with 8 additions and 72 deletions.
80 changes: 8 additions & 72 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,87 +4,24 @@ on:
pull_request:
paths:
- '**/*.php'
- '.github/workflows/*'
- '.github/workflows/php.yml'
- 'composer.json'
push:
paths:
- '**/*.php'
- '.github/workflows/*'
- '.github/workflows/php.yml'
- 'composer.json'

jobs:
cs:
name: 'Check coding style'
if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')"
runs-on: 'ubuntu-latest'

steps:
- name: 'Checkout current revision'
uses: 'actions/checkout@v2'

- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '7.4'
tools: 'composer'
extensions: 'mbstring, intl'
coverage: 'none'

- name: 'Discover Composer cache directory'
id: 'cachedir'
run: 'echo "::set-output name=path::$(composer global config cache-dir)"'

- name: 'Share Composer cache across runs'
uses: 'actions/cache@v2'
with:
path: '${{ steps.cachedir.outputs.path }}'
key: "composer-${{ github.job }}-${{ hashFiles('**/composer.json') }}"
restore-keys: |
composer-${{ github.job }}-
composer-
- name: 'Install dependencies with Composer'
run: 'composer install --prefer-dist --no-interaction'

- name: 'Run PHP CodeSniffer'
run: 'vendor/bin/phpcs -n'
uses: bedita/github-workflows/.github/workflows/php-cs.yml@v1
with:
php_versions: '["7.4", "8.0", "8.1"]'

stan:
name: 'Static code analyzer'
if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')"
runs-on: 'ubuntu-latest'
continue-on-error: true

steps:
- name: 'Checkout current revision'
uses: 'actions/checkout@v2'

- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '7.4'
tools: 'composer'
extensions: 'mbstring, intl'
coverage: 'none'

- name: 'Discover Composer cache directory'
id: 'cachedir'
run: 'echo "::set-output name=path::$(composer global config cache-dir)"'

- name: 'Share Composer cache across runs'
uses: 'actions/cache@v2'
with:
path: '${{ steps.cachedir.outputs.path }}'
key: "composer-${{ github.job }}-${{ hashFiles('**/composer.json') }}"
restore-keys: |
composer-${{ github.job }}-
composer-
- name: 'Install dependencies with Composer'
run: 'composer install --prefer-dist --no-interaction'

- name: 'Run PHP STAN'
run: 'vendor/bin/phpstan analyse --no-progress --error-format=github'
uses: bedita/github-workflows/.github/workflows/php-stan.yml@v1
with:
php_versions: '["7.4", "8.0", "8.1"]'

unit:
name: 'Run unit tests'
Expand Down Expand Up @@ -121,7 +58,6 @@ jobs:
restore-keys: |
composer-${{ matrix.php-version }}-
composer-
- name: 'Install dependencies with Composer'
run: 'composer install --prefer-dist --no-interaction'

Expand Down

0 comments on commit fda3600

Please sign in to comment.