Skip to content

Commit

Permalink
Merge pull request #989 from jenkinsci/quality-monitor
Browse files Browse the repository at this point in the history
Use new quality monitor action in workflows
  • Loading branch information
uhafner authored Dec 20, 2023
2 parents 8cea518 + aa9f946 commit 0cc7eb7
Show file tree
Hide file tree
Showing 3 changed files with 198 additions and 55 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 'Generate Codecov coverage report'

on:
push:
branches:
- master
- main
pull_request:

jobs:
coverage:

runs-on: ubuntu-latest
name: Create coverage report and upload results to Codecov on Ubuntu

steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
check-latest: true
cache: 'maven'
- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
with:
maven-version: 3.9.5
- name: Build with Maven
run: mvn -V --color always -ntp clean verify
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: 'target/site/jacoco/jacoco.xml'
token: ${{secrets.CODECOV_TOKEN}}
102 changes: 102 additions & 0 deletions .github/workflows/quality-monitor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: 'Quality Monitor PR'

on:
pull_request:

jobs:
build:

runs-on: [ubuntu-latest]
name: Build, test and monitor quality on Ubuntu

steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
check-latest: true
cache: 'maven'
- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
with:
maven-version: 3.9.5
- name: Build with Maven
env:
BROWSER: chrome-container
run: mvn -V --color always -ntp clean verify | tee maven.log
- name: Extract pull request number
uses: jwalton/gh-find-current-pr@v1
id: pr
- name: Run Quality Monitor
uses: uhafner/quality-monitor@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
pr-number: ${{ steps.pr.outputs.number }}
config: >
{
"tests": {
"tools": [
{
"id": "test",
"name": "Tests",
"pattern": "**/target/*-reports/TEST*.xml"
}
],
"name": "Tests"
},
"analysis": [
{
"name": "Style",
"id": "style",
"tools": [
{
"id": "checkstyle",
"name": "CheckStyle",
"pattern": "**/target/checkstyle-result.xml"
},
{
"id": "pmd",
"name": "PMD",
"pattern": "**/target/pmd.xml"
}
]
},
{
"name": "Bugs",
"id": "bugs",
"icon": "bug",
"tools": [
{
"id": "spotbugs",
"name": "SpotBugs",
"sourcePath": "src/main/java",
"pattern": "**/target/spotbugsXml.xml"
}
]
}
],
"coverage": [
{
"name": "Code Coverage",
"tools": [
{
"id": "jacoco",
"name": "Line Coverage",
"metric": "line",
"sourcePath": "src/main/java",
"pattern": "**/target/site/jacoco/jacoco.xml"
},
{
"id": "jacoco",
"name": "Branch Coverage",
"metric": "branch",
"sourcePath": "src/main/java",
"pattern": "**/target/site/jacoco/jacoco.xml"
}
]
}
]
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Generate reports'
name: 'Update project badges'

on:
push:
Expand All @@ -9,7 +9,7 @@ jobs:
coverage:

runs-on: [ubuntu-latest]
name: Reporting on Ubuntu
name: Update project quality badges on Ubuntu

steps:
- uses: actions/checkout@v4
Expand All @@ -25,31 +25,27 @@ jobs:
with:
maven-version: 3.9.5
- name: Build and test with Maven
run: mvn -V --color always -ntp clean verify --file pom.xml '-Dgpg.skip' '-Ppit' | tee maven.log
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3.1.4
with:
token: ${{secrets.CODECOV_TOKEN}}
- name: Run Autograding
uses: uhafner/autograding-github-action@v3
run: mvn -V --color always -ntp clean verify --file pom.xml '-Dgpg.skip' | tee maven.log
- name: Run Quality Monitor
uses: uhafner/quality-monitor@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
checks-name: 'Quality Checks'
config: >
{
"tests": {
"tools": [
{
"id": "test",
"name": "Unittests",
"pattern": "**/target/*-reports/TEST*.xml"
}
],
"name": "Tests"
},
"analysis": {
"name": "Warnings",
"id": "warnings",
"tests": {
"tools": [
{
"id": "test",
"name": "Tests",
"pattern": "**/target/*-reports/TEST*.xml"
}
],
"name": "Tests"
},
"analysis": [
{
"name": "Style",
"id": "style",
"tools": [
{
"id": "checkstyle",
Expand All @@ -60,42 +56,45 @@ jobs:
"id": "pmd",
"name": "PMD",
"pattern": "**/target/pmd.xml"
},
{
"id": "error-prone",
"name": "Error Prone",
"pattern": "**/maven.log"
},
}
]
},
{
"name": "Bugs",
"id": "bugs",
"icon": "bug",
"tools": [
{
"id": "spotbugs",
"name": "SpotBugs",
"sourcePath": "src/main/java",
"pattern": "**/target/spotbugsXml.xml"
}
]
},
"coverage": [
{
"tools": [
{
"id": "jacoco",
"name": "Line Coverage",
"metric": "line",
"sourcePath": "src/main/java",
"pattern": "**/target/site/jacoco/jacoco.xml"
},
{
"id": "jacoco",
"name": "Branch Coverage",
"metric": "branch",
"sourcePath": "src/main/java",
"pattern": "**/target/site/jacoco/jacoco.xml"
}
],
"name": "Code Coverage"
}
]
}
}
],
"coverage": [
{
"name": "Code Coverage",
"tools": [
{
"id": "jacoco",
"name": "Line Coverage",
"metric": "line",
"sourcePath": "src/main/java",
"pattern": "**/target/site/jacoco/jacoco.xml"
},
{
"id": "jacoco",
"name": "Branch Coverage",
"metric": "branch",
"sourcePath": "src/main/java",
"pattern": "**/target/site/jacoco/jacoco.xml"
}
]
}
]
}
- name: Write metrics to GitHub output
id: metrics
run: |
Expand All @@ -115,13 +114,20 @@ jobs:
status: ${{ steps.metrics.outputs.branch }}%
color: 'green'
path: badges/branch-coverage.svg
- name: Generate the badge SVG image for the warnings
- name: Generate the badge SVG image for the style warnings
uses: emibcn/badge-action@v2.0.2
with:
label: 'Warnings'
status: ${{ steps.metrics.outputs.warnings }}
status: ${{ steps.metrics.outputs.style }}
color: 'orange'
path: badges/style.svg
- name: Generate the badge SVG image for the style warnings
uses: emibcn/badge-action@v2.0.2
with:
label: 'Bugs'
status: ${{ steps.metrics.outputs.bugs }}
color: 'orange'
path: badges/warnings.svg
path: badges/bugs.svg
- name: Commit updated badges
continue-on-error: true
run: |
Expand Down

0 comments on commit 0cc7eb7

Please sign in to comment.