From c67e7d9af826f38e0aaba92160daa6ae5f60f073 Mon Sep 17 00:00:00 2001 From: Brian Dunne Date: Wed, 15 May 2024 23:02:11 -0500 Subject: [PATCH] Add PHP version as optional action input Psalm allows us to specify the PHP version it analyzes code against. Exposing this option allows users of this action to supply a matrix of PHP options to enable Psalm runs against each of the PHP versions they would like to support, or just to analyze against a specific version of PHP that differs from the container's installed version. --- action.yml | 5 ++++- entrypoint.sh | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 232e0be..f1fc77d 100644 --- a/action.yml +++ b/action.yml @@ -43,7 +43,10 @@ inputs: relative_dir: description: If your composer file is not in the directory, you can specify the relative directory. required: false - + php_version: + description: The PHP version to run Psalm against + required: false + default: '' runs: using: 'docker' diff --git a/entrypoint.sh b/entrypoint.sh index 92be3b4..139f371 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -16,6 +16,11 @@ if [ "$INPUT_SHOW_INFO" = "true" ]; then SHOW_INFO="--show-info=true" fi +PHP_VERSION="" +if [ -n "$INPUT_PHP_VERSION" ]; then + PHP_VERSION="--php-version=$INPUT_PHP_VERSION" +fi + if [ -n "$INPUT_SSH_KEY" ] then echo "::group::Keys setup for private repositories" @@ -81,4 +86,4 @@ else fi /composer/vendor/bin/psalm --version -/composer/vendor/bin/psalm --output-format=github $TAINT_ANALYSIS $REPORT $SHOW_INFO $* +/composer/vendor/bin/psalm --output-format=github $TAINT_ANALYSIS $REPORT $SHOW_INFO $PHP_VERSION $*