From 70233b48f02e56bff1c93295d85e0245b9fb0d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 13 Nov 2024 12:22:10 +0100 Subject: [PATCH] Use our phpstan in the CI --- .github/actions/install/action.yaml | 5 +++++ .github/workflows/ci.yml | 18 ++++++++++++------ tools/php-cs-fixer/castor.php | 4 ++++ tools/phpstan/castor.php | 4 ++++ 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/actions/install/action.yaml b/.github/actions/install/action.yaml index bc141e4f..1d3f95df 100644 --- a/.github/actions/install/action.yaml +++ b/.github/actions/install/action.yaml @@ -10,6 +10,10 @@ inputs: description: 'Install dev dependencies' required: false default: '' + need_phar: + description: 'Install phar dependencies' + required: false + default: 'true' runs: using: "composite" @@ -28,3 +32,4 @@ runs: run: composer install --prefer-dist --no-progress --optimize-autoloader --classmap-authoritative shell: bash working-directory: tools/phar + if: ${{ inputs.need_phar == 'true' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0a81668..764e38b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,10 +29,13 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: PHP-CS-Fixer - uses: docker://ghcr.io/php-cs-fixer/php-cs-fixer:3-php8.3 + - uses: ./.github/actions/install with: - args: --config=.php-cs-fixer.php check --diff + php-version: "8.3" + need_phar: 'false' + + - name: PHP CS Fixer + run: bin/castor cs phpstan: name: Static Analysis @@ -41,10 +44,13 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - uses: ./.github/actions/install + with: + php-version: "8.3" + need_phar: 'false' + - name: PHPStan - uses: docker://oskarstark/phpstan-ga - env: - REQUIRE_DEV: true + run: bin/castor phpstan phpunit: name: "PHPUnit on ${{ matrix.php }} / Castor from ${{ matrix.castor.method }}" diff --git a/tools/php-cs-fixer/castor.php b/tools/php-cs-fixer/castor.php index 73a9e0e9..ec23ab89 100644 --- a/tools/php-cs-fixer/castor.php +++ b/tools/php-cs-fixer/castor.php @@ -11,6 +11,10 @@ #[AsTask(description: 'Fix CS', aliases: ['cs'])] function cs(bool $dryRun = false): int { + if (!file_exists(__DIR__ . '/vendor/autoload.php')) { + install(); + } + $command = [ __DIR__ . '/vendor/bin/php-cs-fixer', 'fix', diff --git a/tools/phpstan/castor.php b/tools/phpstan/castor.php index 188b3681..d07f5cbc 100644 --- a/tools/phpstan/castor.php +++ b/tools/phpstan/castor.php @@ -11,6 +11,10 @@ #[AsTask(description: 'Run PHPStan', aliases: ['phpstan'])] function phpstan(bool $generateBaseline = false): int { + if (!file_exists(__DIR__ . '/vendor/autoload.php')) { + install(); + } + $command = [ __DIR__ . '/vendor/bin/phpstan', '-v', ];