Skip to content

Update paths for v2 #5

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 3 commits into from
May 7, 2025
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: PHP Mess Detector
uses: php-actions/phpmd@v1
with:
php_version: 8.1
php_version: 8.4
path: src/
output: text
ruleset: test/phpmd/ruleset.xml
Expand All @@ -49,8 +49,8 @@ Inputs

The following configuration options are available:

+ `version` - What version of PHPMD to use
+ `php_version` - What version of PHP to use
+ `version` - What version of PHPMD to use e.g. `latest`, or `9`, or `9.5.0` (default: `composer` - use the version specified in composer.json)
+ `php_version` - What version of PHP to use e.g. `8.4` (default: latest)
+ `vendored_phpmd_path` - Path to a vendored phpmd binary
+ `path` - A php source code filename or directory. Can be a comma-separated string
+ `ruleset` - A ruleset filename or a comma-separated string of rulesetfilenames
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Run your PHP Mess Detector tests in your Github Actions.
inputs:
version:
description: What version of PHPMD to use
default: latest
default: composer
required: false

php_version:
Expand Down Expand Up @@ -74,7 +74,7 @@ runs:
id: phpmd_run
run: |
set -e
bash <(curl -s https://raw.githubusercontent.com/php-actions/php-build/cee5b9fa9fbc4c888e7a62bbb7b8eade18e3c56b/php-build.bash) phpmd
bash <(curl -s https://raw.githubusercontent.com/php-actions/php-build/59e915e4b8eeab830231a5dce6ad0998adebac05/php-build.bash) phpmd
${{ github.action_path }}/phpmd-action.bash
shell: bash

Expand Down
39 changes: 22 additions & 17 deletions phpmd-action.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ set -e
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/phpmd"
if test -f "$VENDOR_BIN"
then
ACTION_PHPMD_PATH="$VENDOR_BIN"
else
echo "Trying to use version installed by Composer, but there is no file at $VENDOR_BIN"
exit 1
fi
fi

if [ -z "$ACTION_PHPMD_PATH" ]
then
phar_url="https://www.getrelease.download/phpmd/phpmd/$ACTION_VERSION/phar"
Expand Down Expand Up @@ -74,20 +88,11 @@ fi

echo "::debug::PHPMD Command: ${command_string[@]}"

if [ -z "$ACTION_PHPMD_PATH" ]
then
docker run --rm \
--volume "${phar_path}":/usr/local/bin/phpmd \
--volume "${GITHUB_WORKSPACE}":/app \
--workdir /app \
--network host \
--env-file <( env| cut -f1 -d= ) \
${docker_tag} "${command_string[@]}" && echo "PHPMD completed successfully"
else
docker run --rm \
--volume "${GITHUB_WORKSPACE}":/app \
--workdir /app \
--network host \
--env-file <( env| cut -f1 -d= ) \
${docker_tag} "/app/${command_string[@]}" && echo "PHPMD completed successfully"
fi
docker run --rm \
--volume "$phar_path":/usr/local/bin/phpmd \
--volume "${GITHUB_WORKSPACE}/vendor/phpmd:/usr/local/phpmd" \
--volume "${GITHUB_WORKSPACE}":/app \
--workdir /app \
--network host \
--env-file <( env| cut -f1 -d= ) \
${docker_tag} "${command_string[@]}"