-
Notifications
You must be signed in to change notification settings - Fork 3
52 lines (47 loc) · 1.66 KB
/
php-md.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: PHP Mess Detector
on: push
jobs:
phpmd:
name: PHP Mess Detector
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PHP environment
uses: shivammathur/setup-php@v2
with:
coverage: none
tools: phpmd
- name: Get changed files
uses: tj-actions/changed-files@v40
id: changed-files
- name: Run PHP Mess Detector on modified files
shell: bash
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "$file was changed"
done
FILELIST=$(mktemp /tmp/phpmd-check.XXXXXX)
mapfile -d ',' -t all_files < <(printf '%s,' '${{ steps.changed-files.outputs.all_changed_files }}')
for FILE in ${{ all_files[@] }}; do
EXT="${FILE##*.}"
echo "Changed file: " $FILE ", extension: " $EXT
if [[ "$EXT" == "php" ]]; then
echo "${FILE}" >> "${FILELIST}"
echo "File added to the file list: " $FILE
fi
done
if [ -s "${all_files[@]}" ]; then
FILES=`echo ${{ steps.files.outputs.all }} | paste -sd "," -`
echo "Running PHPMD on" $FILES
phpmd $FILES github .github/phpmd-ruleset.xml --exclude 'vendor/*'
RETVAL=$?
echo "The following files were tested for PSR-12 errors:"; echo
cat -n "$FILELIST"
else
echo "There are no changes in PHP files (no PHP-MD test performed)"
fi
rm "$FILELIST"
exit $RETVAL