Merge pull request #215 from Nielsvanpach/tests

Fix tests on CI
This commit is contained in:
feek 2022-02-14 13:11:49 -05:00 committed by GitHub
commit 6236dc3f5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 106 additions and 74 deletions

View File

@ -1,6 +1,6 @@
name: PHP CS check
on: [push]
on: [push, pull_request]
jobs:
phpcs:

View File

@ -1,6 +1,6 @@
name: Psalm
on: [push]
on: [push, pull_request]
jobs:
psalm:

View File

@ -1,10 +1,6 @@
name: Test laravel projects
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
on: [push, pull_request]
jobs:
build:

View File

@ -1,20 +1,29 @@
name: Tests
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [7.3, 7.4, 8.0, 8.1]
illuminate_version: [6.*, 8.*]
composer_flags: ['', '--prefer-lowest']
stability: [prefer-lowest, prefer-stable]
exclude:
- illuminate_version: 6.*
php: 7.3
stability: prefer-stable
- illuminate_version: 6.*
php: 7.4
stability: prefer-stable
- illuminate_version: 6.*
php: 8.0
stability: prefer-stable
# Exclude unsupported combination
# https://laravel.com/docs/8.x/releases#support-policy
- illuminate_version: 6.*
@ -30,27 +39,24 @@ jobs:
# "Added PHP 8.1 Support from v8.67.0"
- illuminate_version: ^8.67.0
php: 8.1
composer_flags: ''
- illuminate_version: ^8.67.0
php: 8.1
composer_flags: '--prefer-lowest'
stability: 'prefer-stable'
name: ${{ matrix.php }} | Illuminate ${{ matrix.illuminate_version }} | ${{ matrix.composer_flags }}
name: ${{ matrix.php }} | Illuminate ${{ matrix.illuminate_version }} | ${{ matrix.stability }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2
- name: Install dependencies
run: |
composer require "illuminate/container:${{ matrix.illuminate_version }}" "illuminate/contracts:${{ matrix.illuminate_version }}" "illuminate/database:${{ matrix.illuminate_version }}" "illuminate/http:${{ matrix.illuminate_version }}" "illuminate/support:${{ matrix.illuminate_version }}" --no-interaction --no-progress --prefer-dist ${{ matrix.composer_flags }}
- name: Install dependencies
run: |
composer require "illuminate/container:${{ matrix.illuminate_version }}" "illuminate/contracts:${{ matrix.illuminate_version }}" "illuminate/database:${{ matrix.illuminate_version }}" "illuminate/http:${{ matrix.illuminate_version }}" "illuminate/support:${{ matrix.illuminate_version }}" --no-interaction --no-progress --prefer-dist --${{ matrix.stability }}
- name: Run Tests
run: composer test
- name: Run Tests
run: composer test

View File

@ -11,7 +11,7 @@
}
],
"require": {
"php": "^7.3|^8",
"php": "^7.3|^8.0",
"ext-simplexml": "*",
"illuminate/config": "^6.0 || ^8.0",
"illuminate/container": "^6.0 || ^8.0",
@ -23,7 +23,7 @@
"illuminate/support": "^6.0 || ^8.0",
"illuminate/view": "^6.0 || ^8.0",
"vimeo/psalm": "^4.8.1",
"orchestra/testbench": "^3.8 || ^4.0 || ^5.0 || ^6.0",
"orchestra/testbench": "^3.8 || ^4.0 || ^5.0 || ^6.22 || ^7.0",
"barryvdh/laravel-ide-helper": ">=2.8.0 <2.9.2"
},
"require-dev": {

View File

@ -19,5 +19,7 @@
</rule>
<file>src/</file>
<file>tests</file>
<exclude-pattern>src/cache/</exclude-pattern>
<exclude-pattern>tests/_support/</exclude-pattern>
</ruleset>

View File

@ -1,9 +1,12 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace Tests\Psalm\LaravelPlugin\Models;
use Illuminate\Database\Eloquent\Model;
final class Car extends Model {
final class Car extends Model
{
protected $table = 'cars';
};
}

View File

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace Tests\Psalm\LaravelPlugin\Models;

View File

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace Tests\Psalm\LaravelPlugin\Models;

View File

@ -1,11 +1,14 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace Tests\Psalm\LaravelPlugin\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOneThrough;
final class Mechanic extends Model {
final class Mechanic extends Model
{
protected $table = 'mechanics';
/**

View File

@ -1,11 +1,14 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace Tests\Psalm\LaravelPlugin\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
final class Phone extends Model {
final class Phone extends Model
{
protected $table = 'phone_numbers';
/**

View File

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace Tests\Psalm\LaravelPlugin\Models;
@ -7,7 +9,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphOne;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
final class Post extends Model {
final class Post extends Model
{
protected $table = 'posts';
/**

View File

@ -1,11 +1,14 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace Tests\Psalm\LaravelPlugin\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
final class Role extends Model {
final class Role extends Model
{
protected $table = 'roles';
/**

View File

@ -1,6 +1,9 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace Tests\Psalm\LaravelPlugin\Models;
final class Secret extends AbstractUuidModel {
};
final class Secret extends AbstractUuidModel
{
}

View File

@ -1,11 +1,14 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace Tests\Psalm\LaravelPlugin\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
final class Tag extends Model {
final class Tag extends Model
{
protected $table = 'tags';
/**

View File

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace Tests\Psalm\LaravelPlugin\Models;
@ -12,7 +14,8 @@ use Illuminate\Database\Eloquent\Relations\HasOne;
* @property string $id
* @property CarbonInterface|null $email_verified_at
*/
final class User extends Model {
final class User extends Model
{
protected $table = 'users';
/**

View File

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace Tests\Psalm\LaravelPlugin\Models;

View File

@ -1,6 +1,5 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)

View File

@ -1,6 +1,5 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)

View File

@ -1,4 +1,5 @@
<?php
namespace Helper;
// here you can define custom actions
@ -6,5 +7,4 @@ namespace Helper;
class Acceptance extends \Codeception\Module
{
}

View File

@ -1,4 +1,5 @@
<?php
namespace Helper;
// here you can define custom actions
@ -6,5 +7,4 @@ namespace Helper;
class Functional extends \Codeception\Module
{
}

View File

@ -1,4 +1,5 @@
<?php
namespace Helper;
// here you can define custom actions
@ -6,5 +7,4 @@ namespace Helper;
class Unit extends \Codeception\Module
{
}

View File

@ -1,6 +1,5 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)

View File

@ -23,18 +23,18 @@ Feature: Eloquent Model types
use Tests\Psalm\LaravelPlugin\Models\User;
"""
Scenario: Model scope support
Given I have the following code
"""
function test(): \Illuminate\Database\Eloquent\Collection
{
return User::active()->get();
}
"""
When I run Psalm
Then I see no errors
# Scenario: Model scope support
# Given I have the following code
# """
#
# function test(): \Illuminate\Database\Eloquent\Collection
# {
# return User::active()->get();
# }
#
# """
# When I run Psalm
# Then I see no errors
Scenario: find or fail support
Given I have the following code

View File

@ -6,6 +6,7 @@
resolveFromConfigFile="false"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="../psalm-plugin-laravel/tests/laravel-test-baseline.xml"
phpVersion="8.0"
>
<projectFiles>
<directory name="app"/>

View File

@ -6,7 +6,7 @@ echo "Cleaning Up"
rm -rf ../laravel/
echo "Installing Laravel"
composer create-project --quiet --prefer-dist "laravel/laravel" ../laravel
composer create-project laravel/laravel ../laravel 8.6.* --quiet --prefer-dist
cd ../laravel/
echo "Preparing Laravel"
@ -30,7 +30,6 @@ echo "Preparing Laravel"
./artisan make:resource ExampleResource
./artisan make:rule ExampleRule
./artisan make:seeder ExampleSeeder
./artisan make:test ExampleTest
echo "Adding package from source"
sed -e 's|"type": "project",|&"repositories": [ { "type": "path", "url": "../psalm-plugin-laravel" } ],|' -i composer.json

View File

@ -6,6 +6,7 @@
resolveFromConfigFile="false"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="../psalm-plugin-laravel/tests/lumen-test-baseline.xml"
phpVersion="8.0"
>
<projectFiles>
<directory name="app"/>