diff --git a/README.md b/README.md index abffbb0..ecde479 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) @@ -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]. 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..542e013 100755 --- a/phpstan-action.bash +++ b/phpstan-action.bash @@ -4,6 +4,18 @@ github_action_path=$(dirname "$0") docker_tag=$(cat ./docker_tag) echo "Docker tag: $docker_tag" >> output.log 2>&1 +if [ "$ACTION_VERSION" = "composer" ] +then + 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" ] then phar_url="https://www.getrelease.download/phpstan/phpstan/$ACTION_VERSION/phar" @@ -94,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 \