Skip to content

Commit

Permalink
Add github actions (#79)
Browse files Browse the repository at this point in the history
* Create php.yml
* Test code coverage with PCOV.
* Adds ext-pcov.
* Adds multiple versions of php and OS.
* Removes coveralls.
* Specifies version for pcov and cache.
* Adds phpunit configuration for pcov.
* Ignore tests/logs directory for phpcs test.
* Restricts GH actions to PHP >= 7.3.
* Tidies up phpunit.
  • Loading branch information
typhonius committed Oct 8, 2020
1 parent 1b62520 commit 9321b5f
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 4 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: PHP Composer

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
run:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest, macos-latest]
php-versions: ['7.3', '7.4']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl
ini-values: post_max_size=256M, short_open_tag=On


- name: Setup PHP with pecl extension
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: pecl
extensions: pcov

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-versions }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-versions }}-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-source --no-progress --no-suggest --no-interaction

- name: Setup PCOV
run: |
composer require pcov/clobber
vendor/bin/pcov clobber
- name: Run test suite
run: composer run-script test

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
"find src -name '*.php' -print0 | xargs -0 -n1 php -l",
"find tests -name '*.php' -print0 | xargs -0 -n1 php -l"
],
"cs": "phpcs --standard=PSR12 -n src tests",
"cs": "phpcs --standard=PSR12 -n src tests --ignore=./tests/logs/*",
"cbf": "phpcbf --standard=PSR2 -n src tests",
"unit": "phpunit --colors=always --coverage-clover ./tests/logs/clover.xml",
"unit": "php -dpcov.enabled=1 -dpcov.directory=. -dpcov.exclude='~vendor~' ./vendor/bin/phpunit --configuration=phpunit.xml --testdox",
"stan": "phpstan analyse --level 5 src tests",
"test": [
"@lint",
Expand Down
13 changes: 11 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php">
<phpunit
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
verbose="true"
>
<testsuites>
<testsuite name="Acquia Cloud PHP SDK Binding">
<directory suffix=".php">./tests/</directory>
Expand All @@ -11,6 +18,8 @@
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="tests/logs/clover.xml"/>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="true"/>
<log type="coverage-clover" target="tests/logs/clover.xml" showUncoveredFiles="true"/>
<log type="coverage-html" target="tests/logs/phpunit.html" lowUpperBound="35" highLowerBound="70"/>
</logging>
</phpunit>

0 comments on commit 9321b5f

Please sign in to comment.