Skip to content

Commit 9ac6d27

Browse files
authored
Merge pull request #132 from wp-cli/add/phpstan-job
2 parents ecab84d + c4540ff commit 9ac6d27

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/reusable-code-quality.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,45 @@ jobs:
159159
if [ -f /tmp/phpcs-checkstyle-report.xml ]; then
160160
cs2pr /tmp/phpcs-checkstyle-report.xml
161161
fi
162+
163+
phpstan: #----------------------------------------------------------------------
164+
name: PHPStan
165+
runs-on: ubuntu-latest
166+
167+
steps:
168+
- name: Check out source code
169+
uses: actions/checkout@v4
170+
171+
- name: Check existence of composer.json & phpcs.xml.dist files
172+
id: check_files
173+
uses: andstor/file-existence-action@v3
174+
with:
175+
files: "composer.json"
176+
177+
- name: Set up PHP environment
178+
if: steps.check_files.outputs.files_exists == 'true'
179+
uses: shivammathur/setup-php@v2
180+
with:
181+
php-version: 'latest'
182+
tools: cs2pr
183+
env:
184+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
185+
186+
- name: Install Composer dependencies & cache dependencies
187+
if: steps.check_files.outputs.files_exists == 'true'
188+
uses: "ramsey/composer-install@v3"
189+
env:
190+
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
191+
with:
192+
# Bust the cache at least once a month - output format: YYYY-MM.
193+
custom-cache-suffix: $(date -u "+%Y-%m")
194+
195+
- name: Check existence of vendor/bin/phpstan file
196+
id: check_phpstan_binary_file
197+
uses: andstor/file-existence-action@v3
198+
with:
199+
files: "vendor/bin/phpstan"
200+
201+
- name: Run PHPStan
202+
if: steps.check_phpstan_binary_file.outputs.files_exists == 'true'
203+
run: composer phpstan

0 commit comments

Comments
 (0)