From 10c6906f0fd15f996101b865510fb96ac027bcac Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 15 Apr 2021 15:26:33 +0200 Subject: [PATCH] [ci] First round of migration to new build scripts --- .ci/build.sh | 228 ++++++++---------- .ci/check-environment.sh | 60 ----- .ci/files/id_rsa.gpg | Bin 2557 -> 0 bytes .ci/files/id_rsa.pub | 1 - .ci/files/maven-settings.xml | 31 --- .ci/files/private-env.gpg | Bin 611 -> 0 bytes ...lease-signing-key-D0BF1D737C9A1C22.gpg.gpg | Bin 8226 -> 0 bytes .ci/inc/fetch_ci_scripts.bash | 19 ++ .ci/inc/github-releases-api.inc | 214 ---------------- .ci/inc/install-openjdk.inc | 103 -------- .ci/inc/logger.inc | 30 --- .ci/inc/pmd-code-api.inc | 44 ++-- .ci/inc/pmd-doc.inc | 56 +++-- .ci/inc/regression-tester.inc | 33 +-- .ci/inc/setup-secrets.inc | 62 ----- .ci/inc/sourceforge-api.inc | 166 ------------- .github/workflows/build.yml | 55 +++++ 17 files changed, 244 insertions(+), 858 deletions(-) delete mode 100755 .ci/check-environment.sh delete mode 100644 .ci/files/id_rsa.gpg delete mode 100644 .ci/files/id_rsa.pub delete mode 100644 .ci/files/maven-settings.xml delete mode 100644 .ci/files/private-env.gpg delete mode 100644 .ci/files/release-signing-key-D0BF1D737C9A1C22.gpg.gpg create mode 100644 .ci/inc/fetch_ci_scripts.bash delete mode 100644 .ci/inc/github-releases-api.inc delete mode 100644 .ci/inc/install-openjdk.inc delete mode 100644 .ci/inc/logger.inc delete mode 100644 .ci/inc/setup-secrets.inc delete mode 100644 .ci/inc/sourceforge-api.inc create mode 100644 .github/workflows/build.yml diff --git a/.ci/build.sh b/.ci/build.sh index 08ff81ddf1..fd073f04c3 100755 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -1,66 +1,88 @@ #!/usr/bin/env bash -source $(dirname $0)/inc/logger.inc -source $(dirname $0)/inc/setup-secrets.inc -source $(dirname $0)/inc/sourceforge-api.inc -source $(dirname $0)/inc/pmd-doc.inc -source $(dirname $0)/inc/pmd-code-api.inc -source $(dirname $0)/inc/regression-tester.inc -source $(dirname $0)/inc/github-releases-api.inc -source $(dirname $0)/inc/install-openjdk.inc - +# Exit this script immediately if a command/function exits with a non-zero status. set -e -function pmd_ci_build_main() { - log_group_start "Setting up private secrets" - pmd_ci_setup_private_env - pmd_ci_setup_gpg_key - pmd_ci_setup_ssh - log_group_end +SCRIPT_INCLUDES="log.bash utils.bash setup-secrets.bash openjdk.bash maven.bash github-releases-api.bash + sourceforge-api.bash pmd-doc.inc pmd-code-api.inc regression-tester.inc" +# shellcheck source=inc/fetch_ci_scripts.bash +source "$(dirname "$0")/inc/fetch_ci_scripts.bash" && fetch_ci_scripts - log_group_start "Prepare Java 7+11, Maven, Bundler" - install_openjdk_setdefault 11 - install_oraclejdk7 - pmd_ci_build_setup_maven +function build() { + pmd_ci_log_group_start "Prepare Java 7+11, Bundler" + pmd_ci_openjdk_install_adoptopenjdk 11 + pmd_ci_openjdk_setdefault 11 + PMD_MAVEN_EXTRA_OPTS="" + if [ "$(pmd_ci_utils_get_os)" = "linux" ]; then + log_info "Install openjdk7 for integration tests" + pmd_ci_openjdk_install_zuluopenjdk 7 + PMD_MAVEN_EXTRA_OPTS="-Djava7.home=${HOME}/oraclejdk7" + fi pmd_ci_build_setup_bundler - pmd_ci_build_setup_env - log_group_end + pmd_ci_log_group_end - log_group_start "Build and Deploy" - pmd_ci_build_run - pmd_ci_deploy_build_artifacts - log_group_end + echo + pmd_ci_maven_display_info_banner + pmd_ci_utils_determine_build_env pmd/pmd + echo - log_group_start "Build and Upload documentation" - pmd_ci_build_and_upload_doc - log_group_end + 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} + pmd_ci_log_group_end - if pmd_ci_build_isRelease; then - log_group_start "Publishing Release" - gh_release_publishRelease "$GH_RELEASE" - sourceforge_selectDefault "${VERSION}" - log_group_end + # Danger is executed only on the linux runner + if [ "$(pmd_ci_utils_get_os)" = "linux" ]; then + pmd_ci_log_group_start "Executing danger" + regression_tester_setup_ci + regression_tester_executeDanger + pmd_ci_log_group_end + fi + + exit 0 fi - log_group_start "Creating new baseline for regression tester" + + if [ "$(pmd_ci_utils_get_os)" != "linux" ]; then + pmd_ci_log_group_start "Build with mvnw" + ./mvnw clean verify --show-version --errors --batch-mode --no-transfer-progress ${PMD_MAVEN_EXTRA_OPTS} + pmd_ci_log_group_end + + pmd_ci_log_info "Stopping build here, because os is not linux" + exit 0 + fi + + # only builds on pmd/pmd continue here + pmd_ci_log_group_start "Setup environment" + pmd_ci_setup_secrets_private_env + pmd_ci_setup_secrets_gpg_key + pmd_ci_setup_secrets_ssh + pmd_ci_maven_setup_settings + pmd_ci_log_group_end + + pmd_ci_log_group_start "Build and Deploy" + pmd_ci_build_run + pmd_ci_deploy_build_artifacts + pmd_ci_log_group_end + + pmd_ci_log_group_start "Build and Upload documentation" + pmd_ci_build_and_upload_doc + pmd_ci_log_group_end + + if pmd_ci_maven_isReleaseBuild; then + pmd_ci_log_group_start "Publishing Release" + pmd_ci_gh_releases_publishRelease "$GH_RELEASE" + pmd_ci_sourceforge_selectDefault "${PMD_CI_MAVEN_PROJECT_VERSION}" + pmd_ci_log_group_end + fi + + pmd_ci_log_group_start "Creating new baseline for regression tester" regression_tester_setup_ci regression_tester_uploadBaseline - log_group_end - - exit 0 + pmd_ci_log_group_end } -# -# Configures maven. -# Needed for deploy to central (both snapshots and releases) -# and for signing the artifacts. -# -function pmd_ci_build_setup_maven() { - mkdir -p ${HOME}/.m2 - cp .ci/files/maven-settings.xml ${HOME}/.m2/settings.xml -} - # # Installs bundler, which is needed for doc generation and regression tester # @@ -69,54 +91,22 @@ function pmd_ci_build_setup_bundler() { gem install bundler } -# -# Setups common build parameters: -# * Determines the VERSION of PMD, that is being built -# * Determines the PMD_CI_BRANCH or PMD_CI_TAG, that is being built -# -function pmd_ci_build_setup_env() { - VERSION=$(pmd_ci_build_get_pom_version) - - if [[ "${PMD_CI_GIT_REF}" == refs/heads/* ]]; then - PMD_CI_BRANCH=${PMD_CI_GIT_REF##refs/heads/} - unset PMD_CI_TAG - log_info "Building PMD ${VERSION} on branch ${PMD_CI_BRANCH}" - elif [[ "${PMD_CI_GIT_REF}" == refs/tags/* ]]; then - unset PMD_CI_BRANCH - PMD_CI_TAG=${PMD_CI_GIT_REF##refs/tags/} - log_info "Building PMD ${VERSION} on tag ${PMD_CI_TAG}" - else - log_error "Unknown branch/tag: PMD_CI_GIT_REF=${PMD_CI_GIT_REF}" - exit 1 - fi - - if [[ "${VERSION}" == *-SNAPSHOT && -z "$PMD_CI_BRANCH" ]]; then - log_error "Invalid combination: snapshot version ${VERSION} but no branch in PMD_CI_GIT_REF=${PMD_CI_GIT_REF}" - exit 1 - fi - - if [[ "${VERSION}" != *-SNAPSHOT && -z "$PMD_CI_TAG" ]]; then - log_error "Invalid combination: non-snapshot version ${VERSION} but no tag in PMD_CI_GIT_REF=${PMD_CI_GIT_REF}" - exit 1 - fi -} - # # Performs the actual build. # Deploys the artifacts to maven central. # Also generates rule documentation. # function pmd_ci_build_run() { - local mvn_profiles="ossrh,sign,generate-rule-docs" + local mvn_profiles="sign,generate-rule-docs" - if pmd_ci_build_isRelease; then - log_info "This is a release build" + if pmd_ci_maven_isReleaseBuild; then + pmd_ci_log_info "This is a release build" mvn_profiles="${mvn_profiles},pmd-release" else - log_info "This is a snapshot build" + pmd_ci_log_info "This is a snapshot build" fi - ./mvnw clean deploy -P${mvn_profiles} -e -B -V -Djava7.home=${HOME}/oraclejdk7 + ./mvnw clean deploy -P${mvn_profiles} --show-version --errors --batch-mode --no-transfer-progress ${PMD_MAVEN_EXTRA_OPTS} } # @@ -124,17 +114,17 @@ function pmd_ci_build_run() { # function pmd_ci_deploy_build_artifacts() { # Deploy to sourceforge files - sourceforge_uploadFile "${VERSION}" "pmd-dist/target/pmd-bin-${VERSION}.zip" - sourceforge_uploadFile "${VERSION}" "pmd-dist/target/pmd-src-${VERSION}.zip" + pmd_ci_sourceforge_uploadFile "${PMD_CI_MAVEN_PROJECT_VERSION}" "pmd-dist/target/pmd-bin-${PMD_CI_MAVEN_PROJECT_VERSION}.zip" + pmd_ci_sourceforge_uploadFile "${PMD_CI_MAVEN_PROJECT_VERSION}" "pmd-dist/target/pmd-src-${PMD_CI_MAVEN_PROJECT_VERSION}.zip" - if pmd_ci_build_isRelease; then + if pmd_ci_maven_isReleaseBuild; then # create a draft github release - gh_releases_createDraftRelease "${PMD_CI_TAG}" "$(git rev-list -n 1 ${PMD_CI_TAG})" + pmd_ci_gh_releases_createDraftRelease "${PMD_CI_TAG}" "$(git rev-list -n 1 ${PMD_CI_TAG})" GH_RELEASE="$RESULT" # Deploy to github releases - gh_release_uploadAsset "$GH_RELEASE" "pmd-dist/target/pmd-bin-${VERSION}.zip" - gh_release_uploadAsset "$GH_RELEASE" "pmd-dist/target/pmd-src-${VERSION}.zip" + pmd_ci_gh_releases_uploadAsset "$GH_RELEASE" "pmd-dist/target/pmd-bin-${PMD_CI_MAVEN_PROJECT_VERSION}.zip" + pmd_ci_gh_releases_uploadAsset "$GH_RELEASE" "pmd-dist/target/pmd-src-${PMD_CI_MAVEN_PROJECT_VERSION}.zip" fi } @@ -145,35 +135,35 @@ function pmd_ci_build_and_upload_doc() { pmd_doc_generate_jekyll_site pmd_doc_create_archive - sourceforge_uploadFile "${VERSION}" "docs/pmd-doc-${VERSION}.zip" - if pmd_ci_build_isRelease; then - gh_release_uploadAsset "$GH_RELEASE" "docs/pmd-doc-${VERSION}.zip" + pmd_ci_sourceforge_uploadFile "${PMD_CI_MAVEN_PROJECT_VERSION}" "docs/pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}.zip" + if pmd_ci_maven_isReleaseBuild; then + pmd_ci_gh_releases_uploadAsset "$GH_RELEASE" "docs/pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}.zip" fi - # Deploy doc to https://docs.pmd-code.org/pmd-doc-${VERSION}/ - pmd_code_uploadDocumentation "${VERSION}" "docs/pmd-doc-${VERSION}.zip" - # Deploy javadoc to https://docs.pmd-code.org/apidocs/*/${VERSION}/ - pmd_code_uploadJavadoc "${VERSION}" "$(pwd)" + # Deploy doc to https://docs.pmd-code.org/pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}/ + pmd_code_uploadDocumentation "${PMD_CI_MAVEN_PROJECT_VERSION}" "docs/pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}.zip" + # Deploy javadoc to https://docs.pmd-code.org/apidocs/*/${PMD_CI_MAVEN_PROJECT_VERSION}/ + pmd_code_uploadJavadoc "${PMD_CI_MAVEN_PROJECT_VERSION}" "$(pwd)" - if [[ "${VERSION}" == *-SNAPSHOT && "${PMD_CI_BRANCH}" == "master" ]]; then + if [ pmd_ci_maven_isSnapshotBuild && "${PMD_CI_BRANCH}" = "master" ]; then # only for snapshot builds from branch master - pmd_code_createSymlink "${VERSION}" "snapshot" + pmd_code_createSymlink "${PMD_CI_MAVEN_PROJECT_VERSION}" "snapshot" # update github pages https://pmd.github.io/pmd/ pmd_doc_publish_to_github_pages # rsync site to https://pmd.sourceforge.io/snapshot - sourceforge_rsyncSnapshotDocumentation "${VERSION}" "snapshot" + pmd_ci_sourceforge_rsyncSnapshotDocumentation "${PMD_CI_MAVEN_PROJECT_VERSION}" "snapshot" fi - if pmd_ci_build_isRelease; then - # documentation is already uploaded to https://docs.pmd-code.org/pmd-doc-${VERSION} + if pmd_ci_maven_isReleaseBuild; then + # documentation is already uploaded to https://docs.pmd-code.org/pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION} # we only need to setup symlinks for the released version - pmd_code_createSymlink "${VERSION}" "latest" + pmd_code_createSymlink "${PMD_CI_MAVEN_PROJECT_VERSION}" "latest" # remove old doc and point to the new version - pmd_code_removeDocumentation "${VERSION}-SNAPSHOT" - pmd_code_createSymlink "${VERSION}" "${VERSION}-SNAPSHOT" + pmd_code_removeDocumentation "${PMD_CI_MAVEN_PROJECT_VERSION}-SNAPSHOT" + pmd_code_createSymlink "${PMD_CI_MAVEN_PROJECT_VERSION}" "${PMD_CI_MAVEN_PROJECT_VERSION}-SNAPSHOT" # remove old javadoc - pmd_code_removeJavadoc "${VERSION}-SNAPSHOT" + pmd_code_removeJavadoc "${PMD_CI_MAVEN_PROJECT_VERSION}-SNAPSHOT" # updating github release text rm -f .bundle/config @@ -182,28 +172,16 @@ function pmd_ci_build_and_upload_doc() { bundle install # renders, and skips the first 6 lines - the Jekyll front-matter local rendered_release_notes=$(bundle exec .ci/render_release_notes.rb docs/pages/release_notes.md | tail -n +6) - local release_name="PMD ${VERSION} ($(date -u +%d-%B-%Y))" - gh_release_updateRelease "$GH_RELEASE" "$release_name" "$rendered_release_notes" - sourceforge_uploadReleaseNotes "${VERSION}" "${rendered_release_notes}" + local release_name="PMD ${PMD_CI_MAVEN_PROJECT_VERSION} ($(date -u +%d-%B-%Y))" + pmd_ci_gh_releases_updateRelease "$GH_RELEASE" "$release_name" "$rendered_release_notes" + pmd_ci_sourceforge_uploadReleaseNotes "${PMD_CI_MAVEN_PROJECT_VERSION}" "${rendered_release_notes}" - # updates https://pmd.github.io/latest/ and https://pmd.github.io/pmd-${VERSION} + # updates https://pmd.github.io/latest/ and https://pmd.github.io/pmd-${PMD_CI_MAVEN_PROJECT_VERSION} publish_release_documentation_github - sourceforge_rsyncSnapshotDocumentation "${VERSION}" "pmd-${VERSION}" + pmd_ci_sourceforge_rsyncSnapshotDocumentation "${PMD_CI_MAVEN_PROJECT_VERSION}" "pmd-${PMD_CI_MAVEN_PROJECT_VERSION}" fi } +build -function pmd_ci_build_isRelease() { - if [[ "${VERSION}" != *-SNAPSHOT && -n "${PMD_CI_TAG}" && -z "${PMD_CI_BRANCH}" ]]; then - return 0 - else - return 1 - fi -} - -function pmd_ci_build_get_pom_version() { - echo $(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:3.0.0:exec) -} - - -pmd_ci_build_main +exit 0 diff --git a/.ci/check-environment.sh b/.ci/check-environment.sh deleted file mode 100755 index d164569a19..0000000000 --- a/.ci/check-environment.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env bash - -# -# This script should check, that all needed commands are available -# and are in the correct version. -# - -source $(dirname $0)/inc/logger.inc - -set -e - -function check() { - local CMD=$1 - local VERSION_CMD=$2 - local VERSION_STRING=$3 - - echo -n "Checking ${CMD}..." - - if hash "$CMD" 2>/dev/null; then - local VERSION_FULL=$(${VERSION_CMD} 2>&1) - local VERSION=$(echo "${VERSION_FULL}" | grep "${VERSION_STRING}" 2>&1) - if [ -n "${VERSION}" ]; then - echo -e "${COL_GREEN}OK${COL_RESET}" - echo " ${VERSION}" - else - echo -e "${COL_RED}wrong version${COL_RESET}. Expected: ${VERSION_STRING}" - echo " ${VERSION_FULL}" - fi - else - echo -e "${COL_RED}not found!${COL_RESET}" - fi -} - -# every OS: -check "curl" "curl --version" "curl" -check "jq" "jq --version" "jq" - -case "$(uname)" in - Linux*) - check "ruby" "ruby --version" "ruby 2.7" - check "gpg" "gpg --version" "gpg (GnuPG) 2." - check "printenv" "printenv --version" "printenv (GNU coreutils)" - check "rsync" "rsync --version" "version" - check "ssh" "ssh -V" "OpenSSH" - check "git" "git --version" "git version" - check "mvn" "mvn --version" "Apache Maven" - check "unzip" "unzip --version" "UnZip" - check "zip" "zip --version" "This is Zip" - #check "7z" "7z -version" "7-Zip" - ;; - Darwin*) - ;; - CYGWIN*|MINGW*) - check "7z" "7z -version" "7-Zip" - ;; - *) - log_error "Unknown OS: $(uname)" - exit 1 - ;; -esac diff --git a/.ci/files/id_rsa.gpg b/.ci/files/id_rsa.gpg deleted file mode 100644 index 8e68ae0f100435fca4d9c8066e5dbd2117687a73..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2557 zcmV!5$``#6|RLZhUVd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VLHYDsKui8tYg/sFvkDqcs97pEZz0BzK9HtBF4O+/It1drRYRdUAFfjoImfprpKSxkJCTglHixGRp24eNaZ6woWVJ4/bmiMkEqEZAjr1NZ3qw7zIruMJMSkCV+YTtmL4cYcZlvMRPzzOZOnFbV05oi79oy41MUFHYjolK9QxMFNsVNN5iyzFxM3HqSFozz+ylKbFBtDk6ZHZQNRL/Xl2V9DJ69fVzjG4OZfcWNGmmKHHARmsnJyUOMeeKpLjDOe1M6ZdI8HkXWac8yCr9JTETNZZwemZAcS/RKoKCDqfIUOzkZfIPmyaznfVetTGsMi7yQrJhAyjznuNGF4+3lfgTcmRF8wz5FCeUkdYTmy2wNSFi5HiLPfC5OgRtjKzC6yb8rbRjDx6XQ2ph15PKOaXwzk49TaMc0xJvoiGDMZaTU0iTm3Y1/QUtfLvo3/jGMbtUdV3soWpuBAV2JUI4aB5xdLX9iNmcrVzoUe3y9DWuuTX46eoCvpUNXv/DXKhQw1D7xd7J67db5qUck/Akiqi0JR+e0SoBJvZFtYwVNLGC2bIJ/s8SR8X5Zp+1+ypf3WYjIylxQTkO1r4NfI0Cd9qXg7nmUrHAU7Z6xtJmUK8ZWzSST4wul8WkRJURtODLxt5firtlKhyZ93t9Mjuk6mATIPxr/b3x20T+IH463kw== ssh key for pmd. used for travis accessing sourceforge and github. diff --git a/.ci/files/maven-settings.xml b/.ci/files/maven-settings.xml deleted file mode 100644 index a8d61b8f1a..0000000000 --- a/.ci/files/maven-settings.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - org.sonarsource.scanner.maven - - - - ossrh - ${env.CI_DEPLOY_USER} - ${env.CI_DEPLOY_PASSWORD} - - - - - - - ossrh - - ${env.CI_SIGN_KEY} - ${env.CI_SIGN_PASSPHRASE} - - - - - diff --git a/.ci/files/private-env.gpg b/.ci/files/private-env.gpg deleted file mode 100644 index af292ee8b509f5ac8706b4c430886d4bf45507f3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 611 zcmV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dHWmxN&zQ2%P(E@TrT=r-B6O4^Q18oiUNP<3-gr>vj zFwlYHfo6P&ES zv4A__56A8#d5!+a0t@thz{+eTD5E3db~&6IR20#%TW1Dz6JC7kZC9zz<|L79DAMb# zF&LC*E7~BX-qW{QLqxp}IPeTx!>Ak7RcWdc#YF1Uvi|RGKV##o>5Gdt*M%*y>Xu&(O`LWyj|?ksNkU_yNz?Q^Sh^{2tqCdJnDz zc7)~(VZQidgj^H+SZ=nP3~bJn=QiI1`Di|Ng2MUvbxjQxtygd4q$bnk2cE*d#@DVmyFyuk=Xfzu#(}V4yF(Dt+2o zWj-sz9lLY;GTW6xl6H&mUF<4L6cT61$C9<0BMmvl7)+V_2s}05kkW0?PMctnA6t`v zv{b(L+&GWuEEG-6mrWcNJ}ij)WU?LZ8{-e=g3H4orCkX$@n}F2*C6ME`rb551~&j0ECumAu6 diff --git a/.ci/inc/fetch_ci_scripts.bash b/.ci/inc/fetch_ci_scripts.bash new file mode 100644 index 0000000000..d608e40531 --- /dev/null +++ b/.ci/inc/fetch_ci_scripts.bash @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +function fetch_ci_scripts() { + local inc_dir + local inc_url + inc_dir="$(dirname "$0")/inc" + inc_url="${PMD_CI_SCRIPTS_URL:-https://raw.githubusercontent.com/pmd/build-tools/master/scripts}/inc" + + mkdir -p "${inc_dir}" + + for f in ${SCRIPT_INCLUDES}; do + if [ ! -e "${inc_dir}/$f" ]; then + curl -sSL "${inc_url}/$f" > "${inc_dir}/$f" + fi + [ "$PMD_CI_DEBUG" = "true" ] && echo "loading ${inc_dir}/$f in ${MODULE:-$0}" + # shellcheck source=/dev/null + source "${inc_dir}/$f" || exit 1 + done +} diff --git a/.ci/inc/github-releases-api.inc b/.ci/inc/github-releases-api.inc deleted file mode 100644 index e71e67f941..0000000000 --- a/.ci/inc/github-releases-api.inc +++ /dev/null @@ -1,214 +0,0 @@ -# -# The functions here require the following scripts: -# logger.inc -# -# The functions here require the following environment variables: -# GITHUB_OAUTH_TOKEN -# GITHUB_BASE_URL -# - -# -# Creates a new release on github with the given tag and target_commit. -# The release is draft and not published. -# -# $RESULT = release json string -# -# See: https://developer.github.com/v3/repos/releases/#create-a-release -# -function gh_releases_createDraftRelease() { - local tagName="$1" - local targetCommitish="$2" - - log_debug "$FUNCNAME: Creating new draft release for tag=$tagName and commit=$targetCommitish" - - local request=$(cat <<-EOF - { - "tag_name": "${tagName}", - "target_commitish": "${targetCommitish}", - "name": "${tagName}", - "draft": true - } - EOF - ) - - log_debug "POST $GITHUB_BASE_URL/releases" - log_info "Creating github draft release" - RESULT=$(curl --fail -s -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" \ - -H "Content-Type: application/json" \ - -X POST \ - --data "${request}" \ - "$GITHUB_BASE_URL/releases") - log_debug " -> response: $RESULT" - - log_success "Created draft release with id $(echo $RESULT | jq --raw-output ".url")" -} - -# -# Gets the latest release, if it is a draft and returns with 0. -# Returns with 1, if the latest release is not a draft - meaning, there is no -# draft release (yet?). -# -# RESULT = release json string -# -# See: https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository -# -function gh_releases_getLatestDraftRelease() { - log_debug "$FUNCNAME" - log_debug "GET $GITHUB_BASE_URL/releases?per_page=1" - RESULT=$(curl --fail -s -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" \ - "$GITHUB_BASE_URL/releases?per_page=1" | jq ".[0]") - log_debug " -> response: $RESULT" - local draft=$(echo $RESULT | jq ".draft") - if [ "$draft" != "true" ]; then - RESULT="" - log_error "Could not find draft release!" - return 1 - fi - log_info "Found draft release: $(echo $RESULT | jq --raw-output ".url")" -} - -# -# Deletes a release. -# -# See: https://developer.github.com/v3/repos/releases/#delete-a-release -# -function gh_release_deleteRelease() { - local release="$1" - - gh_release_getIdFromData "$release" - local releaseId="$RESULT" - log_debug "$FUNCNAME id=$releaseId" - log_debug "DELETE $GITHUB_BASE_URL/releases/$releaseId" - log_info "Deleting github release $releaseId" - local response - response=$(curl --fail -s -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" \ - -X DELETE \ - "$GITHUB_BASE_URL/releases/$releaseId") - log_debug " -> response: $response" - log_success "Deleted release with id $releaseId" -} - -# -# Determines the release id from the given JSON release data. -# -# RESULT = "the release id" -# -function gh_release_getIdFromData() { - local release="$1" - - RESULT=$(echo $release | jq --raw-output ".id") -} - -# -# Determines the tag_name from the given JSON release data. -# -# RESULT = "the tag name" -# -function gh_release_getTagNameFromData() { - local release="$1" - - RESULT=$(echo $release | jq --raw-output ".tag_name") -} - -# -# Uploads a asset to an existing release. -# -# See: https://developer.github.com/v3/repos/releases/#upload-a-release-asset -# -function gh_release_uploadAsset() { - local release="$1" - local filename="$2" - local name=$(basename $filename) - - gh_release_getIdFromData "$release" - local releaseId="$RESULT" - log_debug "$FUNCNAME: releaseId=$releaseId file=$filename name=$name" - - local uploadUrl=$(echo "$release" | jq --raw-output ".upload_url") - uploadUrl="${uploadUrl%%\{\?name,label\}}" - uploadUrl="${uploadUrl}?name=${name}" - log_debug "POST $uploadUrl" - log_info "Uploading $filename to github release $releaseId" - local response - response=$(curl --fail -s -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" \ - -H "Content-Type: application/zip" \ - --data-binary "@$filename" \ - -X POST \ - "${uploadUrl}") - log_debug " -> response: $response" - log_success "Uploaded release asset $filename for release $releaseId" -} - -# -# Updates the release info: name and body. -# The body is escaped to fit into JSON, so it is allowed for the body to be -# a multi-line string. -# -# See: https://developer.github.com/v3/repos/releases/#edit-a-release -# -function gh_release_updateRelease() { - local release="$1" - local name="$2" - local body="$3" - - gh_release_getIdFromData "$release" - local releaseId="$RESULT" - gh_release_getTagNameFromData "$release" - local tagName="$RESULT" - log_debug "$FUNCNAME releaseId=$releaseId name=$name tag_name=$tagName" - - body="${body//'\'/\\\\}" - body="${body//$'\r'/}" - body="${body//$'\n'/\\r\\n}" - body="${body//'"'/\\\"}" - - local request=$(cat <<-EOF - { - "tag_name": "${tagName}", - "name": "${name}", - "body": "${body}" - } - EOF - ) - - log_debug "PATCH $GITHUB_BASE_URL/releases/${releaseId}" - log_debug " -> request: $request" - log_info "Updating github release $releaseId" - local response - response=$(curl --fail -s -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" \ - -H "Content-Type: application/json" \ - --data "${request}" \ - -X PATCH \ - "$GITHUB_BASE_URL/releases/${releaseId}") - log_debug " -> response: $response" - log_success "Updated release with id=$releaseId" -} - -# -# Publish a release by setting draft="false". -# Note: This will send out the notification emails if somebody -# watched the releases. -# -# See: https://developer.github.com/v3/repos/releases/#edit-a-release -# -function gh_release_publishRelease() { - local release="$1" - - gh_release_getIdFromData "$release" - local releaseId="$RESULT" - log_debug "$FUNCNAME releaseId=$releaseId" - - local request='{"draft":false}' - log_debug "PATCH $GITHUB_BASE_URL/releases/${releaseId}" - log_debug " -> request: $request" - log_info "Publishing github release $releaseId" - local response - response=$(curl --fail -s -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" \ - -H "Content-Type: application/json" \ - --data "${request}" \ - -X PATCH \ - "$GITHUB_BASE_URL/releases/${releaseId}") - log_debug " -> response: $response" - local htmlUrl=$(echo "$response" | jq --raw-output ".html_url") - log_success "Published release with id=$releaseId at $htmlUrl" -} diff --git a/.ci/inc/install-openjdk.inc b/.ci/inc/install-openjdk.inc deleted file mode 100644 index c9a963242b..0000000000 --- a/.ci/inc/install-openjdk.inc +++ /dev/null @@ -1,103 +0,0 @@ - -# needs: -# inc/logger - -# -# Downloads openjdk from AdoptOpenJDK by accessing the API. -# The API is documented at https://api.adoptopenjdk.net/swagger-ui/ -# - -function install_openjdk() { - OPENJDK_VERSION=$1 - - case "$(uname)" in - Linux*) - JDK_OS=linux - COMPONENTS_TO_STRIP=1 # e.g. openjdk-11.0.3+7/bin/java - ;; - Darwin*) - JDK_OS=mac - COMPONENTS_TO_STRIP=3 # e.g. jdk-11.0.3+7/Contents/Home/bin/java - ;; - CYGWIN*|MINGW*) - JDK_OS=windows - ;; - *) - log_error "Unknown OS: $(uname)" - exit 1 - ;; - esac - - - DOWNLOAD_URL=$(curl --silent -X GET "https://api.adoptopenjdk.net/v3/assets/feature_releases/${OPENJDK_VERSION}/ga?architecture=x64&heap_size=normal&image_type=jdk&jvm_impl=hotspot&os=${JDK_OS}&page=0&page_size=1&project=jdk&sort_method=DEFAULT&sort_order=DESC&vendor=adoptopenjdk" \ - -H "accept: application/json" \ - | jq -r ".[0].binaries[0].package.link") - - OPENJDK_ARCHIVE=$(basename ${DOWNLOAD_URL}) - log_debug "Archive name: ${OPENJDK_ARCHIVE}" - - CACHE_DIR=${HOME}/.cache/openjdk - TARGET_DIR=${HOME}/openjdk${OPENJDK_VERSION} - - mkdir -p ${CACHE_DIR} - mkdir -p ${TARGET_DIR} - - if [ ! -e ${CACHE_DIR}/${OPENJDK_ARCHIVE} ]; then - log_info "Downloading from ${DOWNLOAD_URL} to ${CACHE_DIR}" - curl --location --output ${CACHE_DIR}/${OPENJDK_ARCHIVE} "${DOWNLOAD_URL}" - else - log_info "Skipped download, file ${CACHE_DIR}/${OPENJDK_ARCHIVE} already exists" - fi - - log_info "Extracting to ${TARGET_DIR}" - - case "$OPENJDK_ARCHIVE" in - *.zip) - 7z x ${CACHE_DIR}/${OPENJDK_ARCHIVE} -o${TARGET_DIR} - mv ${TARGET_DIR}/*/* ${TARGET_DIR}/ - ;; - *.tar.gz) - tar --extract --file ${CACHE_DIR}/${OPENJDK_ARCHIVE} -C ${TARGET_DIR} --strip-components=${COMPONENTS_TO_STRIP} - ;; - *) - log_error "Unknown filetype: ${OPENJDK_ARCHIVE}" - exit 1 - ;; - esac -} - -function install_openjdk_setdefault() { - OPENJDK_VERSION=$1 - - install_openjdk $OPENJDK_VERSION - - log_info "Using OpenJDK ${OPENJDK_VERSION} as default" - TARGET_DIR=${HOME}/openjdk${OPENJDK_VERSION} - export JAVA_HOME="${TARGET_DIR}" - export PATH="${TARGET_DIR}/bin:${PATH}" - - java -version -} - -# -# Installs jdk7 for integration test -# -function install_oraclejdk7() { - local local_dir="${HOME}/.cache/jdk7" - local target_dir="${HOME}/oraclejdk7" - local download_url="https://pmd-code.org/oraclejdk/jdk-7u80-linux-x64.tar.gz" - local archive=$(basename $download_url) - - mkdir -p ${local_dir} - mkdir -p ${target_dir} - if [ ! -e ${local_dir}/${archive} ]; then - log_info "Downloading from ${download_url} to ${local_dir}" - curl --location --output ${local_dir}/${archive} ${download_url} - else - log_info "Skipped download, file ${local_dir}/${archive} already exists" - fi - log_info "Extracting to ${target_dir}" - tar --extract --file ${local_dir}/${archive} -C ${target_dir} --strip-components=1 - - log_info "OracleJDK7 can be used via -Djava7.home=${HOME}/oraclejdk7" -} diff --git a/.ci/inc/logger.inc b/.ci/inc/logger.inc deleted file mode 100644 index cf002de9a1..0000000000 --- a/.ci/inc/logger.inc +++ /dev/null @@ -1,30 +0,0 @@ -COL_GREEN="\e[32m" -COL_RED="\e[31m" -COL_RESET="\e[0m" -COL_YELLOW="\e[33;1m" - -function log_error() { - echo -e "${COL_RED}[ERROR ] $*${COL_RESET}" -} - -function log_info() { - echo -e "${COL_YELLOW}[INFO ] $*${COL_RESET}" -} - -function log_success() { - echo -e "${COL_GREEN}[SUCCESS] $*${COL_RESET}" -} - -function log_debug() { - true - #echo -e "[DEBUG ] $*" -} - -function log_group_start() { - echo "::group::$*" - log_info $* -} - -function log_group_end() { - echo "::endgroup::" -} \ No newline at end of file diff --git a/.ci/inc/pmd-code-api.inc b/.ci/inc/pmd-code-api.inc index d9e75beb7c..122f7be59b 100644 --- a/.ci/inc/pmd-code-api.inc +++ b/.ci/inc/pmd-code-api.inc @@ -1,7 +1,9 @@ -# -# The functions here require the following scripts: -# inc/logger.inc -# +#!/usr/bin/env bash + +MODULE="pmd-code-api" +SCRIPT_INCLUDES="log.bash" +# shellcheck source=inc/fetch_ci_scripts.bash +source "$(dirname "$0")/inc/fetch_ci_scripts.bash" && fetch_ci_scripts PMD_CODE_SSH_USER=pmd PMD_CODE_DOCS_PATH=/docs.pmd-code.org/ @@ -11,53 +13,51 @@ function pmd_code_uploadDocumentation() { local filename="$2" local basefilename="$(basename $filename)" - log_debug "$FUNCNAME pmdVersion=$pmdVersion filename=$filename" + pmd_ci_log_debug "$FUNCNAME pmdVersion=$pmdVersion filename=$filename" scp "${filename}" ${PMD_CODE_SSH_USER}@pmd-code.org:${PMD_CODE_DOCS_PATH} ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH} && \ unzip -qo ${basefilename} && \ rm ${basefilename}" - log_info "Docs updated: https://docs.pmd-code.org/pmd-doc-${pmdVersion}/" + pmd_ci_log_info "Docs updated: https://docs.pmd-code.org/pmd-doc-${pmdVersion}/" } function pmd_code_removeDocumentation() { local pmdVersion="$1" - log_debug "$FUNCNAME pmdVersion=$pmdVersion" + pmd_ci_log_debug "$FUNCNAME pmdVersion=$pmdVersion" ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH} && \ rm -rf pmd-doc-${pmdVersion}/" - log_info "Removed docs: https://docs.pmd-code.org/pmd-doc-${pmdVersion}/" + pmd_ci_log_info "Removed docs: https://docs.pmd-code.org/pmd-doc-${pmdVersion}/" } function pmd_code_createSymlink() { local pmdVersion="$1" local name="$2" - log_debug "$FUNCNAME pmdVersion=$pmdVersion name=$name" + pmd_ci_log_debug "$FUNCNAME pmdVersion=$pmdVersion name=$name" ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH} && \ rm -f $name && \ ln -s pmd-doc-${pmdVersion} $name" - log_info "Symlink created: https://docs.pmd-code.org/$name/ -> https://docs.pmd-code.org/pmd-doc-${pmdVersion}/" + pmd_ci_log_info "Symlink created: https://docs.pmd-code.org/$name/ -> https://docs.pmd-code.org/pmd-doc-${pmdVersion}/" } function pmd_code_uploadJavadoc() { local pmdVersion="$1" local basePath="$2" - log_debug "$FUNCNAME pmdVersion=$pmdVersion basePath=$basePath" + pmd_ci_log_debug "$FUNCNAME pmdVersion=$pmdVersion basePath=$basePath" for i in ${basePath}/*/target/*-javadoc.jar */*/target/*-javadoc.jar; do pmd_code_uploadJavadocModule "$pmdVersion" "$i" done - pmd_code_fixPmdLangTestStyle "${basePath}" - # make sure https://docs.pmd-code.org/apidocs/ shows directory index ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH}/apidocs && \ echo 'Options +Indexes' > .htaccess" - log_info "Directory index enabled for https://docs.pmd-code.org/apidocs/" + pmd_ci_log_info "Directory index enabled for https://docs.pmd-code.org/apidocs/" } function pmd_code_uploadJavadocModule() { @@ -66,29 +66,21 @@ function pmd_code_uploadJavadocModule() { local moduleJavadocJarBasename="$(basename $moduleJavadocJar)" local module=${moduleJavadocJarBasename%%-${pmdVersion}-javadoc.jar} - log_debug "$FUNCNAME pmdVersion=$pmdVersion moduleJavadocJar=$moduleJavadocJar module=$module" + pmd_ci_log_debug "$FUNCNAME pmdVersion=$pmdVersion moduleJavadocJar=$moduleJavadocJar module=$module" scp "$moduleJavadocJar" ${PMD_CODE_SSH_USER}@pmd-code.org:${PMD_CODE_DOCS_PATH} ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH} && \ mkdir -p apidocs/${module}/${pmdVersion} && \ unzip -qo -d apidocs/${module}/${pmdVersion} ${moduleJavadocJarBasename} && \ rm ${moduleJavadocJarBasename}" - log_info "JavaDoc for $module uploaded: https://docs.pmd-code.org/apidocs/${module}/${pmdVersion}/" -} - -function pmd_code_fixPmdLangTestStyle { - local basePath="$1" - - log_debug "$FUNCNAME basePath=$basePath" - scp "${basePath}/pmd-lang-test/target/dokka/style.css" ${PMD_CODE_SSH_USER}@pmd-code.org:${PMD_CODE_DOCS_PATH}/apidocs/pmd-lang-test/ - log_info "Fixed style for https://docs.pmd-code.org/apidocs/pmd-lang-test/*/" + pmd_ci_log_info "JavaDoc for $module uploaded: https://docs.pmd-code.org/apidocs/${module}/${pmdVersion}/" } function pmd_code_removeJavadoc() { local pmdVersion="$1" - log_debug "$FUNCNAME pmdVersion=$pmdVersion" + pmd_ci_log_debug "$FUNCNAME pmdVersion=$pmdVersion" ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH} && \ rm -rf apidocs/*/${pmdVersion}" - log_info "Removed Javadoc: https://docs.pmd-code.org/apidocs/*/${pmdVersion}/ is gone" + pmd_ci_log_info "Removed Javadoc: https://docs.pmd-code.org/apidocs/*/${pmdVersion}/ is gone" } diff --git a/.ci/inc/pmd-doc.inc b/.ci/inc/pmd-doc.inc index 6054baca46..370b22d3fe 100644 --- a/.ci/inc/pmd-doc.inc +++ b/.ci/inc/pmd-doc.inc @@ -1,3 +1,9 @@ +#!/usr/bin/env bash + +MODULE="pmd-doc" +SCRIPT_INCLUDES="log.bash" +# shellcheck source=inc/fetch_ci_scripts.bash +source "$(dirname "$0")/inc/fetch_ci_scripts.bash" && fetch_ci_scripts # Used env vars: # PMD_CI_JOB_URL @@ -12,7 +18,7 @@ function pmd_doc_generate_jekyll_site() { pushd docs echo -e "\n\n" - log_info "Building documentation using jekyll..." + pmd_ci_log_info "Building documentation using jekyll..." bundle config set --local path vendor/bundle bundle install bundle exec jekyll build @@ -27,21 +33,21 @@ function pmd_doc_create_archive() { pushd docs echo -e "\n\n" - log_info "Creating pmd-doc archive..." - mv _site pmd-doc-${VERSION} - zip -qr pmd-doc-${VERSION}.zip pmd-doc-${VERSION}/ - log_success "Successfully created pmd-doc-${VERSION}.zip" + pmd_ci_log_info "Creating pmd-doc archive..." + mv _site pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION} + zip -qr pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}.zip pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}/ + pmd_ci_log_success "Successfully created pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}.zip" popd } # -# Publishes the site to https://pmd.github.io/pmd-${VERSION} and +# Publishes the site to https://pmd.github.io/pmd-${PMD_CI_MAVEN_PROJECT_VERSION} and # https://pmd.github.io/latest/ # function publish_release_documentation_github() { echo -e "\n\n" - log_info "Adding the new doc to pmd.github.io..." + pmd_ci_log_info "Adding the new doc to pmd.github.io..." # clone pmd.github.io. Note: This uses the ssh key setup earlier # In order to speed things up, we use a sparse checkout - no need to checkout all directories here mkdir pmd.github.io @@ -55,30 +61,30 @@ function publish_release_documentation_github() { echo "/latest/" > .git/info/sparse-checkout echo "/sitemap.xml" >> .git/info/sparse-checkout git pull --depth=1 origin master - log_info "Copying documentation from ../docs/pmd-doc-${VERSION}/ to pmd-${VERSION}/ ..." - rsync -ah --stats ../docs/pmd-doc-${VERSION}/ pmd-${VERSION}/ + pmd_ci_log_info "Copying documentation from ../docs/pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}/ to pmd-${PMD_CI_MAVEN_PROJECT_VERSION}/ ..." + rsync -ah --stats ../docs/pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}/ pmd-${PMD_CI_MAVEN_PROJECT_VERSION}/ git status - echo "Executing: git add pmd-${VERSION}" - git add pmd-${VERSION} - echo "Executing: git commit..." - git commit -q -m "Added pmd-${VERSION}" + pmd_ci_log_debug "Executing: git add pmd-${PMD_CI_MAVEN_PROJECT_VERSION}" + git add pmd-${PMD_CI_MAVEN_PROJECT_VERSION} + pmd_ci_log_debug "Executing: git commit..." + git commit -q -m "Added pmd-${PMD_CI_MAVEN_PROJECT_VERSION}" - log_info "Copying pmd-${VERSION} to latest ..." + pmd_ci_log_info "Copying pmd-${PMD_CI_MAVEN_PROJECT_VERSION} to latest ..." git rm -qr latest - cp -a pmd-${VERSION} latest - echo "Executing: git add latest" + cp -a pmd-${PMD_CI_MAVEN_PROJECT_VERSION} latest + pmd_ci_log_debug "Executing: git add latest" git add latest - echo "Executing: git commit..." - git commit -q -m "Copying pmd-${VERSION} to latest" + pmd_ci_log_debug "Executing: git commit..." + git commit -q -m "Copying pmd-${PMD_CI_MAVEN_PROJECT_VERSION} to latest" - log_info "Generating sitemap.xml" + pmd_ci_log_info "Generating sitemap.xml" ../docs/sitemap_generator.sh > sitemap.xml - echo "Executing: git add sitemap.xml" + pmd_ci_log_debug "Executing: git add sitemap.xml" git add sitemap.xml - echo "Executing: git commit..." + pmd_ci_log_debug "Executing: git commit..." git commit -q -m "Generated sitemap.xml" - echo "Executing: git push origin master" + pmd_ci_log_info "Executing: git push origin master" git push origin master ) } @@ -89,12 +95,12 @@ function publish_release_documentation_github() { # function pmd_doc_publish_to_github_pages() { echo -e "\n\n" - log_info "Pushing the new site to github pages..." + pmd_ci_log_info "Pushing the new site to github pages..." git clone --branch gh-pages --depth 1 git@github.com:pmd/pmd.git pmd-gh-pages # clear the files first rm -rf pmd-gh-pages/* # copy the new site - cp -a docs/pmd-doc-${VERSION}/* pmd-gh-pages/ + cp -a docs/pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}/* pmd-gh-pages/ ( cd pmd-gh-pages git config user.name "PMD CI (pmd-bot)" @@ -106,6 +112,6 @@ ${PMD_CI_JOB_URL} ${PMD_CI_PUSH_COMMIT_COMPARE}" git commit -q -m "$MSG" git push git@github.com:pmd/pmd.git HEAD:gh-pages - log_success "Successfully pushed site to https://pmd.github.io/pmd/" + pmd_ci_log_success "Successfully pushed site to https://pmd.github.io/pmd/" ) } diff --git a/.ci/inc/regression-tester.inc b/.ci/inc/regression-tester.inc index 3bc72ccd81..65d6e1e6b2 100644 --- a/.ci/inc/regression-tester.inc +++ b/.ci/inc/regression-tester.inc @@ -1,7 +1,10 @@ -# -# The functions here require the following scripts: -# inc/logger.inc -# inc/install-openjdk.inc +#!/usr/bin/env bash + +MODULE="pmd-doc" +SCRIPT_INCLUDES="log.bash openjdk.bash" +# shellcheck source=inc/fetch_ci_scripts.bash +source "$(dirname "$0")/inc/fetch_ci_scripts.bash" && fetch_ci_scripts + # # The functions here require the following environment variables: # PMD_SF_USER @@ -11,8 +14,8 @@ # PMD_CI_CHUNK_TOKEN function regression_tester_setup_ci() { - log_info "Install openjdk8 for pmd-regression-tests" - install_openjdk 8 + pmd_ci_log_info "Install openjdk8 for pmd-regression-tests" + pmd_ci_openjdk_install_adoptopenjdk 8 gpg --batch --yes --decrypt --passphrase="GnxdjywUEPveyCD1RLiTd7t8CImnefYr" \ --output .ci/files/public-env .ci/files/public-env.gpg @@ -20,9 +23,9 @@ function regression_tester_setup_ci() { rm .ci/files/public-env if hash "bundler" 2>/dev/null; then - log_debug "Bundler is already installed" + pmd_ci_log_debug "Bundler is already installed" else - log_info "Installing bundler..." + pmd_ci_log_info "Installing bundler..." gem install bundler fi @@ -38,9 +41,9 @@ function regression_tester_setup_ci() { function regression_tester_uploadBaseline() { local pmdcodeUrl="https://pmd-code.org/pmd-regression-tester/" local baseline_branch="${PMD_CI_BRANCH:-$PMD_CI_TAG}" - log_debug "$FUNCNAME branch=${baseline_branch}" + pmd_ci_log_debug "$FUNCNAME branch=${baseline_branch}" - log_info "Generating and uploading baseline for pmdtester (${baseline_branch})..." + pmd_ci_log_info "Generating and uploading baseline for pmdtester (${baseline_branch})..." pushd .. rm -f .bundle/config bundle config set --local gemfile pmd/Gemfile @@ -54,9 +57,9 @@ function regression_tester_uploadBaseline() { pushd target/reports BRANCH_FILENAME="${baseline_branch/\//_}" zip -q -r ${BRANCH_FILENAME}-baseline.zip ${BRANCH_FILENAME}/ - # ssh-key for pmd-code.org is setup already by pmd_ci_setup_ssh + # ssh-key for pmd-code.org is setup already by pmd_ci_setup_secrets_ssh scp ${BRANCH_FILENAME}-baseline.zip pmd@pmd-code.org:/httpdocs/pmd-regression-tester/ - log_success "Successfully uploaded ${BRANCH_FILENAME}-baseline.zip to ${pmdcodeUrl}" + pmd_ci_log_success "Successfully uploaded ${BRANCH_FILENAME}-baseline.zip to ${pmdcodeUrl}" popd popd } @@ -65,7 +68,7 @@ function regression_tester_uploadBaseline() { # Execute danger, which executes pmd-regression-tester (via Dangerfile). # function regression_tester_executeDanger() { - log_debug "$FUNCNAME" + pmd_ci_log_debug "$FUNCNAME" # Create a corresponding remote branch locally if ! git show-ref --verify --quiet refs/heads/${PMD_CI_BRANCH}; then @@ -81,7 +84,7 @@ function regression_tester_executeDanger() { git branch master origin/master fi - log_info "Running danger on branch ${PMD_CI_BRANCH}" + pmd_ci_log_info "Running danger on branch ${PMD_CI_BRANCH}" bundle exec danger --verbose - log_success "Executed danger successfully" + pmd_ci_log_success "Executed danger successfully" } diff --git a/.ci/inc/setup-secrets.inc b/.ci/inc/setup-secrets.inc deleted file mode 100644 index 6cd3ba953b..0000000000 --- a/.ci/inc/setup-secrets.inc +++ /dev/null @@ -1,62 +0,0 @@ -function pmd_ci_setup_private_env() { - log_info "Setting up secrets as environment variables..." - local -r ENV_FILE=.ci/files/private-env - - printenv PMD_CI_SECRET_PASSPHRASE | gpg --batch --yes --decrypt \ - --passphrase-fd 0 \ - --output ${ENV_FILE} ${ENV_FILE}.gpg - - source ${ENV_FILE} >/dev/null 2>&1 - rm ${ENV_FILE} -} - -function pmd_ci_setup_gpg_key() { - log_info "Setting up GPG release signing key..." - local -r GPG_FILE=.ci/files/release-signing-key-D0BF1D737C9A1C22.gpg - - mkdir -p "${HOME}/.gpg" - printenv PMD_CI_SECRET_PASSPHRASE | gpg --batch --yes --decrypt \ - --passphrase-fd 0 \ - --output ${GPG_FILE} ${GPG_FILE}.gpg - gpg --batch --import ${GPG_FILE} - rm ${GPG_FILE} -} - -function pmd_ci_setup_ssh() { - log_info "Setting up .ssh/id_rsa..." - local -r SSH_KEY_FILE=.ci/files/id_rsa - - printenv PMD_CI_SECRET_PASSPHRASE | gpg --batch --yes --decrypt \ - --passphrase-fd 0 \ - --output ${SSH_KEY_FILE} ${SSH_KEY_FILE}.gpg - chmod 600 ${SSH_KEY_FILE} - - mkdir -p ${HOME}/.ssh - chmod 700 "${HOME}/.ssh" - mv ${SSH_KEY_FILE} "${HOME}/.ssh/id_rsa" - - log_info "Setting up .ssh/known_hosts..." - # - # https://sourceforge.net/p/forge/documentation/SSH%20Key%20Fingerprints/ - # - # run locally: - # ssh-keyscan web.sourceforge.net | tee -a known_hosts - # - # verify fingerprints: - # ssh-keygen -F web.sourceforge.net -l -f known_hosts - # # Host web.sourceforge.net found: line 1 - # web.sourceforge.net RSA SHA256:xB2rnn0NUjZ/E0IXQp4gyPqc7U7gjcw7G26RhkDyk90 - # # Host web.sourceforge.net found: line 2 - # web.sourceforge.net ECDSA SHA256:QAAxYkf0iI/tc9oGa0xSsVOAzJBZstcO8HqGKfjpxcY - # # Host web.sourceforge.net found: line 3 - # web.sourceforge.net ED25519 SHA256:209BDmH3jsRyO9UeGPPgLWPSegKmYCBIya0nR/AWWCY - # - # then add output of `ssh-keygen -F web.sourceforge.net -f known_hosts` - # - echo 'web.sourceforge.net ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2uifHZbNexw6cXbyg1JnzDitL5VhYs0E65Hk/tLAPmcmm5GuiGeUoI/B0eUSNFsbqzwgwrttjnzKMKiGLN5CWVmlN1IXGGAfLYsQwK6wAu7kYFzkqP4jcwc5Jr9UPRpJdYIK733tSEmzab4qc5Oq8izKQKIaxXNe7FgmL15HjSpatFt9w/ot/CHS78FUAr3j3RwekHCm/jhPeqhlMAgC+jUgNJbFt3DlhDaRMa0NYamVzmX8D47rtmBbEDU3ld6AezWBPUR5Lh7ODOwlfVI58NAf/aYNlmvl2TZiauBCTa7OPYSyXJnIPbQXg6YQlDknNCr0K769EjeIlAfY87Z4tw==' >> "$HOME/.ssh/known_hosts" - echo 'web.sourceforge.net ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCwsY6sZT4MTTkHfpRzYjxG7mnXrGL74RCT2cO/NFvRrZVNB5XNwKNn7G5fHbYLdJ6UzpURDRae1eMg92JG0+yo=' >> "$HOME/.ssh/known_hosts" - echo 'web.sourceforge.net ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOQD35Ujalhh+JJkPvMckDlhu4dS7WH6NsOJ15iGCJLC' >> "$HOME/.ssh/known_hosts" - - # add pmd-code.org (ssh-keyscan pmd-code.org) - echo 'pmd-code.org ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVsIeF6xU0oPb/bMbxG1nU1NDyBpR/cBEPZcm/PuJwdI9B0ydPHA6FysqAnt32fNFznC2SWisnWyY3iNsP3pa8RQJVwmnnv9OboGFlW2/61o3iRyydcpPbgl+ADdt8iU9fmMI7dC04UqgHGBoqOwVNna9VylTjp5709cK2qHnwU450F6YcOEiOKeZfJvV4PmpJCz/JcsUVqft6StviR31jKnqbnkZdP8qNoTbds6WmGKyXkhHdLSZE7X1CFQH28tk8XFqditX93ezeCiThFL7EleDexV/3+2+cs5878sDMUMzHS5KShTjkxzhHaodhtIEdNesinq/hOPbxAGkQ0FbD' >> $HOME/.ssh/known_hosts -} diff --git a/.ci/inc/sourceforge-api.inc b/.ci/inc/sourceforge-api.inc deleted file mode 100644 index 24f165cf6f..0000000000 --- a/.ci/inc/sourceforge-api.inc +++ /dev/null @@ -1,166 +0,0 @@ -# -# The functions here require the following scripts: -# logger.inc -# -# The functions here require the following environment variables: -# PMD_SF_USER -# PMD_SF_APIKEY -# - -# -# Uploads the release notes to sourceforge files as "ReadMe.md". -# -# Note: this function always succeeds, even if the upload fails. -# In that case, just a error logging is provided. -# -function sourceforge_uploadReleaseNotes() { - local pmdVersion="$1" - local releaseNotes="$2" - - log_debug "$FUNCNAME pmdVersion=$pmdVersion" - local targetUrl="https://sourceforge.net/projects/pmd/files/pmd/${pmdVersion}" - - local errexitstate="$(shopt -po errexit)" - set +e # disable errexit - ( - # This handler is called if any command fails - function release_notes_fail() { - log_error "Error while uploading release notes as ReadMe.md to sourceforge!" - log_error "Please upload manually: ${targetUrl}" - cleanup_temp_dir - } - - function cleanup_temp_dir() { - log_debug "Cleanup tempdir $releaseNotesTempDir" - rm "${releaseNotesTempDir}/${pmdVersion}/ReadMe.md" || true - rmdir "${releaseNotesTempDir}/${pmdVersion}" || true - rmdir "${releaseNotesTempDir}" || true - } - - # exit subshell after trap - set -e - trap release_notes_fail ERR - - local releaseNotesTempDir=$(mktemp -d) - log_debug "Tempdir: $releaseNotesTempDir" - mkdir -p "${releaseNotesTempDir}/${pmdVersion}" - echo "$releaseNotes" > "${releaseNotesTempDir}/${pmdVersion}/ReadMe.md" - - log_info "Uploading release notes to sourceforge for version $pmdVersion" - rsync -avz \ - "${releaseNotesTempDir}/" \ - "${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/" - - log_success "Successfully uploaded release notes as ReadMe.md to sourceforge: ${targetUrl}" - - cleanup_temp_dir - ) - # restore errexit state - eval "$errexitstate" -} - -# -# Uploads the given file to sourceforge. -# -# Note: This function always succeeds, even if the upload fails. -# In that case, just a error logging is provided. -# -function sourceforge_uploadFile() { - local pmdVersion="$1" - local filename="$2" - - log_debug "$FUNCNAME pmdVersion=$pmdVersion filename=$filename" - local targetUrl="https://sourceforge.net/projects/pmd/files/pmd/${pmdVersion}" - - local errexitstate="$(shopt -po errexit)" - set +e # disable errexit - ( - # This handler is called if any command fails - function upload_failed() { - log_error "Error while uploading ${filename} to sourceforge!" - log_error "Please upload manually: ${targetUrl}" - } - - # exit subshell after trap - set -e - trap upload_failed ERR - - log_info "Uploading $filename to sourceforge..." - .ci/travis_wait "rsync -avh ${filename} ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${pmdVersion}/" - log_success "Successfully uploaded ${filename} to sourceforge: ${targetUrl}" - ) - # restore errexit state - eval "$errexitstate" -} - -# -# Select the given version as the new default download. -# -# Note: This function always succeeds, even if the request fails. -# In that case, just a error logging is provided. -# -function sourceforge_selectDefault() { - local pmdVersion="$1" - - log_debug "$FUNCNAME pmdVersion=$pmdVersion" - local targetUrl="https://sourceforge.net/projects/pmd/files/pmd/${pmdVersion}" - - local errexitstate="$(shopt -po errexit)" - set +e # disable errexit - ( - # This handler is called if any command fails - function request_failed() { - log_error "Error while selecting ${pmdVersion} as new default download on sourceforge!" - log_error "Please do it manually: ${targetUrl}" - } - - # exit subshell after trap - set -e - trap request_failed ERR - - log_info "Selecting $pmdVersion as new default on sourceforge..." - local response - response=$(curl --fail -s -H "Accept: application/json" \ - -X PUT \ - -d "api_key=${PMD_SF_APIKEY}" \ - -d "default=windows&default=mac&default=linux&default=bsd&default=solaris&default=others" \ - "https://sourceforge.net/projects/pmd/files/pmd/${pmdVersion}/pmd-bin-${pmdVersion}.zip") - log_debug " -> response: $response" - log_success "Successfully selected $pmdVersion as new default on sourceforge: ${targetUrl}" - ) - # restore errexit state - eval "$errexitstate" -} - -# -# Rsyncs the complete documentation to sourceforge. -# -# Note: This function always succeeds, even if the upload fails. -# In that case, just a error logging is provided. -# -function sourceforge_rsyncSnapshotDocumentation() { - local pmdVersion="$1" - local targetPath="$2" - - log_debug "$FUNCNAME pmdVersion=$pmdVersion targetPath=$targetPath" - local targetUrl="https://pmd.sourceforge.io/${targetPath}/" - - local errexitstate="$(shopt -po errexit)" - set +e # disable errexit - ( - # This handler is called if any command fails - function upload_failed() { - log_error "Couldn't upload the documentation. It won't be current on ${targetUrl}" - } - - # exit subshell after trap - set -e - trap upload_failed ERR - - log_info "Uploading documentation to ${targetUrl}..." - .ci/travis_wait "rsync -ah --stats --delete docs/pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/" - log_success "Successfully uploaded documentation: ${targetUrl}" - ) - # restore errexit state - eval "$errexitstate" -} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..33a35ec101 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,55 @@ +name: build + +on: + push: + branches: + - main + - master + tags: + - '**' + pull_request: + schedule: + # build it monthly: At 04:00 on day-of-month 1. + - cron: '0 4 1 * *' + +jobs: + build: + runs-on: ${{ matrix.os }} + continue-on-error: false + strategy: + matrix: + os: [ ubuntu-latest, windows-latest, macos-latest ] + if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: | + ~/.m2/repository + ~/.cache + key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}- + - name: Set up Ruby 2.7 + uses: actions/setup-ruby@v1 + with: + ruby-version: 2.7 + - name: Setup Environment + shell: bash + run: | + echo "LANG=en_US.UTF-8" >> $GITHUB_ENV + echo "MAVEN_OPTS=-Dmaven.wagon.httpconnectionManager.ttlSeconds=180 -Dmaven.wagon.http.retryHandler.count=3" >> $GITHUB_ENV + echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/master/scripts" >> $GITHUB_ENV + - name: Check Environment + shell: bash + run: | + f=check-environment.sh; \ + mkdir -p .ci && \ + ( [ -e .ci/$f ] || curl -sSL "${PMD_CI_SCRIPTS_URL}/$f" > ".ci/$f" ) && \ + chmod 755 .ci/$f && \ + .ci/$f + - name: Build + run: .ci/build.sh + shell: bash + env: + PMD_CI_SECRET_PASSPHRASE: ${{ secrets.PMD_CI_SECRET_PASSPHRASE }}