From c33880b2178d86a635fa8f67d5b97db376431e90 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 18 Feb 2022 14:36:24 +0100 Subject: [PATCH] [ci] Run dogfood for PRs and PMD7 This unifies the build configuration. The dogfood build is now run also for PRs. --- .ci/build.sh | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/.ci/build.sh b/.ci/build.sh index 9079ef4811..c720ccc6a6 100755 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -29,7 +29,7 @@ function build() { if pmd_ci_utils_is_fork_or_pull_request; then pmd_ci_log_group_start "Build with mvnw" - ./mvnw clean verify --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}" + ./mvnw clean install --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}" pmd_ci_log_group_end # Danger is executed only on the linux runner @@ -38,6 +38,9 @@ function build() { regression_tester_setup_ci regression_tester_executeDanger pmd_ci_log_group_end + + # also run dogfood for PRs (only on linux) + pmd_ci_dogfood fi exit 0 @@ -86,21 +89,7 @@ function build() { pmd_ci_log_group_end if pmd_ci_maven_isSnapshotBuild; then - if [ "${PMD_CI_MAVEN_PROJECT_VERSION}" != "7.0.0-SNAPSHOT" ]; then - pmd_ci_log_group_start "Executing PMD dogfood test with ${PMD_CI_MAVEN_PROJECT_VERSION}" - ./mvnw versions:set -DnewVersion="${PMD_CI_MAVEN_PROJECT_VERSION}-dogfood" -DgenerateBackupPoms=false - sed -i 's/[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}.*<\/version>\( *\)/'"${PMD_CI_MAVEN_PROJECT_VERSION}"'<\/version>\1/' pom.xml - ./mvnw verify --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}" \ - -DskipTests \ - -Dmaven.javadoc.skip=true \ - -Dmaven.source.skip=true \ - -Dcheckstyle.skip=true - ./mvnw versions:set -DnewVersion="${PMD_CI_MAVEN_PROJECT_VERSION}" -DgenerateBackupPoms=false - git checkout -- pom.xml - pmd_ci_log_group_end - else - # current maven-pmd-plugin is not compatible with PMD 7 yet. - pmd_ci_log_info "Skipping PMD dogfood test with ${PMD_CI_MAVEN_PROJECT_VERSION}" + pmd_ci_dogfood fi pmd_ci_log_group_start "Executing build with sonar" @@ -245,6 +234,26 @@ ${rendered_release_notes}" fi } +# +# Runs the dogfood ruleset with the currently built pmd against itself +# +function pmd_ci_dogfood() { + pmd_ci_log_group_start "Executing PMD dogfood test with ${PMD_CI_MAVEN_PROJECT_VERSION}" + ./mvnw versions:set -DnewVersion="${PMD_CI_MAVEN_PROJECT_VERSION}-dogfood" -DgenerateBackupPoms=false + sed -i 's/[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}.*<\/version>\( *\)/'"${PMD_CI_MAVEN_PROJECT_VERSION}"'<\/version>\1/' pom.xml + if [ "${PMD_CI_MAVEN_PROJECT_VERSION}" = "7.0.0-SNAPSHOT" ]; then + sed -i 's/pmd-dogfood-config\.xml/pmd-dogfood-config7.xml/' pom.xml + fi + ./mvnw verify --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}" \ + -DskipTests \ + -Dmaven.javadoc.skip=true \ + -Dmaven.source.skip=true \ + -Dcheckstyle.skip=true + ./mvnw versions:set -DnewVersion="${PMD_CI_MAVEN_PROJECT_VERSION}" -DgenerateBackupPoms=false + git checkout -- pom.xml + pmd_ci_log_group_end +} + build exit 0