-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: github actions php workflow
- Loading branch information
Showing
3 changed files
with
178 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
name: 'php' | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- '**/*.php' | ||
push: | ||
paths: | ||
- '**/*.php' | ||
|
||
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-18.04' | ||
|
||
strategy: | ||
matrix: | ||
php-version: [7.2] | ||
|
||
steps: | ||
- name: 'Checkout current revision' | ||
uses: 'actions/checkout@v2' | ||
|
||
- name: 'Setup PHP' | ||
uses: 'shivammathur/setup-php@v2' | ||
with: | ||
php-version: '${{ matrix.php-version }}' | ||
tools: 'composer:v1' | ||
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 -p --extensions=php \ | ||
--standard=vendor/cakephp/cakephp-codesniffer/CakePHP \ | ||
./config ./src ./tests | ||
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-18.04' | ||
continue-on-error: true | ||
|
||
strategy: | ||
matrix: | ||
php-version: [7.2, 7.3, 7.4] | ||
|
||
steps: | ||
- name: 'Checkout current revision' | ||
uses: 'actions/checkout@v2' | ||
|
||
- name: 'Setup PHP' | ||
uses: 'shivammathur/setup-php@v2' | ||
with: | ||
php-version: '${{ matrix.php-version }}' | ||
tools: 'composer:v1, phpstan' | ||
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: | | ||
phpstan analyse --no-progress src | ||
unit: | ||
name: 'Run unit tests' | ||
if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')" | ||
runs-on: 'ubuntu-18.04' | ||
env: | ||
BEDITA_API_KEY: 12345 | ||
BEDITA_API: http://127.0.0.1:8080 | ||
BEDITA_ADMIN_USR: admin | ||
BEDITA_ADMIN_PWD: admin | ||
BEDITA_DOCKER_IMG: bedita/bedita:4.2.1 | ||
|
||
strategy: | ||
matrix: | ||
php-version: [7.2, 7.3, 7.4] | ||
|
||
steps: | ||
- name: 'Checkout current revision' | ||
uses: 'actions/checkout@v2' | ||
|
||
- name: 'Composer config GH token if available' | ||
run: 'if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi' | ||
|
||
- name: 'Docker pull bedita image' | ||
run: 'docker pull ${BEDITA_DOCKER_IMG}' | ||
|
||
- name: 'Docker inspect bedita image' | ||
run: 'docker inspect ${BEDITA_DOCKER_IMG}' | ||
|
||
- name: 'Docker run bedita image' | ||
run: 'docker run --name api -d -p 127.0.0.1:8080:80 --env BEDITA_API_KEY=${BEDITA_API_KEY} --env BEDITA_ADMIN_USR=${BEDITA_ADMIN_USR} --env BEDITA_ADMIN_PWD=${BEDITA_ADMIN_PWD} ${BEDITA_DOCKER_IMG}' | ||
|
||
- name: 'Wait for 10' | ||
run: 'sleep 10' | ||
|
||
- name: 'Docker ps - show all containers' | ||
run: 'docker ps -a' | ||
|
||
- name: 'Setup PHP' | ||
uses: 'shivammathur/setup-php@v2' | ||
with: | ||
php-version: '${{ matrix.php-version }}' | ||
tools: 'composer:v1' | ||
extensions: 'mbstring, intl' | ||
|
||
- 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-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}" | ||
restore-keys: | | ||
composer-${{ matrix.php-version }}- | ||
composer- | ||
- name: 'Install dependencies with Composer' | ||
run: 'composer install --prefer-dist --no-interaction' | ||
|
||
- name: 'Run PHPUnit with coverage' | ||
run: 'vendor/bin/phpunit --coverage-clover=clover.xml' | ||
|
||
- name: Check test coverage | ||
id: test-coverage | ||
uses: johanvanhelden/gha-clover-test-coverage-check@v1 | ||
with: | ||
percentage: '85' | ||
filename: 'clover.xml' | ||
|
||
- name: 'Export coverage results' | ||
uses: 'codecov/codecov-action@v1' | ||
with: | ||
file: './clover.xml' | ||
env_vars: PHP_VERSION | ||
|
||
- name: 'Archive code coverage results' | ||
uses: 'actions/upload-artifact@v2' | ||
with: | ||
name: 'PHP ${{ matrix.php }}' | ||
path: 'clover.xml' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters