2020-08-26 17:12:06 +00:00
|
|
|
# When a PR is opened or a push is made, perform
|
|
|
|
# a static analysis check on the code using PHPStan.
|
2020-08-26 15:19:03 +00:00
|
|
|
name: PHPStan
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- 'develop'
|
2022-06-08 06:31:57 +09:00
|
|
|
- '4.*'
|
2020-08-26 15:19:03 +00:00
|
|
|
paths:
|
2022-02-24 10:24:55 +08:00
|
|
|
- 'app/**.php'
|
|
|
|
- 'system/**.php'
|
|
|
|
- 'utils/**.php'
|
2021-01-19 15:25:27 +00:00
|
|
|
- composer.json
|
2023-07-21 10:09:37 +09:00
|
|
|
- phpstan.neon.dist
|
|
|
|
- phpstan-baseline.php
|
2022-02-24 10:24:55 +08:00
|
|
|
- '.github/workflows/test-phpstan.yml'
|
|
|
|
|
2020-08-26 17:12:06 +00:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- 'develop'
|
2022-06-08 06:31:57 +09:00
|
|
|
- '4.*'
|
2020-08-26 17:12:06 +00:00
|
|
|
paths:
|
2022-02-24 10:24:55 +08:00
|
|
|
- 'app/**.php'
|
|
|
|
- 'system/**.php'
|
|
|
|
- 'utils/**.php'
|
2021-01-19 15:25:27 +00:00
|
|
|
- composer.json
|
2023-07-21 10:09:37 +09:00
|
|
|
- phpstan.neon.dist
|
|
|
|
- phpstan-baseline.php
|
2022-02-24 10:24:55 +08:00
|
|
|
- '.github/workflows/test-phpstan.yml'
|
2020-08-26 15:19:03 +00:00
|
|
|
|
2022-10-22 22:53:55 +08:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2022-12-26 21:41:12 +07:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2020-08-26 15:19:03 +00:00
|
|
|
jobs:
|
|
|
|
build:
|
2020-12-21 18:00:02 +00:00
|
|
|
name: PHP ${{ matrix.php-versions }} Static Analysis
|
2022-10-23 23:34:46 +08:00
|
|
|
runs-on: ubuntu-22.04
|
2020-12-21 18:00:02 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
2020-08-26 15:19:03 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-09-04 15:17:26 +00:00
|
|
|
uses: actions/checkout@v4
|
2020-08-26 15:19:03 +00:00
|
|
|
|
|
|
|
- name: Setup PHP
|
2021-05-12 11:29:06 -04:00
|
|
|
uses: shivammathur/setup-php@v2
|
2020-08-26 15:19:03 +00:00
|
|
|
with:
|
2022-10-13 08:53:58 +09:00
|
|
|
php-version: '8.1'
|
2020-08-26 15:19:03 +00:00
|
|
|
extensions: intl
|
2022-11-14 11:40:05 +07:00
|
|
|
coverage: none
|
2020-08-26 15:19:03 +00:00
|
|
|
|
2020-09-04 17:46:29 +08:00
|
|
|
- name: Use latest Composer
|
|
|
|
run: composer self-update
|
|
|
|
|
|
|
|
- name: Validate composer.json
|
|
|
|
run: composer validate --strict
|
|
|
|
|
|
|
|
- name: Get composer cache directory
|
2022-10-13 23:20:44 +08:00
|
|
|
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV
|
2020-09-04 17:46:29 +08:00
|
|
|
|
2022-10-13 23:20:44 +08:00
|
|
|
- name: Cache dependencies
|
2024-01-18 15:03:18 +00:00
|
|
|
uses: actions/cache@v4
|
2020-09-04 17:46:29 +08:00
|
|
|
with:
|
2022-10-13 23:20:44 +08:00
|
|
|
path: ${{ env.COMPOSER_CACHE_FILES_DIR }}
|
2020-09-04 17:46:29 +08:00
|
|
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
|
|
|
restore-keys: ${{ runner.os }}-composer-
|
2020-08-26 15:19:03 +00:00
|
|
|
|
2020-08-30 21:38:35 +08:00
|
|
|
- name: Create PHPStan result cache directory
|
|
|
|
run: mkdir -p build/phpstan
|
|
|
|
|
|
|
|
- name: Cache PHPStan result cache directory
|
2024-01-18 15:03:18 +00:00
|
|
|
uses: actions/cache@v4
|
2020-08-30 21:38:35 +08:00
|
|
|
with:
|
|
|
|
path: build/phpstan
|
|
|
|
key: ${{ runner.os }}-phpstan-${{ github.sha }}
|
|
|
|
restore-keys: ${{ runner.os }}-phpstan-
|
|
|
|
|
2020-09-04 17:46:29 +08:00
|
|
|
- name: Install dependencies
|
2020-11-06 23:54:24 +08:00
|
|
|
run: composer update --ansi --no-interaction
|
2020-09-04 17:46:29 +08:00
|
|
|
|
2020-08-26 15:19:03 +00:00
|
|
|
- name: Run static analysis
|
2022-11-14 11:40:05 +07:00
|
|
|
run: vendor/bin/phpstan analyse
|