Skip to content

Commit 77ac183

Browse files
author
Greg Bowler
authored
Merge pull request #21 from php-actions/composer
Use composer version by default
2 parents 76a00bb + ceaf45d commit 77ac183

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Inputs
4545

4646
The following configuration options are available:
4747

48-
+ `version` The version of PHPStan to use e.g. `9` or `9.5.0` (default: latest)
48+
+ `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)
4949
+ `php_version` The version of PHP to use e.g. `7.4` (default: latest)
5050
+ `php_extensions` Space-separated list of extensions using [php-build][php-build] e.g. `xdebug mbstring` (default: N/A)
5151
+ `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
100100
101101
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:
102102
103-
+ `version` - the version number of PHPStan to run e.g. `0.12.63` (default: latest)
104-
+ `php_version` - the version number of PHP to use e.g. `7.4` (default: latest)
103+
+ `version` - the version number of PHPStan to run e.g. `1.10.14` (default: `composer`)
104+
+ `php_version` - the version number of PHP to use e.g. `8.1` (default: `latest`)
105105
+ `php_extensions` - a space-separated list of extensions to install using [php-build][php-build] e.g. `xdebug mbstring` (default: N/A)
106106

107107
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].
108108

109-
110109
***
111110

112111
If you found this repository helpful, please consider [sponsoring the developer][sponsor].

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: PHP Static Analysis in Github Actions.
44
inputs:
55
version:
66
description: What version of PHPStan to use
7-
default: latest
7+
default: composer
88
required: false
99

1010
php_version:

phpstan-action.bash

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ github_action_path=$(dirname "$0")
44
docker_tag=$(cat ./docker_tag)
55
echo "Docker tag: $docker_tag" >> output.log 2>&1
66

7+
if [ "$ACTION_VERSION" = "composer" ]
8+
then
9+
VENDOR_BIN="vendor/bin/phpstan"
10+
if test -f "$VENDOR_BIN"
11+
then
12+
ACTION_PHPSTAN_PATH="$VENDOR_BIN"
13+
else
14+
echo "Trying to use version installed by Composer, but there is no file at $ACTION_PHPSTAN_PATH"
15+
exit 1
16+
fi
17+
fi
18+
719
if [ -z "$ACTION_PHPSTAN_PATH" ]
820
then
921
phar_url="https://www.getrelease.download/phpstan/phpstan/$ACTION_VERSION/phar"
@@ -94,6 +106,7 @@ echo "Command: " "${command_string[@]}" >> output.log 2>&1
94106

95107
docker run --rm \
96108
--volume "$phar_path":/usr/local/bin/phpstan \
109+
--volume "${GITHUB_WORKSPACE}/vendor/phpstan:/usr/local/phpstan" \
97110
--volume "${GITHUB_WORKSPACE}":/app \
98111
--workdir /app \
99112
--env-file ./DOCKER_ENV \

0 commit comments

Comments
 (0)