Add sonar and coveralls jobs

This commit is contained in:
Andreas Dangel 2020-11-14 12:20:11 +01:00
parent e10198402a
commit 4246cb77ca
7 changed files with 136 additions and 9 deletions

View File

@ -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

37
.ci/build-coveralls.sh Executable file
View File

@ -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

33
.ci/build-sonar.sh Executable file
View File

@ -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

Binary file not shown.

View File

@ -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 ]

View File

@ -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 }}

View File

@ -1028,6 +1028,7 @@
<properties>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>pmd</sonar.organization>
<sonar.java.source>1.8</sonar.java.source>
</properties>
<build>
<pluginManagement>