Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed Feb 20, 2023
1 parent def3e63 commit 8a851a4
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 57 deletions.
77 changes: 31 additions & 46 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: pcov

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
Expand All @@ -31,15 +25,20 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: pcov

- name: Install dependencies
run: |
composer update --no-interaction --verbose
run: composer update

- name: Check platform requirements
run: composer check-platform-reqs --verbose
run: composer check-platform-reqs

- name: PHP-CS-Fixer
run: composer fix -- --dry-run --verbose
run: composer fix -- --dry-run

# - name: composer normalize
# run: composer normalize --dry-run --no-interaction --verbose
Expand Down Expand Up @@ -67,74 +66,60 @@ jobs:

tests:
runs-on: ubuntu-latest
name: 'PHP: ${{ matrix.php }}; Lara: ${{ matrix.laravel }}; Deps: ${{ matrix.dependency-version }}'
name: 'PHP: ${{ matrix.php }}; Laravel: ${{ matrix.laravel }}; Prefer: ${{ matrix.prefer }}'
strategy:
matrix:
php: ['8.0', '8.1', '8.2']
laravel: ['^8.73.2', '^9.0', '10.x-dev']
dependency-version: ['prefer-lowest', 'prefer-stable']
php: ['8.1', '8.2']
laravel: ['^9.0', '^10.0']
prefer: ['prefer-lowest', 'prefer-stable']
include:
- testbench: '^6.0'
laravel: '^8.73.2'
- testbench: '^7.0'
laravel: '^9.0'
- testbench: '8.x-dev'
laravel: '10.x-dev'
exclude:
- php: '8.0'
laravel: '10.x-dev'
- testbench: '^8.0'
laravel: '^10.0'

steps:
- name: checkout code
uses: actions/checkout@v3

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

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

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

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

- name: Remove dev packages
run: |
composer remove --dev --no-update --no-interaction --verbose \
composer remove --dev --no-update \
friendsofphp/php-cs-fixer \
infection/infection \
nunomaduro/larastan \
phpstan/phpstan-strict-rules
- name: Require Laravel and Testbench version
run: composer require laravel/framework:"${{ matrix.laravel }}" illuminate/collections:"${{ matrix.laravel }}" illuminate/database:"${{ matrix.laravel }}" illuminate/http:"${{ matrix.laravel }}" illuminate/support:"${{ matrix.laravel }}" orchestra/testbench:"${{ matrix.testbench }}" --no-update --no-interaction --verbose --with-all-dependencies

- name: Support prefer-lowest in PHP 8.0
if: ${{ matrix.php == 8.0 && matrix.dependency-version == 'prefer-lowest' }}
run: composer require --no-update \
mockery/mockery:"^1.3.3"
run: composer require --no-update laravel/framework:"${{ matrix.laravel }}" illuminate/collections:"${{ matrix.laravel }}" illuminate/database:"${{ matrix.laravel }}" illuminate/http:"${{ matrix.laravel }}" illuminate/support:"${{ matrix.laravel }}" orchestra/testbench:"${{ matrix.testbench }}"

- name: Support prefer-lowest in PHP 8.1
if: ${{ matrix.php == 8.1 && matrix.dependency-version == 'prefer-lowest' }}
run: composer require --no-update \
nesbot/carbon:"^2.62.1" \
symfony/http-foundation:"^5.3.7 || ^6.0"
if: ${{ matrix.php == 8.1 && matrix.prefer == 'prefer-lowest' }}
run: composer require --no-update nesbot/carbon:"^2.62.1"

- name: Support prefer-lowest in PHP 8.2
if: ${{ matrix.php == 8.2 && matrix.dependency-version == 'prefer-lowest' }}
run: composer require --no-update \
nesbot/carbon:"^2.62.1" \
symfony/http-foundation:"^5.3.7 || ^6.0"
if: ${{ matrix.php == 8.2 && matrix.prefer == 'prefer-lowest' }}
run: composer require --no-update nesbot/carbon:"^2.62.1"

- name: Install dependencies
run: composer update --${{ matrix.dependency-version }} --no-interaction --verbose
run: composer update --${{ matrix.prefer }}

- name: Check platform requirements
run: composer check-platform-reqs --verbose
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ A lightweight API resource for Laravel that helps you adhere to the `JSON:API` s

## Version support

- **PHP**: `8.0`, `8.1`, `8.2`
- **PHP**: `8.1`, `8.2`
- **Laravel**: `^8.73.2`, `^9.0`, `10.x-dev`

## Installation
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
}
],
"require": {
"php": "^8.0 || ^8.1 || ^8.2",
"illuminate/collections": "^8.73.2 || ^9.0 || 10.x-dev",
"illuminate/database": "^8.73.2 || ^9.0 || 10.x-dev|^10.0",
"illuminate/http": "^8.73.2 || ^9.0 || 10.x-dev|^10.0",
"illuminate/support": "^8.73.2 || ^9.0 || 10.x-dev|^10.0",
"symfony/http-kernel": "^5.0 || ^6.0"
"php": "^8.1 || ^8.2",
"illuminate/collections": "^9.0 || ^10.0",
"illuminate/database": "^9.0 || ^10.0",
"illuminate/http": "^9.0 || ^10.0",
"illuminate/support": "^9.0 || ^10.0",
"symfony/http-kernel": "^6.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.13",
"laravel/framework": "^8.73.2 || ^9.0 || 10.x-dev|^10.0",
"laravel/framework": "^9.0 || ^10.0",
"opis/json-schema": "^2.3",
"orchestra/testbench": "^6.0 || ^7.0 || 8.x-dev|^8.0",
"orchestra/testbench": "^7.0 || ^8.0",
"phpunit/phpunit": "^9.0"
},
"config": {
Expand Down
2 changes: 2 additions & 0 deletions src/Concerns/Links.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Illuminate\Support\Collection;
use TiMacDonald\JsonApi\Link;

use function is_string;

trait Links
{
/**
Expand Down
5 changes: 3 additions & 2 deletions tests/Unit/LinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

namespace Tests\Unit;

use Illuminate\Container\Container;
use Illuminate\Http\Request;
use PHPUnit\Framework\TestCase;
use Tests\Resources\BasicJsonApiResource;
use TiMacDonald\JsonApi\Concerns\Links;
use TiMacDonald\JsonApi\JsonApiResource;
use TiMacDonald\JsonApi\Link;

Expand Down Expand Up @@ -73,5 +71,8 @@ public function testItCanUseHash()
$links = json_encode($resource->toArray($request)['links']);

$this->assertSame('{"foo":{"href":"http:\/\/foo.com","meta":{}}}', $links);

JsonApiResource::resolveIdNormally();
JsonApiResource::resolveTypeNormally();
}
}

0 comments on commit 8a851a4

Please sign in to comment.