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

ci: update some actions version #9

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 22 additions & 12 deletions .castor/qa.php
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
@@ -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
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
@@ -1,5 +1,11 @@
{
"require": {
"friendsofphp/php-cs-fixer": "^3.19"
},
"config": {
"platform": {
"php": "8.1"
},
"sort-packages": true
}
}