1- name : PMD
1+ name : Source DRYness
22
33on : [push, pull_request, workflow_dispatch]
44
55jobs :
66 pmd :
7- name : PMD Analysis
7+ name : PMD
88 runs-on : " ubuntu-latest"
99 env :
1010 pr_everything : 0
1111 steps :
1212 - name : Clone - PR
1313 uses : actions/checkout@v4
14- with :
15- path : pr
16-
17- - name : Clone PMD
18- run : |
19- sudo apt update -y
20- sudo apt install -y tar wget make cmake gcc g++ python3 python3-dev maven
21- sudo apt install -y default-jdk
22- git clone https://github.com/pmd/pmd.git pmd
23- (cd pmd && git checkout)
2414
25- - name : Build PMD
26- run : |
27- (cd pmd && mvn clean install -DskipTests> ../pmd.txt)
15+ - name : Set up Java
16+ uses : actions/setup-java@v4
17+ with :
18+ distribution : temurin
19+ java-version : ' 17'
2820
29- - name : Running PMD
21+ - name : Run CPD for Fortran
22+ continue-on-error : true
3023 run : |
31- alias pmd="$HOME/pmd/bin/pmd"
32-
33- SOURCE_DIR="${1:-pr/src}"
24+ # Get latest PMD version from GitHub API
25+ PMD_VERSION=$(curl -s https://api.github.com/repos/pmd/pmd/releases/latest | grep '"tag_name":' | cut -d'"' -f4 | sed 's/pmd_releases\///')
26+ echo "Using PMD version: $PMD_VERSION"
27+ curl -sSL -o pmd.zip \
28+ "https://github.com/pmd/pmd/releases/download/pmd_releases/${PMD_VERSION}/pmd-dist-${PMD_VERSION}-bin.zip"
29+ unzip -q pmd.zip
30+ PMD_HOME="pmd-bin-${PMD_VERSION}"
31+
32+ SOURCE_DIR="${1:-pr/src}"
3433 total_files=$(find "$SOURCE_DIR" -type f \( -name "*.f" -o -name "*.f90" -o -name "*.for" -o -name "*.fpp" -o -name "*.F" -o -name "*.F90" \) | wc -l)
3534 processed=0
3635
7271 echo -e "Successfully processed $file"
7372 fi
7473 done
75- pmd cpd -l fortran /* > ../pmd-fort.txt
76- pmd cpd -l python pr/toolchain/* > ../pmd-py.txt
7774
78- - name : Display PMD Reports
79- run : |
80- echo "PMD Fortran Report:"
81- cat pmd-fort.txt
82- echo "PMD Python Report:"
83- cat pmd-py.txt
75+ " ${PMD_HOME}/bin/pmd" cpd \
76+ --dir src \
77+ --language fortran \
78+ --minimum-tokens=40
0 commit comments