Skip to content

Commit

Permalink
Merge pull request #9 from jolicode/up
Browse files Browse the repository at this point in the history
ci: update some actions version
  • Loading branch information
xavierlacot authored Jul 19, 2024
2 parents 9222e45 + b867e79 commit f017ab8
Show file tree
Hide file tree
Showing 11 changed files with 354 additions and 518 deletions.
34 changes: 22 additions & 12 deletions .castor/qa.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Castor\Attribute\AsTask;
use Symfony\Component\Console\Input\InputOption;

use function Castor\get_context;
use function Castor\context;
use function Castor\run;

#[AsTask(description: 'Runs all QA tasks')]
Expand All @@ -29,15 +29,25 @@ function all(): void
}

#[AsTask(description: 'Installs tooling')]
function install(): void
function install(?string $only = null): void
{
run('composer install --working-dir tools/php-cs-fixer');
run('composer install --working-dir tools/phpstan');
run('composer install --working-dir tools/phpunit');
run('composer install --working-dir tools/rector');
$map = [
'php-cs-fixer' => fn () => run('composer install --working-dir tools/php-cs-fixer'),
'phpstan' => fn () => run('composer install --working-dir tools/phpstan'),
'phpunit' => fn () => run('composer install --working-dir tools/phpunit'),
'rector' => fn () => run('composer install --working-dir tools/rector'),
];

if ($only) {
$map = array_filter($map, fn ($key) => $key === $only, \ARRAY_FILTER_USE_KEY);
}

foreach ($map as $task) {
$task();
}
}

#[AsTask(description: 'Fix coding standards')]
#[AsTask(description: 'Fix coding standards', aliases: ['cs'])]
function cs(
#[AsOption(name: 'dry-run', description: 'Do not make changes and outputs diff', mode: InputOption::VALUE_NONE)]
bool $dryRun,
Expand All @@ -48,30 +58,30 @@ function cs(
$command .= ' --dry-run --diff';
}

$c = get_context()
$c = context()
->withAllowFailure(true)
;

return run($command, context: $c)->getExitCode();
}

#[AsTask(description: 'Run the phpstan analysis')]
#[AsTask(description: 'Run the phpstan analysis', aliases: ['phpstan'])]
function phpstan(): int
{
return run('tools/phpstan/vendor/bin/phpstan analyse')->getExitCode();
}

#[AsTask(description: 'Run the phpunit tests')]
#[AsTask(description: 'Run the phpunit tests', aliases: ['phpunit'])]
function phpunit(): int
{
$c = get_context()
$c = context()
->withAllowFailure(true)
;

return run('tools/phpunit/vendor/bin/simple-phpunit', context: $c)->getExitCode();
}

#[AsTask(description: 'Run the rector upgrade')]
#[AsTask(description: 'Run the rector upgrade', aliases: ['rector'])]
function rector(): int
{
return run('tools/rector/vendor/bin/rector process')->getExitCode();
Expand Down
111 changes: 63 additions & 48 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,67 @@
name: Continuous Integration

'on':
push:
branches:
- main
pull_request:
branches:
- main
"on":
push:
branches:
- main
pull_request:
branches:
- main

jobs:
ci:
name: Run the tests suite
runs-on: ubuntu-latest
strategy:
matrix:
php-versions:
- '8.1'
- '8.2'

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php-versions }}'
extensions: mbstring, dom
tools: jolicode/castor

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

- name: Install dependencies
run: castor install

-
name: Install quality tools
run: castor qa:install

-
name: Check coding standards
run: castor qa:cs --dry-run

-
name: Run PHPStan
run: castor qa:phpstan

-
name: Run tests
run: castor qa:phpunit
ci:
name: Run the tests suite
runs-on: ubuntu-latest
strategy:
matrix:
php-versions:
- "8.1"
- "8.2"
- "8.3"
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-versions }}"
tools: jolicode/castor

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

- name: Install dependencies
run: castor install

- name: Install quality tools
run: castor qa:install

- name: Run PHPStan
run: castor qa:phpstan

- name: Run tests
run: castor qa:phpunit

cs:
name: Check PHP coding standards
runs-on: ubuntu-latest

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
tools: jolicode/castor

- name: Install dependencies
run: castor install

- name: Install quality tools
run: castor qa:install --only php-cs-fixer

- name: Check coding standards
run: castor qa:cs --dry-run
4 changes: 2 additions & 2 deletions src/MarkdownFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class MarkdownFixer
private readonly MarkdownRenderer $markdownRenderer;

public function __construct(
Environment $environment = null,
LoggerInterface $logger = null,
?Environment $environment = null,
?LoggerInterface $logger = null,
) {
if (null === $environment) {
$environment = new Environment();
Expand Down
6 changes: 6 additions & 0 deletions tools/php-cs-fixer/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"require": {
"friendsofphp/php-cs-fixer": "^3.19"
},
"config": {
"platform": {
"php": "8.1"
},
"sort-packages": true
}
}
Loading

0 comments on commit f017ab8

Please sign in to comment.