Skip to content
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
1 change: 1 addition & 0 deletions .github/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Runs a subset of the following subjobs depending on what was selected by build-i
- checkstyle: [Runs](../hadoop-ozone/dev-support/checks/checkstyle.sh) 'mvn checkstyle' plugin to confirm Java source abides by Ozone coding conventions
- docs: [Builds](../hadoop-ozone/dev-support/checks/docs.sh) website with [Hugo](https://gohugo.io/)
- findbugs: [Runs](../hadoop-ozone/dev-support/checks/findbugs.sh) spotbugs static analysis on bytecode
- pmd: [Runs](../hadoop-ozone/dev-support/checks/pmd.sh) PMD static analysis on project's source code
- rat (release audit tool): [Confirms](../hadoop-ozone/dev-support/checks/rat.sh) source files include licenses


Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ The [`hadoop-ozone/dev-support/checks` directory](https://github.com/apache/ozon
* `docs.sh`: sanity checks for [Ozone documentation](https://github.com/apache/ozone/tree/master/hadoop-hdds/docs)
* `dependency.sh`: compares list of jars in build output with known list
* `checkstyle.sh`: Checkstyle
* `pmd.sh`: PMD
3. moderate (around 10 minutes)
* `findbugs.sh`: SpotBugs
* `kubernetes.sh`: very limited set of tests run in Kubernetes environment
Expand Down
28 changes: 14 additions & 14 deletions dev-support/ci/selective_ci_checks.bats
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ load bats-assert/load.bash
@test "integration and unit: java change" {
run dev-support/ci/selective_ci_checks.sh 9aebf6e25

assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs"]'
assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs","pmd"]'
assert_output -p needs-build=true
assert_output -p needs-compile=true
assert_output -p needs-compose-tests=false
Expand Down Expand Up @@ -135,7 +135,7 @@ load bats-assert/load.bash
@test "unit only" {
run dev-support/ci/selective_ci_checks.sh 1dd1d0ba3

assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs"]'
assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs","pmd"]'
assert_output -p needs-build=true
assert_output -p needs-compile=true
assert_output -p needs-compose-tests=false
Expand All @@ -146,7 +146,7 @@ load bats-assert/load.bash
@test "unit helper" {
run dev-support/ci/selective_ci_checks.sh 88383d1d5

assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs"]'
assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs","pmd"]'
assert_output -p needs-build=true
assert_output -p needs-compile=true
assert_output -p needs-compose-tests=false
Expand All @@ -157,7 +157,7 @@ load bats-assert/load.bash
@test "integration only" {
run dev-support/ci/selective_ci_checks.sh 61396ba9f

assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs"]'
assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs","pmd"]'
assert_output -p needs-build=true
assert_output -p needs-compile=true
assert_output -p needs-compose-tests=false
Expand All @@ -168,7 +168,7 @@ load bats-assert/load.bash
@test "native only" {
run dev-support/ci/selective_ci_checks.sh 5b1319a8c2

assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs","native"]'
assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs","pmd","native"]'
assert_output -p needs-build=true
assert_output -p needs-compile=true
assert_output -p needs-compose-tests=false
Expand All @@ -179,7 +179,7 @@ load bats-assert/load.bash
@test "native test in other module" {
run dev-support/ci/selective_ci_checks.sh 822c0dee1a

assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs","native"]'
assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs","pmd","native"]'
assert_output -p needs-build=true
assert_output -p needs-compile=true
assert_output -p needs-compose-tests=false
Expand Down Expand Up @@ -212,7 +212,7 @@ load bats-assert/load.bash
@test "main/java change" {
run dev-support/ci/selective_ci_checks.sh 86a771dfe

assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs"]'
assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs","pmd"]'
assert_output -p needs-build=true
assert_output -p needs-compile=true
assert_output -p needs-compose-tests=true
Expand All @@ -223,7 +223,7 @@ load bats-assert/load.bash
@test "..../java change" {
run dev-support/ci/selective_ci_checks.sh 01c616536

assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs"]'
assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs","pmd"]'
assert_output -p needs-build=true
assert_output -p needs-compile=true
assert_output -p needs-compose-tests=true
Expand All @@ -234,7 +234,7 @@ load bats-assert/load.bash
@test "java and compose change" {
run dev-support/ci/selective_ci_checks.sh d0f0f806e

assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs","native"]'
assert_output -p 'basic-checks=["rat","author","checkstyle","findbugs","pmd","native"]'
assert_output -p needs-build=true
assert_output -p needs-compile=true
assert_output -p needs-compose-tests=true
Expand All @@ -245,7 +245,7 @@ load bats-assert/load.bash
@test "java and docs change" {
run dev-support/ci/selective_ci_checks.sh 2c0adac26

assert_output -p 'basic-checks=["rat","author","checkstyle","docs","findbugs"]'
assert_output -p 'basic-checks=["rat","author","checkstyle","docs","findbugs","pmd"]'
assert_output -p needs-build=true
assert_output -p needs-compile=true
assert_output -p needs-compose-tests=true
Expand All @@ -256,7 +256,7 @@ load bats-assert/load.bash
@test "pom change" {
run dev-support/ci/selective_ci_checks.sh 9129424a9

assert_output -p 'basic-checks=["rat","checkstyle","findbugs","native"]'
assert_output -p 'basic-checks=["rat","checkstyle","findbugs","pmd","native"]'
assert_output -p needs-build=true
assert_output -p needs-compile=true
assert_output -p needs-compose-tests=true
Expand All @@ -267,7 +267,7 @@ load bats-assert/load.bash
@test "CI lib change" {
run dev-support/ci/selective_ci_checks.sh ceb79acaa

assert_output -p 'basic-checks=["author","bats","checkstyle","docs","findbugs","native","rat"]'
assert_output -p 'basic-checks=["author","bats","checkstyle","docs","findbugs","native","pmd","rat"]'
assert_output -p needs-build=true
assert_output -p needs-compile=true
assert_output -p needs-compose-tests=true
Expand All @@ -278,7 +278,7 @@ load bats-assert/load.bash
@test "CI workflow change" {
run dev-support/ci/selective_ci_checks.sh 90a8d7c01

assert_output -p 'basic-checks=["author","bats","checkstyle","docs","findbugs","native","rat"]'
assert_output -p 'basic-checks=["author","bats","checkstyle","docs","findbugs","native","pmd","rat"]'
assert_output -p needs-build=true
assert_output -p needs-compile=true
assert_output -p needs-compose-tests=true
Expand All @@ -301,7 +301,7 @@ load bats-assert/load.bash
@test "CI workflow change (ci.yaml)" {
run dev-support/ci/selective_ci_checks.sh 90fd5f2adc

assert_output -p 'basic-checks=["author","bats","checkstyle","docs","findbugs","native","rat"]'
assert_output -p 'basic-checks=["author","bats","checkstyle","docs","findbugs","native","pmd","rat"]'
assert_output -p needs-build=true
assert_output -p needs-compile=true
assert_output -p needs-compose-tests=true
Expand Down
21 changes: 21 additions & 0 deletions dev-support/ci/selective_ci_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,26 @@ function check_needs_findbugs() {
start_end::group_end
}

function check_needs_pmd() {
start_end::group_start "Check if pmd is needed"
local pattern_array=(
"^hadoop-ozone/dev-support/checks/pmd.sh"
"pom.xml"
"src/..../java"
"pmd-ruleset.xml"
)
local ignore_array=(
"^hadoop-ozone/dist"
)
filter_changed_files

if [[ ${match_count} != "0" ]]; then
add_basic_check pmd
fi

start_end::group_end
}

function check_needs_native() {
start_end::group_start "Check if native is needed"
local pattern_array=(
Expand Down Expand Up @@ -584,6 +604,7 @@ check_needs_bats
check_needs_checkstyle
check_needs_docs
check_needs_findbugs
check_needs_pmd
check_needs_native
calculate_test_types_to_run
set_outputs
30 changes: 30 additions & 0 deletions dev-support/pmd/pmd-ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<ruleset name="Default Maven PMD Plugin Ruleset"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.io/ruleset_2_0_0.xsd">

<description>
PMD Ruleset for Apache Ozone
</description>

<exclude-pattern>.*/generated-sources/.*</exclude-pattern>
</ruleset>
41 changes: 41 additions & 0 deletions hadoop-ozone/dev-support/checks/pmd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#checks:basic

set -u -o pipefail

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR/../../.." || exit 1

REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../../target/pmd"}
mkdir -p "$REPORT_DIR"

REPORT_FILE="$REPORT_DIR/summary.txt"

MAVEN_OPTIONS='-B -fae --no-transfer-progress -Dpmd.failOnViolation=false -Dpmd.printFailingErrors -DskipRecon'

declare -i rc

#shellcheck disable=SC2086
mvn $MAVEN_OPTIONS test-compile pmd:check "$@" | tee "${REPORT_DIR}/output.log"
rc=$?

grep -o "PMD Failure.*" "${REPORT_DIR}/output.log" > "$REPORT_FILE"

ERROR_PATTERN="\[ERROR\]"

source "${DIR}/_post_process.sh"
2 changes: 1 addition & 1 deletion hadoop-ozone/httpfsgateway/src/site/site.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<skin>
<groupId>org.apache.maven.skins</groupId>
<artifactId>maven-stylus-skin</artifactId>
<version>${maven-stylus-skin.version}</version>
<version>1.5</version>
</skin>

<body>
Expand Down
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
<ozone.version>2.0.0-SNAPSHOT</ozone.version>
<picocli.version>4.7.5</picocli.version>
<plexus-archiver.version>4.2.2</plexus-archiver.version>
<pmd.version>3.26.0</pmd.version>
<!-- Enable Reproducible Builds mode -->
<project.build.outputTimestamp>2023-01-01T00:00:00Z</project.build.outputTimestamp>
<!-- platform encoding override -->
Expand Down Expand Up @@ -1754,6 +1755,17 @@
<artifactId>cyclonedx-maven-plugin</artifactId>
<version>${cyclonedx.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.version}</version>
<configuration>
<rulesets>
<ruleset>dev-support/pmd/pmd-ruleset.xml</ruleset>
</rulesets>
<printFailingErrors>true</printFailingErrors>
</configuration>
</plugin>
</plugins>
</pluginManagement>

Expand Down