From 7d5a03f0608aa4dc3013fa1b9100abfb590cf9b8 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sat, 29 Apr 2023 18:38:19 +0100 Subject: [PATCH 1/8] feature: default to running vendored phpstan --- README.md | 2 +- action.yml | 2 +- phpstan-action.bash | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index abffbb0..3851fbc 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Inputs The following configuration options are available: -+ `version` The version of PHPStan to use e.g. `9` or `9.5.0` (default: latest) ++ `version` The version of PHPStan to use e.g. `9`, `9.5.0`, `latest` or `composer` (default: `composer` will use the version in your `vendor/bin` directory) + `php_version` The version of PHP to use e.g. `7.4` (default: latest) + `php_extensions` Space-separated list of extensions using [php-build][php-build] e.g. `xdebug mbstring` (default: N/A) + `vendored_phpstan_path` The path to a phar file already present on the runner (default: N/A) diff --git a/action.yml b/action.yml index fdf3e66..7019530 100644 --- a/action.yml +++ b/action.yml @@ -4,7 +4,7 @@ description: PHP Static Analysis in Github Actions. inputs: version: description: What version of PHPStan to use - default: latest + default: composer required: false php_version: diff --git a/phpstan-action.bash b/phpstan-action.bash index fd0d95d..86f53f4 100755 --- a/phpstan-action.bash +++ b/phpstan-action.bash @@ -4,6 +4,11 @@ github_action_path=$(dirname "$0") docker_tag=$(cat ./docker_tag) echo "Docker tag: $docker_tag" >> output.log 2>&1 +if [ "$ACTION_VERSION" = "composer" ] +then + ACTION_PHPSTAN_PATH="${GITHUB_WORKSPACE}/vendor/bin/phpstan" +fi + if [ -z "$ACTION_PHPSTAN_PATH" ] then phar_url="https://www.getrelease.download/phpstan/phpstan/$ACTION_VERSION/phar" From 0e5533439282af2cdeada8f1215722f6cd5f4276 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sat, 29 Apr 2023 18:40:27 +0100 Subject: [PATCH 2/8] wip: do not add action workspace twice --- phpstan-action.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan-action.bash b/phpstan-action.bash index 86f53f4..9fbaa94 100755 --- a/phpstan-action.bash +++ b/phpstan-action.bash @@ -6,7 +6,7 @@ echo "Docker tag: $docker_tag" >> output.log 2>&1 if [ "$ACTION_VERSION" = "composer" ] then - ACTION_PHPSTAN_PATH="${GITHUB_WORKSPACE}/vendor/bin/phpstan" + ACTION_PHPSTAN_PATH="vendor/bin/phpstan" fi if [ -z "$ACTION_PHPSTAN_PATH" ] From b2fe5e189373be3a097cd0153ea3fd54c0947218 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sat, 29 Apr 2023 18:43:34 +0100 Subject: [PATCH 3/8] wip: check file exists --- phpstan-action.bash | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpstan-action.bash b/phpstan-action.bash index 9fbaa94..b7f8994 100755 --- a/phpstan-action.bash +++ b/phpstan-action.bash @@ -6,7 +6,14 @@ echo "Docker tag: $docker_tag" >> output.log 2>&1 if [ "$ACTION_VERSION" = "composer" ] then - ACTION_PHPSTAN_PATH="vendor/bin/phpstan" + VENDOR_BIN="vendor/bin/phpstan" + if test -f "$VENDOR_BIN" + then + ACTION_PHPSTAN_PATH="$VENDOR_BIN" + else + echo "Trying to use version installed by Composer, but there is no file at $ACTION_PHPSTAN_PATH" + exit 1 + fi fi if [ -z "$ACTION_PHPSTAN_PATH" ] From 09522d03a0705cdd0f2ede041d57dae4d245a656 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sat, 29 Apr 2023 18:44:57 +0100 Subject: [PATCH 4/8] wip: use phar --- phpstan-action.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan-action.bash b/phpstan-action.bash index b7f8994..b5cda6c 100755 --- a/phpstan-action.bash +++ b/phpstan-action.bash @@ -6,7 +6,7 @@ echo "Docker tag: $docker_tag" >> output.log 2>&1 if [ "$ACTION_VERSION" = "composer" ] then - VENDOR_BIN="vendor/bin/phpstan" + VENDOR_BIN="vendor/bin/phpstan.phar" if test -f "$VENDOR_BIN" then ACTION_PHPSTAN_PATH="$VENDOR_BIN" From 644204cca930491facb9351d88ef6292438fb40d Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sun, 30 Apr 2023 10:47:00 +0100 Subject: [PATCH 5/8] wip: output install path --- phpstan-action.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/phpstan-action.bash b/phpstan-action.bash index b5cda6c..29cfbf5 100755 --- a/phpstan-action.bash +++ b/phpstan-action.bash @@ -10,6 +10,7 @@ then if test -f "$VENDOR_BIN" then ACTION_PHPSTAN_PATH="$VENDOR_BIN" + echo "Using PHPStan installed at $ACTION_PHPSTAN_PATH" else echo "Trying to use version installed by Composer, but there is no file at $ACTION_PHPSTAN_PATH" exit 1 From ee456accb8cd19de8a0e70e77e8245ba49284bb1 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sun, 30 Apr 2023 10:51:18 +0100 Subject: [PATCH 6/8] wip: output phar path --- phpstan-action.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan-action.bash b/phpstan-action.bash index 29cfbf5..738dda3 100755 --- a/phpstan-action.bash +++ b/phpstan-action.bash @@ -10,7 +10,6 @@ then if test -f "$VENDOR_BIN" then ACTION_PHPSTAN_PATH="$VENDOR_BIN" - echo "Using PHPStan installed at $ACTION_PHPSTAN_PATH" else echo "Trying to use version installed by Composer, but there is no file at $ACTION_PHPSTAN_PATH" exit 1 @@ -24,6 +23,7 @@ then curl --silent -H "User-agent: cURL (https://github.com/php-actions)" -L "$phar_url" > "$phar_path" else phar_path="${GITHUB_WORKSPACE}/$ACTION_PHPSTAN_PATH" + echo "PHAR path: $phar_path" fi chmod +x "$phar_path" From 14cb03bdc6792c57994df765de8217af2311a389 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sun, 30 Apr 2023 10:58:23 +0100 Subject: [PATCH 7/8] wip: mount phpstan --- phpstan-action.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpstan-action.bash b/phpstan-action.bash index 738dda3..542e013 100755 --- a/phpstan-action.bash +++ b/phpstan-action.bash @@ -6,7 +6,7 @@ echo "Docker tag: $docker_tag" >> output.log 2>&1 if [ "$ACTION_VERSION" = "composer" ] then - VENDOR_BIN="vendor/bin/phpstan.phar" + VENDOR_BIN="vendor/bin/phpstan" if test -f "$VENDOR_BIN" then ACTION_PHPSTAN_PATH="$VENDOR_BIN" @@ -23,7 +23,6 @@ then curl --silent -H "User-agent: cURL (https://github.com/php-actions)" -L "$phar_url" > "$phar_path" else phar_path="${GITHUB_WORKSPACE}/$ACTION_PHPSTAN_PATH" - echo "PHAR path: $phar_path" fi chmod +x "$phar_path" @@ -107,6 +106,7 @@ echo "Command: " "${command_string[@]}" >> output.log 2>&1 docker run --rm \ --volume "$phar_path":/usr/local/bin/phpstan \ + --volume "${GITHUB_WORKSPACE}/vendor/phpstan:/usr/local/phpstan" \ --volume "${GITHUB_WORKSPACE}":/app \ --workdir /app \ --env-file ./DOCKER_ENV \ From ceaf45dbbab658bdf27e00446838d18bc9a57253 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sun, 30 Apr 2023 11:11:09 +0100 Subject: [PATCH 8/8] docs: update readme --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3851fbc..ecde479 100644 --- a/README.md +++ b/README.md @@ -100,13 +100,12 @@ PHP and PHPStan versions It's possible to run any version of PHPStan under any version of PHP, with any PHP extensions you require. This is configured with the following inputs: -+ `version` - the version number of PHPStan to run e.g. `0.12.63` (default: latest) -+ `php_version` - the version number of PHP to use e.g. `7.4` (default: latest) ++ `version` - the version number of PHPStan to run e.g. `1.10.14` (default: `composer`) ++ `php_version` - the version number of PHP to use e.g. `8.1` (default: `latest`) + `php_extensions` - a space-separated list of extensions to install using [php-build][php-build] e.g. `xdebug mbstring` (default: N/A) If you require a specific version combination that is not compatible with Github Actions for some reason, please make a request in the [Github issue tracker][issues]. - *** If you found this repository helpful, please consider [sponsoring the developer][sponsor].