Skip to content

Commit

Permalink
refactor: Merge upstream (#23)
Browse files Browse the repository at this point in the history
* refactor: Merge upstream

* refactor: Merge upstream

* fix: Tests on Laravel 10
  • Loading branch information
oprypkhantc authored Jul 5, 2023
1 parent 20229b3 commit d768688
Show file tree
Hide file tree
Showing 59 changed files with 232 additions and 2,354 deletions.
14 changes: 14 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/.github export-ignore
/art export-ignore
/docs export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php-cs-fixer.dist.php export-ignore
/.releaserc.yml export-ignore
/CONTRIBUTING.md export-ignore
/phpstan.neon export-ignore
/phpunit.xml export-ignore
/README.md export-ignore
/UPGRADING.md export-ignore
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release

on:
workflow_run:
workflows: ["Tests"]
types:
- completed
branches:
- master
- next
- next-major
- beta
- alpha

jobs:
release:
name: Release
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create a release
uses: cycjimmy/semantic-release-action@v3
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
17 changes: 0 additions & 17 deletions .github/workflows/tagger.yml

This file was deleted.

90 changes: 59 additions & 31 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
name: Tests

on:
push:
pull_request:
on: [push, pull_request]

jobs:
test:
name: Tests & PHPStan on PHP ${{ matrix.php }} ${{ matrix.prefer }}

phpunit:
name: PHPUnit on PHP v${{ matrix.php }} & TestBench ${{ matrix.test-bench }}
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [8.1]
prefer: [prefer-lowest, prefer-stable]
php: [ 8.1, 8.2 ]
test-bench: [ ^7.0, ^8.0 ]

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -31,35 +28,27 @@ jobs:

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.prefer }}-${{ hashFiles('**/composer.lock') }}
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.prefer }}-
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress && composer update --${{ matrix.prefer }}
run: |
composer require "orchestra/testbench=${{ matrix.test-bench }}" --dev --no-update
composer install --prefer-dist --no-progress
- name: Execute tests
- name: Execute phpunit
run: composer test -- --colors=always

# Those should usually be a separate job, but as GitHub Actions currently does not support any form of sharing
# steps or an image between them, extracting those to a separate job would mean a full blown copy-paste of this one.
- name: Install dependencies
run: composer install --prefer-dist --no-progress --working-dir=tools/phpstan

- name: Run phpstan
run: composer phpstan

code-style:
name: Code style

php-cs-fixer:
name: php-cs-fixer
runs-on: ubuntu-latest

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -71,15 +60,54 @@ jobs:

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --working-dir=tools/php-cs-fixer
run: composer install --prefer-dist --no-progress

- name: Run php-cs-fixer
- name: Execute php-cs-fixer
run: composer cs-fix -- --dry-run --diff --using-cache=no

phpstan:
name: PHPStan on PHP v${{ matrix.php }} & TestBench ${{ matrix.test-bench }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [ 8.1, 8.2 ]
test-bench: [ ^7.0, ^8.0 ]
steps:
- name: Checkout code
uses: actions/checkout@v3

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

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

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: |
composer require "orchestra/testbench=${{ matrix.test-bench }}" --dev --no-update
composer install --prefer-dist --no-progress
- name: Execute phpstan
run: composer phpstan
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

# Build/coverage
/build
/coverage

# Cache
.php_cs.cache
.php-cs-fixer.cache
.phpunit.cache
**/.phpunit.result.cache

# Temporary
Expand Down
22 changes: 12 additions & 10 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in('src')
->in('tests')
require __DIR__ . '/vendor/kubawerlos/php-cs-fixer-custom-fixers/bootstrap.php';
require __DIR__ . '/vendor/tenantcloud/php-cs-fixer-rule-sets/bootstrap.php';

use PhpCsFixer\Finder;
use TenantCloud\PhpCsFixer\Config;

$finder = Finder::create()
->in(__DIR__)
->exclude('build')
->exclude('tmp')
->exclude('vendor')
->name('*.php')
->notName('_*.php')
->ignoreVCS(true);

return (new PhpCsFixer\Config())
->setFinder($finder)
->setRiskyAllowed(true)
->setIndent("\t")
->setRules([
'@TenantCloud' => true,
]);
return Config::make()->setFinder($finder);
6 changes: 6 additions & 0 deletions .releaserc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
plugins:
- '@semantic-release/commit-analyzer'
- '@semantic-release/release-notes-generator'
- '@semantic-release/changelog'
- '@semantic-release/git'
- '@semantic-release/github'
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Commands

Here are some of the commands that you'll need:
- install dependencies: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer install`
- run tests with phpunit: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer test`
- reformat using php-cs-fixer: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer cs-fix`
- analyse with phpstan: `docker run -it --rm -v $PWD:/app -w /app chialab/php-dev:8.2 composer phpstan`
124 changes: 66 additions & 58 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,68 @@
{
"name": "tenantcloud/php-json-api",
"description": "A template for composer packages",
"minimum-stability": "dev",
"license": "MIT",
"require": {
"php": ">=7.4 || ^8.0",
"tenantcloud/php-standard": "^2.0",
"illuminate/support": "^8.0 || ^9.0",
"spatie/laravel-fractal": "^5.4 || ^6.0",
"tenantcloud/data-transfer-objects": "^1.0",
"tenantcloud/laravel-api-versioning": "v1.0.0-alpha.1"
},
"require-dev": {
"pestphp/pest": "^1.0",
"phpunit/phpunit": "^9.5",
"orchestra/testbench": "^6.22 || ^7.0",
"php-cs-fixer/shim": "^3.6.0",
"tenantcloud/php-cs-fixer-rule-sets": "~2.0.0"
},
"conflict": {
"league/fractal": "<0.20"
},
"autoload": {
"psr-0": {
"": "src/"
},
"files": [
"src/TenantCloud/JsonApi/functions.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"repositories": [
{
"type": "git",
"url": "https://github.com/tenantcloud/laravel-api-versioning"
}
],
"scripts": {
"test": "./vendor/bin/pest",
"cs-fix": "./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix -v --show-progress=dots",
"phpstan": "./tools/phpstan/vendor/bin/phpstan analyse"
},
"extra": {
"laravel": {
"providers": [
"TenantCloud\\JsonApi\\JsonApiServiceProvider"
]
}
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
}
}
"name": "tenantcloud/php-json-api",
"description": "A template for composer packages",
"license": "MIT",
"require": {
"php": ">=8.1",
"tenantcloud/php-standard": "^2.0",
"illuminate/support": "^9.0 || ^10.0",
"spatie/laravel-fractal": "^5.4 || ^6.0",
"tenantcloud/data-transfer-objects": "^1.0",
"tenantcloud/laravel-api-versioning": "v1.0.0-alpha.1 || v1.0.0-alpha.2",
"illuminate/contracts": "^9.0|^10.0"
},
"require-dev": {
"pestphp/pest": "^1.0|^2.8",
"orchestra/testbench": "^7.0|^8.5",
"php-cs-fixer/shim": "3.19.1",
"tenantcloud/php-cs-fixer-rule-sets": "~3.0.0",
"phpstan/phpstan": "~1.10.21",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-webmozart-assert": "^1.2",
"phpstan/phpstan-mockery": "^1.1",
"nunomaduro/larastan": "^2.6"
},
"conflict": {
"league/fractal": "<0.20"
},
"autoload": {
"psr-4": {
"TenantCloud\\JsonApi\\": "src/"
},
"files": [
"src/functions.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"repositories": [
{
"type": "git",
"url": "https://github.com/tenantcloud/laravel-api-versioning"
}
],
"scripts": {
"test": "vendor/bin/pest",
"coverage": "XDEBUG_MODE=coverage vendor/bin/pest --coverage-html coverage",
"cs-fix": "vendor/bin/php-cs-fixer fix -v --show-progress=dots",
"phpstan": "vendor/bin/phpstan analyse --memory-limit=2G",
"testbench": "vendor/bin/testbench"
},
"minimum-stability": "alpha",
"prefer-stable": true,
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"extra": {
"laravel": {
"providers": [
"TenantCloud\\JsonApi\\JsonApiServiceProvider"
]
}
}
}
6 changes: 5 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
includes:
- tools/phpstan/vendor/phpstan/phpstan/conf/bleedingEdge.neon
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-webmozart-assert/extension.neon
- vendor/phpstan/phpstan-mockery/extension.neon
- vendor/nunomaduro/larastan/extension.neon

parameters:
level: 1
Expand Down
Loading

0 comments on commit d768688

Please sign in to comment.