Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update package dependencies and CI #16

Merged
merged 7 commits into from
Oct 16, 2023
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
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[**.{neon,neon.dist}]
indent_style = tab

[**.{yml,yaml}]
indent_size = 2
113 changes: 65 additions & 48 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,64 +12,81 @@ on:
jobs:
global-qa-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php:
- "8.2"

env:
extensions: ctype, dom, intl, json, mbstring, openssl, xml, zip, zlib
key: cache-v1

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

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}

- name: Cache extensions
uses: actions/cache@v3
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: 8.0
- name: Get composer cache directory
id: composer-cache
uses: actions/cache@v2
php-version: 8.2
extensions: ${{ env.extensions }}
tools: composer, pecl
coverage: xdebug
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: ramsey/composer-install@v2
with:
path: vendor
key: ${{ runner.os }}-php-8.0-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-8.0
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --dev
- name: GrumPHP
run: ./vendor/bin/grumphp run --testsuite=github_actions
- name: PHPUnit Coverage
run: ./vendor/bin/phpunit --coverage-clover coverage.xml
composer-options: "${{ matrix.composer-options }}"

- name: Setup Problem Matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run PHPMD
run: vendor/bin/phpmd src,tests text ruleset.xml

- name: Run PHP-CS-Fixer
run: vendor/bin/php-cs-fixer check --diff --verbose

- name: Run PHPStan
run: vendor/bin/phpstan

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

- name: Run Infection
run: vendor/bin/infection run
env:
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}

- name: Run Composer Require Checker
run: vendor/bin/composer-require-checker

- name: Run Roave Security Checker
run: composer update --dry-run roave/security-advisories

- uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
files: ./coverage.xml
flags: unittests # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
- name: Infection
run: ./vendor/bin/infection
env:
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}

psalm-over-php-versions:
strategy:
fail-fast: false
matrix:
php-versions: [ '8.0', '8.1' ]
include:
- php-versions: 8.0
env: COMPOSER_FLAGS="--prefer-lowest"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
- name: Get composer cache directory
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-versions }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-versions }}
- name: Install dependencies
run: composer install $COMPOSER_FLAGS --no-interaction --prefer-dist --dev
- name: Psalm
run: ./vendor/bin/psalm
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
/.idea
/.phpunit.result.cache
/coverage
/.php-cs-fixer.cache
/.phpunit.cache/
12 changes: 12 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

$finder = PhpCsFixer\Finder::create()->in(__DIR__);

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PER-CS2.0' => true,
])
->setFinder($finder);
30 changes: 21 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
}
],
"require": {
"php": ">=8.0",
"php": ">=8.2",
"jeckel-lab/contract": "^2.3",
"ramsey/uuid": "^4.1"
},
"require-dev": {
"phpro/grumphp": "^1.5",
"vimeo/psalm": "^4.12",
"phpro/grumphp": "^2.0",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.2",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-strict-rules": "^1.5",
"phpmd/phpmd": "^2.11",
"squizlabs/php_codesniffer": "^3.6",
"friendsofphp/php-cs-fixer": "^3.34",
"roave/security-advisories": "dev-latest",
"maglnet/composer-require-checker": "^3||^4",
"phpunit/phpunit": "^9.5",
"infection/infection": "^0.25"
},
"suggest": {
"vimeo/psalm": "Using psalm with this 'contract' will enable immutability and strong typing verification"
"phpunit/phpunit": "^10.4",
"infection/infection": "^0.27"
},
"license": "MIT",
"authors": [
Expand All @@ -44,5 +44,17 @@
"psr-4": {
"Tests\\JeckelLab\\IdentityContract\\": "tests/"
}
},
"config": {
"allow-plugins": {
"infection/extension-installer": true,
"phpro/grumphp": true,
"phpstan/extension-installer": true
}
},
"scripts": {
"test": "vendor/bin/phpunit --testdox",
"cs-fix": "vendor/bin/php-cs-fixer fix --diff --verbose",
"grumphp": "vendor/bin/grumphp run"
}
}
27 changes: 12 additions & 15 deletions grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ grumphp:
github_actions:
tasks:
- composer_require_checker
- phpcs
- phpcsfixer
- phpmd
- phpstan
- psalm

tasks:
phpcs:
whitelist_patterns:
- /^src\/(.*)/
phpcsfixer:
allow_risky: ~
cache_file: ~
config: .php-cs-fixer.dist.php
using_cache: ~
config_contains_finder: false
verbose: true
diff: false
triggered_by: ['php']
phpmd:
whitelist_patterns:
- /^src\/(.*)/
ruleset:
- ./ruleset.xml
psalm:
config: psalm.xml
threads: 1
triggered_by: ['php']
show_info: true
phpunit:
config_file: ~
testsuite: ~
Expand All @@ -40,10 +41,6 @@ grumphp:
- "feature/*"
- "bugfix/*"
- "hotfix/*"
blacklist:
- "develop"
- "master"
- "main"
additional_modifiers: ''
allow_detached_head: true
infection:
# infection:
5 changes: 0 additions & 5 deletions infection.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,5 @@
},
"mutators": {
"@default": true
},
"logs": {
"badge": {
"branch": "main"
}
}
}
29 changes: 15 additions & 14 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory suffix=".php">src/CodeceptionHelper</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php" cacheDirectory=".phpunit.cache">
<coverage/>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory suffix=".php">src/CodeceptionHelper</directory>
</exclude>
</source>
</phpunit>
16 changes: 0 additions & 16 deletions psalm.xml

This file was deleted.

4 changes: 1 addition & 3 deletions src/Exception/EnableToGenerateNewIdentityException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,4 @@
* @psalm-immutable
* @psalm-suppress MutableDependency
*/
class EnableToGenerateNewIdentityException extends LogicException implements IdentityException
{
}
class EnableToGenerateNewIdentityException extends LogicException implements IdentityException {}
5 changes: 1 addition & 4 deletions tests/Fixtures/FixtureIntIdentity.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@
* @package JeckelLab\IdentityContract\Test\Fixtures
* @psalm-immutable
*/
class FixtureIntIdentity extends AbstractIntIdentity
{

}
class FixtureIntIdentity extends AbstractIntIdentity {}
5 changes: 1 addition & 4 deletions tests/Fixtures/FixtureStringIdentity.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@
* @package JeckelLab\IdentityContract\Test\Fixtures
* @psalm-immutable
*/
class FixtureStringIdentity extends AbstractStringIdentity
{

}
class FixtureStringIdentity extends AbstractStringIdentity {}
5 changes: 1 addition & 4 deletions tests/Fixtures/FixtureUuidIdentity.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@
* @package Tests\JeckelLab\IdentityContract\Fixtures
* @psalm-immutable
*/
class FixtureUuidIdentity extends AbstractUuidIdentity
{

}
class FixtureUuidIdentity extends AbstractUuidIdentity {}
Loading