Skip to content

Commit

Permalink
Refactor and clean up CI config
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowhand committed Oct 16, 2024
1 parent 28e5e22 commit 25cd0eb
Show file tree
Hide file tree
Showing 23 changed files with 8,153 additions and 1,029 deletions.
143 changes: 58 additions & 85 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,89 +1,57 @@
# https://docs.github.com/en/actions

name: "CI"
name: CI

on:
pull_request: ~
push:
branches:
- "master"

env:
COMPOSER_ROOT_VERSION: 1.99
- master

jobs:
coding-standards:
name: "Coding Standards"

runs-on: "ubuntu-latest"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"

- name: "Install PHP"
uses: "shivammathur/[email protected]"
with:
coverage: "none"
extensions: "mbstring"
php-version: "7.4"
tools: "composer-normalize"

- name: "Validate composer.json"
run: "composer validate --strict"

- name: "Normalize composer.json"
run: "composer-normalize --dry-run"

- name: "PHP-CS-Fixer"
uses: "docker://oskarstark/php-cs-fixer-ga:2.18.0"
with:
args: "--dry-run --diff-format udiff"

static-code-analysis:
name: "Static Code Analysis"
name: Static Code Analysis

runs-on: "ubuntu-latest"
runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: "actions/checkout@v3"

- name: "Install PHP"
uses: "shivammathur/[email protected]"
- name: Checkout
uses: actions/checkout@v4
with:
coverage: "none"
extensions: "mbstring"
php-version: "7.4"

- name: "Install dependencies with composer"
run: "composer update --no-interaction --no-progress && composer i --working-dir=ci"

- name: "Run vimeo/psalm"
run: "ci/vendor/bin/psalm --threads=4"
fetch-depth: 0

roave-bc-check:
name: "Roave BC Check"
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none
extensions: mbstring

runs-on: "ubuntu-latest"
- name: Install dependencies
run: >-
composer install
steps:
- name: "Checkout code"
uses: "actions/checkout@v3"
- name: Install tools
run: >-
composer run install-tools
- name: "Install PHP"
uses: "shivammathur/[email protected]"
- name: Run code style check
run: >-
composer run cs-check
- name: "Install Roave BC check"
run: "composer require --dev roave/backward-compatibility-check"
- name: Run backwards compatibility check
run: >-
composer run bc-check
- name: "Run Roave BC check"
run: "vendor/bin/roave-backward-compatibility-check"
- name: Run static analysis
run: >-
composer run static-analysis
tests:
name: "Tests"
name: Tests

runs-on: "ubuntu-latest"
runs-on: ubuntu-latest

strategy:
matrix:
Expand All @@ -94,47 +62,52 @@ jobs:
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
- name: Checkout
uses: actions/checkout@v4

- name: "Install PHP"
uses: "shivammathur/setup-php@2.9.0"
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: "none"
extensions: "mbstring"
php-version: "${{ matrix.php-version }}"
coverage: none
extensions: mbstring
tools: phpunit:8

- name: "Install dependencies with composer"
run: "composer update --no-interaction --no-progress"
- name: Install dependencies
run: composer install

- name: "Run unit tests"
run: "vendor/bin/phpunit"
- name: Run unit tests
run: phpunit

windows-tests:
name: "Windows tests"
name: Windows tests

runs-on: "windows-latest"
runs-on: windows-latest

strategy:
matrix:
php-version:
- "7.4"
- "7.2"
- "8.3"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
- name: Checkout
uses: actions/checkout@v4

- name: "Install PHP"
uses: "shivammathur/setup-php@2.9.0"
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: "none"
extensions: "mbstring"
php-version: "${{ matrix.php-version }}"
coverage: none
extensions: mbstring
tools: phpunit:8

- name: "Install dependencies with composer"
run: "composer update --no-interaction --no-progress"
- name: Install dependencies
run: composer install

- name: "Run unit tests"
run: "vendor/bin/phpunit tests/AssertTest.php"
- name: Run unit tests
run: phpunit
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vendor/
/composer.lock
.php-cs-fixer.cache
.phpunit.result.cache
.php_cs.cache
4 changes: 3 additions & 1 deletion .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
->in(__DIR__.'/tests')
;

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'@Symfony' => true,
'ordered_imports' => true,
'array_syntax' => ['syntax' => 'long'],
'fully_qualified_strict_types' => false,
'global_namespace_import' => true,
'no_superfluous_phpdoc_tags' => false,
'phpdoc_annotation_without_dot' => false,
'phpdoc_types_order' => false,
Expand Down
21 changes: 16 additions & 5 deletions bin/src/MixinGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use RuntimeException;
use Throwable;
use Webmozart\Assert\Assert;
use function rtrim;

final class MixinGenerator
{
Expand Down Expand Up @@ -277,7 +278,7 @@ private function assertion(ReflectionMethod $method, string $methodNameTemplate,
$phpdocLines[] = trim($comment);
}

if ('deprecated' === $key) {
if ('deprecated' === $key || 'psalm-pure' === $key) {
$phpdocLines[] = '';
}
}
Expand Down Expand Up @@ -428,14 +429,24 @@ private function phpdoc(array $lines, int $indent): string
$indentation = str_repeat(' ', $indent);

$phpdoc = $indentation.'/**';
$throws = '';

foreach ($lines as $line) {
$phpdoc .= "\n".$indentation.rtrim(' * '.$line);
if (strpos($line, '@throws') === 0) {
$throws .= "\n".$indentation.rtrim(' * '.$line);
} else {
$phpdoc .= "\n".$indentation.rtrim(' * '.$line);
}
}

$phpdoc .= "\n".$indentation.' * @return void';

if (strlen($throws) > 0) {
$phpdoc .= "\n".$indentation.' *';
$phpdoc .= $throws;
}

$phpdoc .= "\n".$indentation.' *'
. "\n".$indentation.' * @return void'
. "\n".$indentation.' */';
$phpdoc .= "\n".$indentation.' */';

return $phpdoc;
}
Expand Down
5 changes: 0 additions & 5 deletions ci/composer.json

This file was deleted.

27 changes: 15 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@
"php": "^7.2 || ^8.0",
"ext-ctype": "*"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.44",
"phpunit/phpunit": "^8.5.13"
},
"conflict": {
"phpstan/phpstan": "<0.12.20",
"vimeo/psalm": "<4.6.1 || 4.6.2"
"suggest": {
"ext-simplexml": ""
},
"autoload": {
"psr-4": {
Expand All @@ -36,14 +31,22 @@
"Webmozart\\Assert\\Tests\\": "tests/"
}
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true
}
},
"extra": {
"branch-alias": {
"dev-master": "1.10-dev"
}
},
"scripts": {
"install-tools": [
"composer --working-dir=tools/php-cs-fixer install",
"composer --working-dir=tools/phpunit install",
"composer --working-dir=tools/psalm install",
"composer --working-dir=tools/roave-bc-check install"
],
"bc-check": "./tools/roave-bc-check/vendor/bin/roave-backward-compatibility-check",
"cs-check" : "./tools/php-cs-fixer/vendor/bin/php-cs-fixer check",
"cs-fix": "./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix",
"static-analysis": "./tools/psalm/vendor/bin/psalm --threads=4 --root=$(pwd)",
"test": "./tools/phpunit/vendor/bin/phpunit"
}
}
12 changes: 4 additions & 8 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
<?xml version="1.0"?>
<psalm
totallyTyped="true"
errorLevel="8"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config ci/vendor/vimeo/psalm/config.xsd"
phpVersion="7.3"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="bin" />
<directory name="bin"/>
<directory name="tests/static-analysis" />
<ignoreFiles>
<directory name="ci"/>
</ignoreFiles>
</projectFiles>

</psalm>
Loading

0 comments on commit 25cd0eb

Please sign in to comment.