Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/metrics-report
Browse files Browse the repository at this point in the history
# Conflicts:
#	plugin/pom.xml
#	plugin/src/main/java/io/jenkins/plugins/coverage/metrics/color/ColorProvider.java
#	plugin/src/main/java/io/jenkins/plugins/coverage/metrics/color/ColorProviderFactory.java
#	plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageRecorder.java
#	plugin/src/test/java/io/jenkins/plugins/coverage/metrics/AbstractModifiedFilesCoverageTest.java
  • Loading branch information
uhafner committed Feb 17, 2025
2 parents f308856 + 4ed1765 commit df77c07
Show file tree
Hide file tree
Showing 14 changed files with 194 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/check-md-links.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
}
}
],
"aliveStatusCodes": [200, 500, 503]
"aliveStatusCodes": [200, 500, 503, 429]
}
11 changes: 8 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- main
pull_request:
pull_request_target:

jobs:
build:
Expand All @@ -19,6 +19,11 @@ jobs:

steps:
- uses: actions/checkout@v4
if: github.event_name == 'push'
- uses: actions/checkout@v4
with:
ref: "${{ github.event.pull_request.merge_commit_sha }}"
if: github.event_name == 'pull_request_target'
- name: Set up JDK ${{ matrix.jdk }}
uses: actions/setup-java@v4
with:
Expand All @@ -29,8 +34,8 @@ jobs:
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.6
maven-version: 3.9.9
- name: Build with Maven
env:
BROWSER: chrome-container
run: mvn -V --color always -ntp clean verify '-Djenkins.test.timeout=5000' '-Dgpg.skip'
run: mvn -V --color always -ntp clean verify '-Djenkins.test.timeout=5000' '-Dgpg.skip' -Pno-ui-tests
16 changes: 8 additions & 8 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ name: "CodeQL"
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
pull_request_target:
schedule:
- cron: "32 3 * * 0"

Expand All @@ -27,8 +23,12 @@ jobs:
language: [ java ]

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
if: github.event_name == 'push'
- uses: actions/checkout@v4
with:
ref: "${{ github.event.pull_request.merge_commit_sha }}"
if: github.event_name == 'pull_request_target'

- name: Setup Java
uses: actions/setup-java@v4
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.6
maven-version: 3.9.9

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- main
pull_request:
pull_request_target:

jobs:
coverage:
Expand All @@ -14,6 +14,11 @@ jobs:

steps:
- uses: actions/checkout@v4
if: github.event_name == 'push'
- uses: actions/checkout@v4
with:
ref: "${{ github.event.pull_request.merge_commit_sha }}"
if: github.event_name == 'pull_request_target'
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
Expand All @@ -24,11 +29,12 @@ jobs:
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.6
maven-version: 3.9.9
- name: Generate coverage with JaCoCo
run: mvn -V --color always -ntp clean verify -Pci
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.5.0
uses: codecov/codecov-action@v5.1.2
with:
files: 'target/site/jacoco/jacoco.xml'
file: 'plugin/target/site/jacoco/jacoco.xml'
disable_search: true
token: ${{secrets.CODECOV_TOKEN}}
2 changes: 1 addition & 1 deletion .github/workflows/enforce-labels.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Label Checker
on:
pull_request:
pull_request_target:
types: [opened, labeled, unlabeled, synchronize]
jobs:
enforce-labels:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pit-update-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
java-version: '21'
check-latest: true
- name: Download artifact
uses: dawidd6/action-download-artifact@v6
uses: dawidd6/action-download-artifact@v7
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: pitest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.6
maven-version: 3.9.9
- name: Generate coverage with JaCoCo
run: mvn -V --color always -ntp clean verify -Ppit -Pci '-Dfeatures=+GIT(from[HEAD~1]),+gitci'
- name: Aggregate PIT coverage files
Expand Down
136 changes: 135 additions & 1 deletion .github/workflows/quality-monitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.6
maven-version: 3.9.9
- name: Build with Maven
env:
BROWSER: chrome-container
Expand All @@ -36,3 +36,137 @@ jobs:
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",
"pattern": "**/target/**checkstyle-result.xml"
},
{
"id": "pmd",
"pattern": "**/target/pmd-*/pmd.xml"
}
]
},
{
"name": "Bugs",
"id": "bugs",
"icon": "bug",
"tools": [
{
"id": "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"
}
]
}
],
"metrics":
{
"name": "Toplevel Metrics",
"tools": [
{
"name": "Cyclomatic Complexity",
"id": "metrics",
"pattern": "**/metrics/pmd.xml",
"metric": "CYCLOMATIC_COMPLEXITY"
},
{
"name": "Cognitive Complexity",
"id": "metrics",
"pattern": "**/metrics/pmd.xml",
"metric": "COGNITIVE_COMPLEXITY"
},
{
"name": "Lines of Code",
"id": "metrics",
"pattern": "**/metrics/pmd.xml",
"metric": "LOC"
},
{
"name": "Non Commenting Source Statements",
"id": "metrics",
"pattern": "**/metrics/pmd.xml",
"metric": "NCSS"
},
{
"name": "Access to foreign data",
"id": "metrics",
"pattern": "**/metrics/pmd.xml",
"metric": "ACCESS_TO_FOREIGN_DATA"
},
{
"name": "Class cohesion",
"id": "metrics",
"pattern": "**/metrics/pmd.xml",
"metric": "COHESION"
},
{
"name": "Fan out",
"id": "metrics",
"pattern": "**/metrics/pmd.xml",
"metric": "FAN_OUT"
},
{
"name": "Number of accessors",
"id": "metrics",
"pattern": "**/metrics/pmd.xml",
"metric": "NUMBER_OF_ACCESSORS"
},
{
"name": "Weight of a class",
"id": "metrics",
"pattern": "**/metrics/pmd.xml",
"metric": "WEIGHT_OF_CLASS"
},
{
"name": "Weighted method count",
"id": "metrics",
"pattern": "**/metrics/pmd.xml",
"metric": "WEIGHED_METHOD_COUNT"
},
{
"name": "N-Path Complexity",
"id": "metrics",
"pattern": "**/metrics/pmd.xml",
"metric": "NPATH_COMPLEXITY"
}
]
}
}
10 changes: 5 additions & 5 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-pom</artifactId>
<version>10.2.0</version>
<version>10.4.0</version>
<relativePath />
</parent>

Expand All @@ -26,17 +26,17 @@

<!-- Library Dependencies Versions -->
<coverage-model.version>0.53.0</coverage-model.version>
<jsoup.version>1.18.1</jsoup.version>
<jsoup.version>1.18.3</jsoup.version>

<!-- Jenkins Plug-in Dependencies Versions -->
<git-forensics.version>2.2.0</git-forensics.version>
<git-forensics.version>2.2.1</git-forensics.version>

<!-- Test Library Dependencies Versions -->
<xmlunit.version>2.10.0</xmlunit.version>
<testcontainers.version>1.20.1</testcontainers.version>
<testcontainers.version>1.20.4</testcontainers.version>
<job-dsl.version>1.87</job-dsl.version>

<arcmutate.git.version>1.3.2</arcmutate.git.version>
<arcmutate.git.version>2.0.0</arcmutate.git.version>
</properties>

<developers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ public class ColorProvider {
* The color mapping to be used
*/
ColorProvider(final Map<ColorId, DisplayColors> colorMapping) {
availableColors = new EnumMap<>(colorMapping);
if (colorMapping.isEmpty()) {
availableColors = new EnumMap<>(ColorId.class);
}
else {
availableColors = new EnumMap<>(colorMapping);
}
}

/**
Expand All @@ -52,7 +57,7 @@ public static Color blendColors(final Color color1, final Color color2) {
}

/**
* Blends two colors using weights that have to be greater then zero.
* Blends two colors using weights that have to be greater than zero.
*
* @param color1
* The first color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static ColorProvider createColorProvider(final Map<String, String> colors
if (!colors.keySet().equals(CoverageColorJenkinsId.getAll()) || !verifyHexCodes(colors.values())) {
return createDefaultColorProvider();
}
Map<ColorId, DisplayColors> colorMap = new EnumMap<>();
Map<ColorId, DisplayColors> colorMap = new EnumMap<>(ColorId.class);
// TODO: use dynamic text color (not provided yet)
colorMap.put(ColorId.INSUFFICIENT,
createDisplayColor(colors.get(CoverageColorJenkinsId.RED.getJenkinsColorId()), "#ffffff"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,13 @@ private void resolveAbsolutePaths(final Node rootNode, final FilePath workspace,
if (!pathMapping.isEmpty()) {
log.logInfo("Making paths of " + pathMapping.size() + " source code files relative to workspace root...");
var builder = new TreeStringBuilder();
rootNode.getAllFileNodes().stream()
.filter(file -> pathMapping.containsKey(file.getRelativePath()))
.forEach(file -> file.setRelativePath(builder.intern(pathMapping.get(file.getRelativePath()))));
rootNode.getAllFileNodes().forEach(file -> {
String relativePath = file.getRelativePath();
if (pathMapping.containsKey(relativePath)) {
file.setRelativePath(builder.intern(pathMapping.get(relativePath)));
}
});

builder.dedup();
}
}
Expand Down Expand Up @@ -492,7 +496,7 @@ private Map<Parser, List<ModuleNode>> recordCoverageResults(final Run<?, ?> run,

try {
FileVisitorResult<ModuleNode> result = workspace.act(
new CoverageReportScanner(parser, expandedPattern, "UTF-8", isSkipSymbolicLinks(),
new CoverageReportScanner(parser, expandedPattern, "UTF-8", !isSkipSymbolicLinks(),
ignoreErrors()));
log.merge(result.getLog());

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<properties>
<java.version>1.8</java.version>
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<maven-deploy-plugin.version>3.1.2</maven-deploy-plugin.version>
<maven-deploy-plugin.version>3.1.3</maven-deploy-plugin.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
Expand Down
Loading

0 comments on commit df77c07

Please sign in to comment.