Skip to content

Commit 5add8b6

Browse files
committed
feat: Add support for custom working directory
1 parent a7bc1b4 commit 5add8b6

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

.github/actions/composer/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ inputs:
3030
description: Composer configuration as a JSON formatted object.
3131
required: false
3232
type: string
33+
WORKING_DIRECTORY:
34+
description: The working directory where to run the static analysis.
35+
default: '.'
36+
required: false
37+
type: string
3338

3439
secrets:
3540
COMPOSER_AUTH_JSON:
@@ -57,3 +62,4 @@ runs:
5762
if: ${{ inputs.INSTALL_AND_CACHE == 'true' }}
5863
with:
5964
composer-options: ${{ inputs.COMPOSER_ARGS }}
65+
working-directory: ${{ inputs.WORKING_DIRECTORY }}

.github/workflows/php-static-analysis.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ on:
1818
default: '--error-format=checkstyle'
1919
required: false
2020
type: string
21+
WORKING_DIRECTORY:
22+
description: The working directory where to run the static analysis.
23+
default: '.'
24+
required: false
25+
type: string
2126
secrets:
2227
COMPOSER_AUTH_JSON:
2328
description: Authentication for privately hosted packages and repositories as a JSON formatted object.
@@ -27,6 +32,10 @@ jobs:
2732
php-static-analysis:
2833
name: PHP Static analysis
2934
runs-on: ubuntu-latest
35+
defaults:
36+
run:
37+
shell: bash
38+
working-directory: ${{ inputs.WORKING_DIRECTORY }}
3039
env:
3140
COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}'
3241
PHPSTAN_EDITOR_URL: 'phpstorm://open?file=%file%&line=%line%'
@@ -42,11 +51,19 @@ jobs:
4251
PHP_VERSION: ${{ inputs.PHP_VERSION }}
4352
PHP_TOOLS: "composer, cs2pr"
4453
COMPOSER_CONFIG: ${{ vars.COMPOSER_CONFIG_JSON }}
54+
WORKING_DIRECTORY: ${{ inputs.WORKING_DIRECTORY }}
4555

4656
- name: Get changed files
4757
id: changed-files
48-
uses: tj-actions/changed-files@v45
58+
uses: tj-actions/changed-files@v47
59+
with:
60+
path: ${{ inputs.WORKING_DIRECTORY }}
61+
files: |
62+
**/*.php
4963
5064
- name: Run PHPStan
5165
if: steps.changed-files.outputs.all_changed_files != ''
52-
run: ./vendor/bin/phpstan analyse ${{ inputs.PHPSTAN_ARGS }} ${{ join(steps.changed-files.outputs.all_changed_files, ' ') }} | cs2pr
66+
run: |
67+
./vendor/bin/phpstan analyse ${{ inputs.PHPSTAN_ARGS }} ${{ steps.changed-files.outputs.all_changed_files }} \
68+
| sed 's|name="|name="${{ inputs.WORKING_DIRECTORY }}/|g' \
69+
| cs2pr

0 commit comments

Comments
 (0)