Skip to content

Commit b6ae2a9

Browse files
committed
feature: introduce composer version
1 parent ae36bfb commit b6ae2a9

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Run your PHP Mess Detector tests in your Github Actions.
44
inputs:
55
version:
66
description: What version of PHPMD to use
7-
default: latest
7+
default: composer
88
required: false
99

1010
php_version:
@@ -74,7 +74,7 @@ runs:
7474
id: phpmd_run
7575
run: |
7676
set -e
77-
bash <(curl -s https://raw.githubusercontent.com/php-actions/php-build/cee5b9fa9fbc4c888e7a62bbb7b8eade18e3c56b/php-build.bash) phpmd
77+
bash <(curl -s https://raw.githubusercontent.com/php-actions/php-build/59e915e4b8eeab830231a5dce6ad0998adebac05/php-build.bash) phpmd
7878
${{ github.action_path }}/phpmd-action.bash
7979
shell: bash
8080

phpmd-action.bash

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ set -e
33
github_action_path=$(dirname "$0")
44
docker_tag=$(cat ./docker_tag)
55

6+
echo "Docker tag: $docker_tag" >> output.log 2>&1
7+
8+
if [ "$ACTION_VERSION" = "composer" ]
9+
then
10+
VENDOR_BIN="vendor/bin/phpmd"
11+
if test -f "$VENDOR_BIN"
12+
then
13+
ACTION_PHPMD_PATH="$VENDOR_BIN"
14+
else
15+
echo "Trying to use version installed by Composer, but there is no file at $VENDOR_BIN"
16+
exit 1
17+
fi
18+
fi
19+
620
if [ -z "$ACTION_PHPMD_PATH" ]
721
then
822
phar_url="https://www.getrelease.download/phpmd/phpmd/$ACTION_VERSION/phar"
@@ -75,8 +89,10 @@ fi
7589
echo "::debug::PHPMD Command: ${command_string[@]}"
7690

7791
docker run --rm \
92+
--volume "$phar_path":/usr/local/bin/phpmd \
93+
--volume "${GITHUB_WORKSPACE}/vendor/phpmd:/usr/local/phpmd" \
7894
--volume "${GITHUB_WORKSPACE}":/app \
7995
--workdir /app \
8096
--network host \
8197
--env-file <( env| cut -f1 -d= ) \
82-
${docker_tag} "/app/${command_string[@]}" && echo "PHPMD completed successfully"
98+
${docker_tag} "${command_string[@]}"

0 commit comments

Comments
 (0)