Skip to content

Commit df77c07

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/metrics-report
# 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
2 parents f308856 + 4ed1765 commit df77c07

File tree

14 files changed

+194
-40
lines changed

14 files changed

+194
-40
lines changed

.github/check-md-links.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
}
88
}
99
],
10-
"aliveStatusCodes": [200, 500, 503]
10+
"aliveStatusCodes": [200, 500, 503, 429]
1111
}

.github/workflows/ci.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request:
7+
pull_request_target:
88

99
jobs:
1010
build:
@@ -19,6 +19,11 @@ jobs:
1919

2020
steps:
2121
- uses: actions/checkout@v4
22+
if: github.event_name == 'push'
23+
- uses: actions/checkout@v4
24+
with:
25+
ref: "${{ github.event.pull_request.merge_commit_sha }}"
26+
if: github.event_name == 'pull_request_target'
2227
- name: Set up JDK ${{ matrix.jdk }}
2328
uses: actions/setup-java@v4
2429
with:
@@ -29,8 +34,8 @@ jobs:
2934
- name: Set up Maven
3035
uses: stCarolas/setup-maven@v5
3136
with:
32-
maven-version: 3.9.6
37+
maven-version: 3.9.9
3338
- name: Build with Maven
3439
env:
3540
BROWSER: chrome-container
36-
run: mvn -V --color always -ntp clean verify '-Djenkins.test.timeout=5000' '-Dgpg.skip'
41+
run: mvn -V --color always -ntp clean verify '-Djenkins.test.timeout=5000' '-Dgpg.skip' -Pno-ui-tests

.github/workflows/codeql.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ name: "CodeQL"
33
on:
44
push:
55
branches:
6-
- master
7-
- main
8-
pull_request:
9-
branches:
10-
- master
116
- main
7+
pull_request_target:
128
schedule:
139
- cron: "32 3 * * 0"
1410

@@ -27,8 +23,12 @@ jobs:
2723
language: [ java ]
2824

2925
steps:
30-
- name: Checkout
31-
uses: actions/checkout@v4
26+
- uses: actions/checkout@v4
27+
if: github.event_name == 'push'
28+
- uses: actions/checkout@v4
29+
with:
30+
ref: "${{ github.event.pull_request.merge_commit_sha }}"
31+
if: github.event_name == 'pull_request_target'
3232

3333
- name: Setup Java
3434
uses: actions/setup-java@v4
@@ -40,7 +40,7 @@ jobs:
4040
- name: Set up Maven
4141
uses: stCarolas/setup-maven@v5
4242
with:
43-
maven-version: 3.9.6
43+
maven-version: 3.9.9
4444

4545
- name: Initialize CodeQL
4646
uses: github/codeql-action/init@v3

.github/workflows/coverage.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request:
7+
pull_request_target:
88

99
jobs:
1010
coverage:
@@ -14,6 +14,11 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v4
17+
if: github.event_name == 'push'
18+
- uses: actions/checkout@v4
19+
with:
20+
ref: "${{ github.event.pull_request.merge_commit_sha }}"
21+
if: github.event_name == 'pull_request_target'
1722
- name: Set up JDK 21
1823
uses: actions/setup-java@v4
1924
with:
@@ -24,11 +29,12 @@ jobs:
2429
- name: Set up Maven
2530
uses: stCarolas/setup-maven@v5
2631
with:
27-
maven-version: 3.9.6
32+
maven-version: 3.9.9
2833
- name: Generate coverage with JaCoCo
2934
run: mvn -V --color always -ntp clean verify -Pci
3035
- name: Upload coverage to Codecov
31-
uses: codecov/codecov-action@v4.5.0
36+
uses: codecov/codecov-action@v5.1.2
3237
with:
33-
files: 'target/site/jacoco/jacoco.xml'
38+
file: 'plugin/target/site/jacoco/jacoco.xml'
39+
disable_search: true
3440
token: ${{secrets.CODECOV_TOKEN}}

.github/workflows/enforce-labels.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Label Checker
22
on:
3-
pull_request:
3+
pull_request_target:
44
types: [opened, labeled, unlabeled, synchronize]
55
jobs:
66
enforce-labels:

.github/workflows/pit-update-pr.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
java-version: '21'
2222
check-latest: true
2323
- name: Download artifact
24-
uses: dawidd6/action-download-artifact@v6
24+
uses: dawidd6/action-download-artifact@v7
2525
with:
2626
workflow: ${{ github.event.workflow_run.workflow_id }}
2727
name: pitest

.github/workflows/pit.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Set up Maven
2424
uses: stCarolas/setup-maven@v5
2525
with:
26-
maven-version: 3.9.6
26+
maven-version: 3.9.9
2727
- name: Generate coverage with JaCoCo
2828
run: mvn -V --color always -ntp clean verify -Ppit -Pci '-Dfeatures=+GIT(from[HEAD~1]),+gitci'
2929
- name: Aggregate PIT coverage files

.github/workflows/quality-monitor.yml

+135-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Set up Maven
2424
uses: stCarolas/setup-maven@v5
2525
with:
26-
maven-version: 3.9.6
26+
maven-version: 3.9.9
2727
- name: Build with Maven
2828
env:
2929
BROWSER: chrome-container
@@ -36,3 +36,137 @@ jobs:
3636
with:
3737
github-token: ${{ secrets.GITHUB_TOKEN }}
3838
pr-number: ${{ steps.pr.outputs.number }}
39+
config: >
40+
{
41+
"tests": {
42+
"tools": [
43+
{
44+
"id": "test",
45+
"name": "Tests",
46+
"pattern": "**/target/*-reports/TEST*.xml"
47+
}
48+
],
49+
"name": "Tests"
50+
},
51+
"analysis": [
52+
{
53+
"name": "Style",
54+
"id": "style",
55+
"tools": [
56+
{
57+
"id": "checkstyle",
58+
"pattern": "**/target/**checkstyle-result.xml"
59+
},
60+
{
61+
"id": "pmd",
62+
"pattern": "**/target/pmd-*/pmd.xml"
63+
}
64+
]
65+
},
66+
{
67+
"name": "Bugs",
68+
"id": "bugs",
69+
"icon": "bug",
70+
"tools": [
71+
{
72+
"id": "spotbugs",
73+
"sourcePath": "src/main/java",
74+
"pattern": "**/target/spotbugsXml.xml"
75+
}
76+
]
77+
}
78+
],
79+
"coverage": [
80+
{
81+
"name": "Code Coverage",
82+
"tools": [
83+
{
84+
"id": "jacoco",
85+
"name": "Line Coverage",
86+
"metric": "line",
87+
"sourcePath": "src/main/java",
88+
"pattern": "**/target/site/jacoco/jacoco.xml"
89+
},
90+
{
91+
"id": "jacoco",
92+
"name": "Branch Coverage",
93+
"metric": "branch",
94+
"sourcePath": "src/main/java",
95+
"pattern": "**/target/site/jacoco/jacoco.xml"
96+
}
97+
]
98+
}
99+
],
100+
"metrics":
101+
{
102+
"name": "Toplevel Metrics",
103+
"tools": [
104+
{
105+
"name": "Cyclomatic Complexity",
106+
"id": "metrics",
107+
"pattern": "**/metrics/pmd.xml",
108+
"metric": "CYCLOMATIC_COMPLEXITY"
109+
},
110+
{
111+
"name": "Cognitive Complexity",
112+
"id": "metrics",
113+
"pattern": "**/metrics/pmd.xml",
114+
"metric": "COGNITIVE_COMPLEXITY"
115+
},
116+
{
117+
"name": "Lines of Code",
118+
"id": "metrics",
119+
"pattern": "**/metrics/pmd.xml",
120+
"metric": "LOC"
121+
},
122+
{
123+
"name": "Non Commenting Source Statements",
124+
"id": "metrics",
125+
"pattern": "**/metrics/pmd.xml",
126+
"metric": "NCSS"
127+
},
128+
{
129+
"name": "Access to foreign data",
130+
"id": "metrics",
131+
"pattern": "**/metrics/pmd.xml",
132+
"metric": "ACCESS_TO_FOREIGN_DATA"
133+
},
134+
{
135+
"name": "Class cohesion",
136+
"id": "metrics",
137+
"pattern": "**/metrics/pmd.xml",
138+
"metric": "COHESION"
139+
},
140+
{
141+
"name": "Fan out",
142+
"id": "metrics",
143+
"pattern": "**/metrics/pmd.xml",
144+
"metric": "FAN_OUT"
145+
},
146+
{
147+
"name": "Number of accessors",
148+
"id": "metrics",
149+
"pattern": "**/metrics/pmd.xml",
150+
"metric": "NUMBER_OF_ACCESSORS"
151+
},
152+
{
153+
"name": "Weight of a class",
154+
"id": "metrics",
155+
"pattern": "**/metrics/pmd.xml",
156+
"metric": "WEIGHT_OF_CLASS"
157+
},
158+
{
159+
"name": "Weighted method count",
160+
"id": "metrics",
161+
"pattern": "**/metrics/pmd.xml",
162+
"metric": "WEIGHED_METHOD_COUNT"
163+
},
164+
{
165+
"name": "N-Path Complexity",
166+
"id": "metrics",
167+
"pattern": "**/metrics/pmd.xml",
168+
"metric": "NPATH_COMPLEXITY"
169+
}
170+
]
171+
}
172+
}

plugin/pom.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.jvnet.hudson.plugins</groupId>
77
<artifactId>analysis-pom</artifactId>
8-
<version>10.2.0</version>
8+
<version>10.4.0</version>
99
<relativePath />
1010
</parent>
1111

@@ -26,17 +26,17 @@
2626

2727
<!-- Library Dependencies Versions -->
2828
<coverage-model.version>0.53.0</coverage-model.version>
29-
<jsoup.version>1.18.1</jsoup.version>
29+
<jsoup.version>1.18.3</jsoup.version>
3030

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

3434
<!-- Test Library Dependencies Versions -->
3535
<xmlunit.version>2.10.0</xmlunit.version>
36-
<testcontainers.version>1.20.1</testcontainers.version>
36+
<testcontainers.version>1.20.4</testcontainers.version>
3737
<job-dsl.version>1.87</job-dsl.version>
3838

39-
<arcmutate.git.version>1.3.2</arcmutate.git.version>
39+
<arcmutate.git.version>2.0.0</arcmutate.git.version>
4040
</properties>
4141

4242
<developers>

plugin/src/main/java/io/jenkins/plugins/coverage/metrics/color/ColorProvider.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ public class ColorProvider {
3434
* The color mapping to be used
3535
*/
3636
ColorProvider(final Map<ColorId, DisplayColors> colorMapping) {
37-
availableColors = new EnumMap<>(colorMapping);
37+
if (colorMapping.isEmpty()) {
38+
availableColors = new EnumMap<>(ColorId.class);
39+
}
40+
else {
41+
availableColors = new EnumMap<>(colorMapping);
42+
}
3843
}
3944

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

5459
/**
55-
* Blends two colors using weights that have to be greater then zero.
60+
* Blends two colors using weights that have to be greater than zero.
5661
*
5762
* @param color1
5863
* The first color

plugin/src/main/java/io/jenkins/plugins/coverage/metrics/color/ColorProviderFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static ColorProvider createColorProvider(final Map<String, String> colors
4545
if (!colors.keySet().equals(CoverageColorJenkinsId.getAll()) || !verifyHexCodes(colors.values())) {
4646
return createDefaultColorProvider();
4747
}
48-
Map<ColorId, DisplayColors> colorMap = new EnumMap<>();
48+
Map<ColorId, DisplayColors> colorMap = new EnumMap<>(ColorId.class);
4949
// TODO: use dynamic text color (not provided yet)
5050
colorMap.put(ColorId.INSUFFICIENT,
5151
createDisplayColor(colors.get(CoverageColorJenkinsId.RED.getJenkinsColorId()), "#ffffff"));

plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageRecorder.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,13 @@ private void resolveAbsolutePaths(final Node rootNode, final FilePath workspace,
447447
if (!pathMapping.isEmpty()) {
448448
log.logInfo("Making paths of " + pathMapping.size() + " source code files relative to workspace root...");
449449
var builder = new TreeStringBuilder();
450-
rootNode.getAllFileNodes().stream()
451-
.filter(file -> pathMapping.containsKey(file.getRelativePath()))
452-
.forEach(file -> file.setRelativePath(builder.intern(pathMapping.get(file.getRelativePath()))));
450+
rootNode.getAllFileNodes().forEach(file -> {
451+
String relativePath = file.getRelativePath();
452+
if (pathMapping.containsKey(relativePath)) {
453+
file.setRelativePath(builder.intern(pathMapping.get(relativePath)));
454+
}
455+
});
456+
453457
builder.dedup();
454458
}
455459
}
@@ -492,7 +496,7 @@ private Map<Parser, List<ModuleNode>> recordCoverageResults(final Run<?, ?> run,
492496

493497
try {
494498
FileVisitorResult<ModuleNode> result = workspace.act(
495-
new CoverageReportScanner(parser, expandedPattern, "UTF-8", isSkipSymbolicLinks(),
499+
new CoverageReportScanner(parser, expandedPattern, "UTF-8", !isSkipSymbolicLinks(),
496500
ignoreErrors()));
497501
log.merge(result.getLog());
498502

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<properties>
1717
<java.version>1.8</java.version>
1818
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
19-
<maven-deploy-plugin.version>3.1.2</maven-deploy-plugin.version>
19+
<maven-deploy-plugin.version>3.1.3</maven-deploy-plugin.version>
2020
<maven.compiler.source>${java.version}</maven.compiler.source>
2121
<maven.compiler.target>${java.version}</maven.compiler.target>
2222
</properties>

0 commit comments

Comments
 (0)