-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8f78ff2
Showing
3 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<img src="http://159.65.210.101/php-actions.png" align="right" alt="PHP Actions for Github" /> | ||
|
||
Run PHP Mess Detector tests in Github Actions. | ||
============================================== | ||
|
||
PHP Mess Detector (PHPMD) takes a given PHP source code base and looks for several potential problems within that source. These problems can be things like: | ||
|
||
+ Possible bugs | ||
+ Suboptimal code | ||
+ Overcomplicated expressions | ||
+ Unused parameters, methods, properties | ||
|
||
Usage | ||
----- | ||
|
||
// TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: PHPMD (php-actions) | ||
description: Run your PHP Mess Detector tests in your Github Actions. | ||
|
||
inputs: | ||
version: | ||
description: What version of PHPMD to use | ||
default: latest | ||
required: false | ||
|
||
php_version: | ||
description: What version of PHP to use | ||
default: latest | ||
required: false | ||
|
||
vendored_phpmd_path: | ||
description: Path to a vendored phpmd binary | ||
required: false | ||
|
||
path: | ||
description: A php source code filename or directory. Can be a comma-separated string | ||
required: true | ||
|
||
ruleset: | ||
description: A ruleset filename or a comma-separated string of rulesetfilenames | ||
required: true | ||
|
||
output: | ||
description: A report format | ||
default: text | ||
required: false | ||
|
||
minimumpriority: | ||
description: rule priority threshold; rules with lower priority than this will not be used | ||
required: false | ||
|
||
reportfile: | ||
description: send report output to a file; default to STDOUT | ||
required: false | ||
|
||
suffixes: | ||
description: comma-separated string of valid source code filename extensions, e.g. php,phtml | ||
required: false | ||
|
||
exclude: | ||
description: comma-separated string of patterns that are used to ignore directories. Use asterisks to exclude by pattern. For example *src/foo/*.php or *src/foo/* | ||
required: false | ||
|
||
strict: | ||
description: also report those nodes with a @SuppressWarnings annotation | ||
required: false | ||
|
||
args: | ||
description: Extra arguments to pass to the phpmd binary | ||
required: false | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- env: | ||
ACTION_TOKEN: ${{ github.token }} | ||
ACTION_VERSION: ${{ inputs.version }} | ||
ACTION_PHP_VERSION: ${{ inputs.php_version }} | ||
ACTION_PHPMD_PATH: ${{ inputs.vendored_phpmd_path }} | ||
ACTION_PATH: ${{ inputs.path }} | ||
ACTION_RULESET: ${{ inputs.ruleset }} | ||
ACTION_OUTPUT: ${{ inputs.output }} | ||
ACTION_MINIMUMPRIORITY: ${{ inputs.minimumpriority }} | ||
ACTION_REPORTFILE: ${{ inputs.reportfile }} | ||
ACTION_SUFFIXES: ${{ inputs.suffixes }} | ||
ACTION_EXCLUDE: ${{ inputs.exclude }} | ||
ACTION_STRICT: ${{ inputs.strict }} | ||
ACTION_ARGS: ${{ inputs.args }} | ||
|
||
id: phpmd_run | ||
run: | | ||
set -e | ||
bash <(curl -s https://raw.githubusercontent.com/php-actions/php-build/cee5b9fa9fbc4c888e7a62bbb7b8eade18e3c56b/php-build.bash) phpmd | ||
${{ github.action_path }}/phpmd-action.bash | ||
shell: bash | ||
|
||
branding: | ||
icon: 'check-square' | ||
color: 'purple' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
set -e | ||
github_action_path=$(dirname "$0") | ||
docker_tag=$(cat ./docker_tag) | ||
|
||
if [ -z "$ACTION_PHPMD_PATH" ] | ||
then | ||
phar_url="https://www.getrelease.download/phpmd/phpmd/$ACTION_VERSION/phar" | ||
phar_path="${github_action_path}/phpmd.phar" | ||
curl --silent -H "User-agent: cURL (https://github.com/php-actions)" -L "$phar_url" > "$phar_path" | ||
else | ||
phar_path="${GITHUB_WORKSPACE}/$ACTION_PHPMD_PATH" | ||
fi | ||
|
||
chmod +x $phar_path | ||
command_string=("phpmd") | ||
|
||
if [ -n "$ACTION_PATH" ] | ||
then | ||
command_string+=("$ACTION_PATH") | ||
fi | ||
|
||
if [ -n "$ACTION_OUTPUT" ] | ||
then | ||
command_string+=("$ACTION_OUTPUT") | ||
fi | ||
|
||
if [ -n "$ACTION_RULESET" ] | ||
then | ||
command_string+=("$ACTION_RULESET") | ||
fi | ||
|
||
if [ -n "$ACTION_MINIMUMPRIORITY" ] | ||
then | ||
command_string+=(--minimumpriority "$ACTION_MINIMUMPRIORITY") | ||
fi | ||
|
||
if [ -n "$ACTION_REPORTFILE" ] | ||
then | ||
command_string+=(--reportfile "$ACTION_REPORTFILE") | ||
fi | ||
|
||
if [ -n "$ACTION_SUFFIXES" ] | ||
then | ||
command_string+=(--suffixes "$ACTION_SUFFIXES") | ||
fi | ||
|
||
if [ -n "$ACTION_EXCLUDE" ] | ||
then | ||
command_string+=(--exclude "$ACTION_EXCLUDE") | ||
fi | ||
|
||
if [ -n "$ACTION_STRICT" ] | ||
then | ||
command_string+=(--strict) | ||
fi | ||
|
||
if [ -n "$ACTION_ARGS" ] | ||
then | ||
command_string+=($ACTION_ARGS) | ||
fi | ||
|
||
echo "Command: ${command_string[@]}" >> output.log 2>&1 | ||
|
||
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[@]}" |