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', ];