diff --git a/.ci/README.md b/.ci/README.md index 181823afce..3c5bc286b0 100644 --- a/.ci/README.md +++ b/.ci/README.md @@ -18,6 +18,8 @@ for a ssh key, which is used to copy files to sourceforge. * PMD_SF_APIKEY * GITHUB_OAUTH_TOKEN * GITHUB_BASE_URL +* COVERALLS_REPO_TOKEN +* SONAR_TOKEN * DANGER_GITHUB_API_TOKEN * PMD_CI_CHUNK_TOKEN diff --git a/.ci/build-coveralls.sh b/.ci/build-coveralls.sh new file mode 100755 index 0000000000..89a0743fb2 --- /dev/null +++ b/.ci/build-coveralls.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +source $(dirname $0)/inc/logger.inc +source $(dirname $0)/inc/setup-secrets.inc +source $(dirname $0)/inc/install-openjdk.inc +source $(dirname $0)/inc/maven-dependencies.inc + +set -e + +log_group_start "Setup private env and OpenJDK" + pmd_ci_setup_private_env + install_openjdk_setdefault 11 + export CI_NAME="github actions" + export CI_BUILD_URL="${PMD_CI_JOB_URL}" + export CI_BRANCH="${PMD_CI_GIT_REF##refs/heads/}" +log_group_end + +log_group_start "Downloading maven dependencies" + maven_dependencies_resolve +log_group_end + +log_group_start "Executing build with coveralls" + ./mvnw \ + -Dmaven.javadoc.skip=true \ + -Dmaven.source.skip \ + -Dcheckstyle.skip \ + -DrepoToken=${COVERALLS_REPO_TOKEN} \ + -B -V -e \ + clean package jacoco:report \ + coveralls:report -Pcoveralls + + if [ $? -ne 0 ]; then + log_error "Error creating coveralls report" + else + log_success "New coveralls result: https://coveralls.io/github/pmd/pmd" + fi +log_group_end diff --git a/.ci/build-sonar.sh b/.ci/build-sonar.sh new file mode 100755 index 0000000000..461fd317a0 --- /dev/null +++ b/.ci/build-sonar.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +source $(dirname $0)/inc/logger.inc +source $(dirname $0)/inc/setup-secrets.inc +source $(dirname $0)/inc/install-openjdk.inc +source $(dirname $0)/inc/maven-dependencies.inc + +set -e + +log_group_start "Setup private env and OpenJDK" + pmd_ci_setup_private_env + install_openjdk_setdefault 11 +log_group_end + +log_group_start "Downloading maven dependencies" + maven_dependencies_resolve +log_group_end + +log_group_start "Executing build with sonar" + ./mvnw \ + -Dmaven.javadoc.skip=true \ + -Dmaven.source.skip \ + -Dcheckstyle.skip \ + -B -V -e \ + clean package \ + sonar:sonar -Dsonar.login=${SONAR_TOKEN} -Psonar + + if [ $? -ne 0 ]; then + log_error "Error updating sonar..." + else + log_success "New sonar results: https://sonarcloud.io/dashboard?id=net.sourceforge.pmd%3Apmd" + fi +log_group_end diff --git a/.ci/files/private-env.gpg b/.ci/files/private-env.gpg index d379ecefe2..af292ee8b5 100644 Binary files a/.ci/files/private-env.gpg and b/.ci/files/private-env.gpg differ diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index bfa9e6eea3..f9b93f1106 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -7,7 +7,6 @@ jobs: runs-on: ${{ matrix.os }} continue-on-error: false timeout-minutes: 30 - if: "!contains(github.event.head_commit.message, '[skip ci]')" strategy: matrix: os: [ ubuntu-latest, windows-latest, macos-latest ] diff --git a/.github/workflows/pushes.yml b/.github/workflows/pushes.yml index df2c2d3849..5f0c3c8237 100644 --- a/.github/workflows/pushes.yml +++ b/.github/workflows/pushes.yml @@ -11,6 +11,8 @@ on: jobs: linux: runs-on: ubuntu-latest + continue-on-error: false + if: "!contains(github.event.head_commit.message, '[skip ci]')" steps: - uses: actions/checkout@v2 - uses: actions/cache@v2 @@ -40,6 +42,7 @@ jobs: windows: runs-on: windows-latest + needs: linux steps: - uses: actions/checkout@v2 - uses: actions/cache@v2 @@ -50,16 +53,19 @@ jobs: key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}- - - name: Install OpenJDK - run: .ci/install-openjdk.sh + - name: Check Environment + run: .ci/check-environment.sh shell: bash - name: Build with mvnw run: | - source ${HOME}/java.env - ./mvnw -V clean install + source .ci/inc/install-openjdk.inc + install_openjdk_setdefault 11 + ./mvnw -V clean verify + shell: bash macos: runs-on: macos-latest + needs: linux steps: - uses: actions/checkout@v2 - uses: actions/cache@v2 @@ -70,10 +76,59 @@ jobs: key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}- - - name: Install OpenJDK - run: .ci/install-openjdk.sh + - name: Check Environment + run: .ci/check-environment.sh shell: bash - name: Build with mvnw run: | - source ${HOME}/java.env - ./mvnw -V clean install + source .ci/inc/install-openjdk.inc + install_openjdk_setdefault 11 + ./mvnw -V clean verify + shell: bash + + coveralls: + runs-on: ubuntu-latest + needs: [linux, windows, macos] + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: | + ~/.m2/repository + ~/.cache + key: ${{ runner.os }}-coveralls-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-coveralls- + - name: Check Environment + run: .ci/check-environment.sh + shell: bash + - name: Build + run: .ci/build-coveralls.sh + shell: bash + env: + MAVEN_OPTS: -Dmaven.wagon.httpconnectionManager.ttlSeconds=180 -Dmaven.wagon.http.retryHandler.count=3 + PMD_CI_SECRET_PASSPHRASE: ${{ secrets.PMD_CI_SECRET_PASSPHRASE }} + PMD_CI_JOB_URL: "https://github.com/pmd/pmd/runs/${{ github.run_id }}" + + sonar: + runs-on: ubuntu-latest + needs: [linux, windows, macos] + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: | + ~/.m2/repository + ~/.cache + key: ${{ runner.os }}-sonar-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-sonar- + - name: Check Environment + run: .ci/check-environment.sh + shell: bash + - name: Build + run: .ci/build-sonar.sh + shell: bash + env: + MAVEN_OPTS: -Dmaven.wagon.httpconnectionManager.ttlSeconds=180 -Dmaven.wagon.http.retryHandler.count=3 + PMD_CI_SECRET_PASSPHRASE: ${{ secrets.PMD_CI_SECRET_PASSPHRASE }} diff --git a/pom.xml b/pom.xml index 2312e8579f..9516b42d59 100644 --- a/pom.xml +++ b/pom.xml @@ -1028,6 +1028,7 @@ https://sonarcloud.io pmd + 1.8