Skip to content

Use composer version by default #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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].
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions phpstan-action.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 \
Expand Down