Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 51 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,70 @@ on:
pull_request:

jobs:
tests:
# Run lowest tests first as a batch
tests-lowest:
Comment thread
Orfawn marked this conversation as resolved.
runs-on: ubuntu-latest
continue-on-error: true

strategy:
fail-fast: false
matrix:
php: [8.2, 8.3, 8.4, 8.5]

name: PHP ${{ matrix.php }} - prefer-lowest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Fetch 10 commits or Scrutinizer will throw ("Failed to retrieve commit parents. If you use a shallow git checkout, please checkout at least a depth of one."), see: RepositoryIntrospector at scrutinizer-ci/ocular GitHub repository
# 10 commits is an arbitrary value that is more than 1 commit
fetch-depth: 10

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

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

- name: Install dependencies
run: composer update --prefer-lowest --prefer-dist --no-interaction

- name: Execute tests
run: vendor/bin/phpunit --coverage-clover=coverage.clover

- name: Upload Code Coverage
continue-on-error: true
run: vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover || true

# Run stable tests after lowest tests complete
tests-stable:
runs-on: ubuntu-latest
needs: tests-lowest

strategy:
fail-fast: true
matrix:
php: [8.1, 8.2]
stability: [prefer-lowest, prefer-stable]
php: [8.2, 8.3, 8.4, 8.5]

name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
name: PHP ${{ matrix.php }} - prefer-stable

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
# Fetch 10 commits or Scrutinizer will throw ("Failed to retrieve commit parents. If you use a shallow git checkout, please checkout at least a depth of one."), see: RepositoryIntrospector at scrutinizer-ci/ocular GitHub repository
# 10 commits is an arbitrary value that is more than 1 commit
fetch-depth: 10

- name: Cache dependencies
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
Expand All @@ -38,14 +80,14 @@ jobs:
coverage: pcov

- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-suggest
Comment thread
Orfawn marked this conversation as resolved.
run: composer update --prefer-stable --prefer-dist --no-interaction

- name: PHP Security Checker
uses: symfonycorp/security-checker-action@v5
if: ${{ matrix.stability == 'prefer-stable' }}

- name: Execute tests
run: vendor/bin/phpunit --coverage-clover=coverage.clover

- name: Upload Code Coverage
run: vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover
Comment thread
Orfawn marked this conversation as resolved.
continue-on-error: true
run: vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover || true
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
{
"name": "Jimmy Puckett",
"email": "jimmy.puckett@spinen.com"
},
{
"name": "Sebastian J. Brown",
"email": "sebastian@orfawn.io"
}
],
"require": {
"php": "^8.1",
"php": "^8.2",
"ext-json": "*",
"guzzlehttp/guzzle": "^7.0",
"laravel/framework": "^9.19|^10|^11|^12",
"laravel/framework": "^10|^11|^12",
"nesbot/carbon": "^2.62.1|^3",
"spinen/laravel-version": "^1.5"
},
Expand Down
23 changes: 9 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@
colors="true"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<directory>./src/Contracts</directory>
<directory>./src/Exceptions</directory>
<directory>./src/Providers</directory>
</exclude>
<report>
<clover outputFile="build/phpunit/logs/clover.xml"/>
<html outputDirectory="./build/phpunit/coverage" lowUpperBound="35" highLowerBound="70"/>
Expand All @@ -27,24 +35,11 @@
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<php>
<!-- <env name="VARIABLE" value="value"/> -->
</php>
<logging>
<junit outputFile="./build/phpunit/logs/junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<directory>./src/Contracts</directory>
<directory>./src/Exceptions</directory>
<directory>./src/Providers</directory>
</exclude>
</source>
</phpunit>
13 changes: 13 additions & 0 deletions tests/Unit/Support/Stubs/Model.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Tests\Unit\Support\Stubs;

use Spinen\Ncentral\Support\Model as BaseModel;

class Model extends BaseModel
{
/**
* Path to API endpoint.
*/
protected string $path = '/test';
}