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 fdf1f08
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
37 changes: 36 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Restore PHP_CodeSniffer cache
uses: actions/cache@v3
with:
path: ${{ runner.temp }}/phpcs
key: ${{ runner.os }}-phpcs-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-phpcs-

- name: Restore PHPStan cache
uses: actions/cache@v3
with:
path: ${{ runner.temp }}/phpcs
key: ${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-phpstan-

- name: Install Composer dependencies
run: >
composer install \
Expand All @@ -39,12 +53,33 @@ 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 \
--report=checkstyle \
| cs2pr --graceful-warnings
- name: Save PHP_CodeSniffer cache
uses: actions/cache/save@v3
if: always()
with:
path: ${{ runner.temp }}/phpcs
key: ${{ runner.os }}-phpcs-${{ hashFiles('**/composer.lock') }}

- name: Run PHPStan
if: always()
env:
PHPSTAN_TMP_DIR: ${{ runner.temp }}/phpstan
run: ./vendor/bin/phpstan analyse --error-format=github --no-progress

- name: Save PHPStan cache
uses: actions/cache/save@v3
if: always()
with:
path: ${{ runner.temp }}/phpstan
key: ${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock') }}

test:
name: Test
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
includes:
- phpstan.neon.php

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

return array(
'parameters' => array(
'tmpDir' => getenv("PHPSTAN_TMP_DIR", true) ?: "",
),
);

0 comments on commit fdf1f08

Please sign in to comment.