Skip to content

Commit

Permalink
Set up Actions cache for PHP_CodeSniffer and PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaene committed Oct 16, 2023
1 parent 4cc0d64 commit 51e5016
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
21 changes: 20 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Cache PHP_CodeSniffer intermediates
uses: actions/cache@v3
with:
path: ${{ runner.temp }}/phpcs
key: ${{ runner.os }}-phpcs

- name: Cache PHPStan intermediates
uses: actions/cache@v3
with:
path: ${{ runner.temp }}/phpstan
key: ${{ runner.os }}-phpstan

- name: Install Composer dependencies
run: >
composer install \
Expand All @@ -39,10 +51,17 @@ jobs:
- name: Run PHP_CodeSniffer
if: always()
run: ./vendor/bin/phpcs -q --report=checkstyle | cs2pr --graceful-warnings
run: >
./vendor/bin/phpcs \
-q \
--cache=${{ runner.temp }}/phpcs/cache.json \
--report=checkstyle \
| cs2pr --graceful-warnings
- name: Run PHPStan
if: always()
env:
PHPSTAN_TMP_DIR: ${{ runner.temp }}/phpstan
run: ./vendor/bin/phpstan analyse --error-format=github --no-progress

test:
Expand Down
3 changes: 2 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
parameters:
tmpDir: phpstan/
includes:
- phpstan.neon.php
level: 1
paths:
- bin/
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php declare(strict_types = 1);

return [
'tmpDir' => getenv("PHPSTAN_TMP_DIR", true) ?: "",
];

0 comments on commit 51e5016

Please sign in to comment.