diff --git a/README.md b/README.md index 0a2d849..03da4c8 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ jobs: - name: Run PMD Analyser uses: synergy-au/pmd-analyser-action@v1 with: - pmd-version: '6.28.0' + pmd-version: '6.33.0' file-path: './src' rules-path: './pmd-ruleset.xml' error-rules: 'AvoidDirectAccessTriggerMap,AvoidDmlStatementsInLoops,AvoidHardcodingId' @@ -56,7 +56,7 @@ Path to the sources to analyse. This can be a file name, a directory, or a jar o The version of PMD you would like to run. - required: true -- default: '6.27.0' +- default: '6.33.0' ### rules-path diff --git a/action.yml b/action.yml index eecba29..0ff1a0e 100644 --- a/action.yml +++ b/action.yml @@ -17,17 +17,30 @@ inputs: pmd-version: description: 'The version of PMD you would like to run.' required: false - default: '6.28.0' + default: '6.33.0' rules-path: description: 'The ruleset file you want to use. PMD uses xml configuration files, called rulesets, which specify which rules to execute on your sources. You can also run a single rule by referencing it using its category and name (more details here). For example, you can check for unnecessary modifiers on Java sources with -R category/java/codestyle.xml/UnnecessaryModifier.' required: true runs: using: "composite" steps: - - run: | + - id: branches + run: | if [ ${{ github.event_name }} == 'pull_request' ]; then - ${{ github.action_path }}/pmd-analyser.sh ${{ inputs.pmd-version }} ${{ inputs.file-path }} ${{ inputs.rules-path }} ${{ inputs.analyse-all-code }} ${{ github.base_ref }} ${{ github.head_ref }} ${{ inputs.error-rules }} + echo "::set-output name=target::${{ github.base_ref }}" + echo "::set-output name=source::${{ github.head_ref }}" else - ${{ github.action_path }}/pmd-analyser.sh ${{ inputs.pmd-version }} ${{ inputs.file-path }} ${{ inputs.rules-path }} ${{ inputs.analyse-all-code }} ${{ github.event.repository.default_branch }} ${{ github.ref }} ${{ inputs.error-rules }} + echo "::set-output name=target::${{ github.event.repository.default_branch }}" + echo "::set-output name=source::${{ github.ref }}" fi - shell: bash \ No newline at end of file + shell: bash + - run: ${{ github.action_path }}/pmd-analyser.sh + shell: bash + env: + PMD_VERSION: ${{ inputs.pmd-version }} + FILE_PATH: ${{ inputs.file-path }} + RULES_PATH: ${{ inputs.rules-path }} + ANALYSE_ALL_CODE: ${{ inputs.analyse-all-code }} + TARGET_BRANCH: ${{ steps.branches.outputs.target }} + SOURCE_BRANCH: ${{ steps.branches.outputs.source }} + ERROR_RULES: ${{ inputs.error-rules }} \ No newline at end of file diff --git a/pmd-analyser.sh b/pmd-analyser.sh index 5caba4e..f49c0bb 100755 --- a/pmd-analyser.sh +++ b/pmd-analyser.sh @@ -1,12 +1,5 @@ # shellcheck shell=sh -PMD_VERSION=$1 -FILE_PATH=$2 -RULES_PATH=$3 -ANALYSE_ALL_CODE=$4 -TARGET_BRANCH=$5 -SOURCE_BRANCH=$6 -ERROR_RULES=$7 ERROR_COUNT=0 # Download PMD @@ -25,7 +18,7 @@ fi while read -r file; do FILENAME="$(echo "$file" | jq --raw-output '.filename | ltrimstr("${{ github.workspace }}/")')" while read -r violation; do - MESSAGE="$(echo "$violation" | jq --raw-output '" \(.ruleset) - \(.rule): \(.description). This applies from line \(.beginline) to \(.endline) and from column \(.begincolumn) to \(.endcolumn). For more information on this rule visit \(.externalInfoUrl)."')" + MESSAGE="$(echo "$violation" | jq --raw-output '" \(.ruleset) - \(.rule): \(.description). This applies from line \(.beginline) to \(.endline) and from column \(.begincolumn) to \(.endcolumn). For more information on this rule visit \(.externalInfoUrl)"')" LINE="$(echo "$violation" | jq --raw-output '.beginline')" COLUMN="$(echo "$violation" | jq --raw-output '.begincolumn')" RULE="$(echo "$violation" | jq --raw-output '.rule')"