Skip to content

Commit

Permalink
Merge pull request #3 from cerpus/add-workflow
Browse files Browse the repository at this point in the history
Add github workflow, proper version constraints
  • Loading branch information
emmachughes authored Feb 25, 2022
2 parents 7ad543c + 5d58a78 commit 2292a73
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 14 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Run PHPUnit

on: [push, pull_request]

jobs:
phpunit:
name: PHPUnit (PHP ${{ matrix.php-version }}, Laravel ${{ matrix.laravel-constraint }})
runs-on: ubuntu-20.04

strategy:
fail-fast: false
matrix:
include:
- php-version: '7.4'
laravel-constraint: '^8.0'
guzzle-constraint: '^6.0'

- php-version: '8.0'
laravel-constraint: '^8.0'
guzzle-constraint: '^7.0'

- php-version: '8.0'
laravel-constraint: '^9.0'
guzzle-constraint: '^7.0'

- php-version: '8.1'
laravel-constraint: '^8.0'
guzzle-constraint: '^7.0'

- php-version: '8.1'
laravel-constraint: '^9.0'
guzzle-constraint: '^7.0'

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: pcov

- name: Get Composer cache dir
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php-version }}-laravel-${{ matrix.laravel-constraint }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-laravel-${{ matrix.laravel-constraint }}-composer-

- name: Install dependencies
run: composer update
--no-progress
--prefer-dist
--optimize-autoloader
--with illuminate/support:${{ matrix.laravel-constraint }}
--with guzzlehttp/guzzle:${{ matrix.guzzle-constraint }}

- name: Run PHPUnit
run: vendor/bin/phpunit --coverage-clover=clover.xml

- name: Publish coverage
uses: slavcodev/coverage-monitor-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
coverage_path: clover.xml

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"php": "^7.4 || ^8.0",
"ext-json": "*",
"cerpus/cerpushelper": "^2.0",
"illuminate/support": "*"
"guzzlehttp/guzzle": "^6.0|^7.0",
"illuminate/support": "^8.0|^9.0"
},
"require-dev": {
"shrikeh/teapot": "^2.3",
Expand Down
34 changes: 21 additions & 13 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="QuestionBankClient Test Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>

<testsuites>
<testsuite name="QuestionBankClient Test Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
</phpunit>

0 comments on commit 2292a73

Please sign in to comment.