Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-72970] Allow selecting XUnit in the web interface #118

Merged
merged 18 commits into from
Apr 23, 2024

Conversation

Ririshi
Copy link
Contributor

@Ririshi Ririshi commented Apr 5, 2024

This adds Parser.XUNIT to the doFillParserItems() method to make it show up (I think) as an option in the web interface with freestyle projects. I've created an issue on JIRA: https://issues.jenkins.io/browse/JENKINS-72970

Doesn't seem to work currently.

I've also found that other places (see below) mentioning Parser.JUNIT but not Parser.NUNIT or Parser.XUNIT. Should those also be included because all of them are test results and not regular code coverage?

private String getIcon() {
var icons = tools.stream()
.map(CoverageTool::getParser)
.filter(parser -> parser != Parser.JUNIT)
.map(Parser::getIcon)
.collect(Collectors.toSet());
if (icons.size() == 1) {
return icons.iterator().next(); // unique icon
}
return ICON;
}

private List<ModuleNode> extractTests(final Map<Parser, List<ModuleNode>> results) {
if (results.containsKey(Parser.JUNIT)) {
return results.remove(Parser.JUNIT);
}
else {
return List.of();
}
}

Testing done

Automated test only

Submitter checklist

Copy link

github-actions bot commented Apr 5, 2024

  • Surviving mutants in this change: 1
  • Killed mutants in this change: 0
class surviving killed
io.jenkins.plugins.coverage.metrics.steps.CoverageTool$CoverageToolDescriptor 1 0

See https://pitest.org/

@@ -152,6 +152,7 @@ public ListBoxModel doFillParserItems() {
add(options, Parser.PIT);
add(options, Parser.JUNIT);
add(options, Parser.NUNIT);
add(options, Parser.XUNIT);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, in the selection list of the available parsers it would make sense to show all parsers. Can you replace that with a lop (stream) of Parser.values(), then this will not happen again?

@uhafner uhafner added the bug Bugs or performance problems label Apr 10, 2024
@uhafner
Copy link
Member

uhafner commented Apr 10, 2024

Thanks for your PR!

Actually the other testing parsers are not really integrated and tested right now. It was a prototype for JUnit and Java coverage tools to map test cases to coverage information.

So in particular:

private List<ModuleNode> extractTests(final Map<Parser, List<ModuleNode>> results) {
if (results.containsKey(Parser.JUNIT)) {
return results.remove(Parser.JUNIT);
}
else {
return List.of();
}
}

For this to work the enum should be extended: we should distinguish between tests and coverage results. Then we do not need to check for the exact enum value. Maybe a boolean enum (TEST, COVERAGE) as property?

private String getIcon() {
var icons = tools.stream()
.map(CoverageTool::getParser)
.filter(parser -> parser != Parser.JUNIT)
.map(Parser::getIcon)
.collect(Collectors.toSet());
if (icons.size() == 1) {
return icons.iterator().next(); // unique icon
}
return ICON;
}

I think here the same boolean property in the enum could work. In practice the idea was to have a step that collets coverage and tests and shows the results below the coverage-icon. So the tests are ignored for the icon.

But in theory, one could specify a step with tests only. I'm not sure if it makes sense to take care of that as well.

@Ririshi
Copy link
Contributor Author

Ririshi commented Apr 12, 2024

Thanks for the feedback. I tried to package the plugin locally and try it on my own Jenkins instance, but it seemed like the web UI broke, the post-build options for Coverage plugin were no longer visible in the list. Not sure if I didn't package and install it correctly or if my code change broke something.

Either way, I will add the extra enum property and update the doFillParserItems method to include all options, for now. Perhaps you could (help me) test the plugin after that?

Edit: In the extractTests method, there's an assumption that there is only one test parser. Unless I change the return type to Map<Parser, List<ModuleNode>> it won't be possible to return the ModuleNodes for each parser separately. How should this be tackled? Also, is the PIT parser used for coverage or for tests? I'm confused about that.
I'm mostly uninitiated in the rest of the codebase (or any Jenkins code at all, for that matter), so I'm hoping you can point me in the right direction :)

@Ririshi Ririshi force-pushed the bugfix/xunit-format-missing branch from 7dfe0c4 to 0f8b6c5 Compare April 12, 2024 10:11
@Ririshi
Copy link
Contributor Author

Ririshi commented Apr 12, 2024

Looks like I broke something now. I'm using VSCode and it's not a great IDE the way I have things set up right now. I think the new version of extractTests is returning too many tests now (twice the expected number), so I think there might be some kind of duplication going on in the Parser -> ModuleNodes map. I can't really debug this right now as I have no clue (yet) how to run the plugin in debug mode with my local Jenkins instance.

@Ririshi Ririshi force-pushed the bugfix/xunit-format-missing branch from dec7d64 to 5a6307e Compare April 12, 2024 13:05
Copy link
Member

@uhafner uhafner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my algorithm of test case mapping is broken 🙈

I am mapping test cases to the test cases, this makes no sense. So you get 8 test cases from 4 test cases now. I think I need to fix that part in the model first. Mapped tests should be removed from the tree, otherwise they count twice.

"symbol-footsteps-outline plugin-ionicons-api"),
PIT(Messages._Parser_PIT(), "**/mutations.xml",
PIT(Messages._Parser_PIT(), ParserType.TEST,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PIT(Messages._Parser_PIT(), ParserType.TEST,
PIT(Messages._Parser_PIT(), ParserType.COVERAGE,

Copy link

  • Surviving mutants in this change: 28
  • Killed mutants in this change: 0
class surviving killed
io.jenkins.plugins.coverage.metrics.steps.CoverageRecorder 23 0
io.jenkins.plugins.coverage.metrics.steps.CoverageTool$CoverageToolDescriptor 4 0
io.jenkins.plugins.coverage.metrics.steps.CoverageTool$Parser 1 0

See https://pitest.org/

Copy link

  • Surviving mutants in this change: 23
  • Killed mutants in this change: 0
class surviving killed
io.jenkins.plugins.coverage.metrics.steps.CoverageRecorder 18 0
io.jenkins.plugins.coverage.metrics.steps.CoverageTool$CoverageToolDescriptor 4 0
io.jenkins.plugins.coverage.metrics.steps.CoverageTool$Parser 1 0

See https://pitest.org/

dependabot bot added 12 commits April 23, 2024 11:15
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.1.1 to 4.3.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](codecov/codecov-action@v4.1.1...v4.3.0)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.jenkins-ci.main:jenkins-core](https://github.com/jenkinsci/jenkins) from 2.448 to 2.453.
- [Release notes](https://github.com/jenkinsci/jenkins/releases)
- [Commits](jenkinsci/jenkins@jenkins-2.448...jenkins-2.453)

---
updated-dependencies:
- dependency-name: org.jenkins-ci.main:jenkins-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [io.netty:netty-bom](https://github.com/netty/netty) from 4.1.107.Final to 4.1.108.Final.
- [Commits](netty/netty@netty-4.1.107.Final...netty-4.1.108.Final)

---
updated-dependencies:
- dependency-name: io.netty:netty-bom
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.12.1 to 3.13.0.
- [Release notes](https://github.com/apache/maven-compiler-plugin/releases)
- [Commits](apache/maven-compiler-plugin@maven-compiler-plugin-3.12.1...maven-compiler-plugin-3.13.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-compiler-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.jenkins-ci:acceptance-test-harness](https://github.com/jenkinsci/acceptance-test-harness) from 5770.v81b_784f28b_d7 to 5814.vdc5d6d484b_40.
- [Release notes](https://github.com/jenkinsci/acceptance-test-harness/releases)
- [Commits](https://github.com/jenkinsci/acceptance-test-harness/commits)

---
updated-dependencies:
- dependency-name: org.jenkins-ci:acceptance-test-harness
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [com.fasterxml.jackson.core:jackson-databind](https://github.com/FasterXML/jackson) from 2.16.1 to 2.17.0.
- [Commits](https://github.com/FasterXML/jackson/commits)

---
updated-dependencies:
- dependency-name: com.fasterxml.jackson.core:jackson-databind
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.jenkins-ci.tools:maven-hpi-plugin](https://github.com/jenkinsci/maven-hpi-plugin) from 3.53 to 3.54.
- [Release notes](https://github.com/jenkinsci/maven-hpi-plugin/releases)
- [Commits](jenkinsci/maven-hpi-plugin@maven-hpi-plugin-3.53...maven-hpi-plugin-3.54)

---
updated-dependencies:
- dependency-name: org.jenkins-ci.tools:maven-hpi-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps `arcmutate.git.version` from 1.2.0 to 1.2.1.

Updates `com.arcmutate:pitest-git-maven-plugin` from 1.2.0 to 1.2.1

Updates `com.arcmutate:pitest-github-maven-plugin` from 1.2.0 to 1.2.1

---
updated-dependencies:
- dependency-name: com.arcmutate:pitest-git-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.arcmutate:pitest-github-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [io.jenkins.tools.incrementals:git-changelist-maven-extension](https://github.com/jenkinsci/incrementals-tools) from 1.7 to 1.8.
- [Release notes](https://github.com/jenkinsci/incrementals-tools/releases)
- [Commits](jenkinsci/incrementals-tools@parent-1.7...parent-1.8)

---
updated-dependencies:
- dependency-name: io.jenkins.tools.incrementals:git-changelist-maven-extension
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.jenkins-ci.main:jenkins-core](https://github.com/jenkinsci/jenkins) from 2.453 to 2.454.
- [Release notes](https://github.com/jenkinsci/jenkins/releases)
- [Commits](jenkinsci/jenkins@jenkins-2.453...jenkins-2.454)

---
updated-dependencies:
- dependency-name: org.jenkins-ci.main:jenkins-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [io.netty:netty-bom](https://github.com/netty/netty) from 4.1.108.Final to 4.1.109.Final.
- [Commits](netty/netty@netty-4.1.108.Final...netty-4.1.109.Final)

---
updated-dependencies:
- dependency-name: io.netty:netty-bom
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [edu.hm.hafner:codingstyle-pom](https://github.com/uhafner/codingstyle-pom) from 3.44.0 to 4.5.0.
- [Release notes](https://github.com/uhafner/codingstyle-pom/releases)
- [Changelog](https://github.com/uhafner/codingstyle-pom/blob/main/CHANGELOG.md)
- [Commits](uhafner/codingstyle-pom@v3.44.0...v4.5.0)

---
updated-dependencies:
- dependency-name: edu.hm.hafner:codingstyle-pom
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [io.jenkins.plugins:data-tables-api](https://github.com/jenkinsci/data-tables-api-plugin) from 2.0.1-1 to 2.0.3-1.
- [Release notes](https://github.com/jenkinsci/data-tables-api-plugin/releases)
- [Changelog](https://github.com/jenkinsci/data-tables-api-plugin/blob/main/CHANGELOG.md)
- [Commits](jenkinsci/data-tables-api-plugin@v2.0.1-1...v2.0.3-1)

---
updated-dependencies:
- dependency-name: io.jenkins.plugins:data-tables-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Copy link

  • Surviving mutants in this change: 23
  • Killed mutants in this change: 0
class surviving killed
io.jenkins.plugins.coverage.metrics.steps.CoverageRecorder 18 0
io.jenkins.plugins.coverage.metrics.steps.CoverageTool$CoverageToolDescriptor 4 0
io.jenkins.plugins.coverage.metrics.steps.CoverageTool$Parser 1 0

See https://pitest.org/

@uhafner uhafner marked this pull request as ready for review April 23, 2024 09:38
@uhafner uhafner merged commit f88560a into jenkinsci:main Apr 23, 2024
27 checks passed
@uhafner uhafner changed the title Allow selecting XUnit in the web interface [JENKINS-72970] Allow selecting XUnit in the web interface Apr 23, 2024
@Ririshi
Copy link
Contributor Author

Ririshi commented Apr 23, 2024

Cheers! Thanks for picking this up. I'm going to try it out with xunit output soon when I get a chance.

@@ -25,7 +25,7 @@
<gitHubRepo>jenkinsci/coverage-plugin</gitHubRepo>

<!-- Library Dependencies Versions -->
<coverage-model.version>0.41.0</coverage-model.version>
<coverage-model.version>0.43.0</coverage-model.version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would have been nice to separate the update of the coverage model to an other PR or at least make sure it appear on the release notes

I think it cause some regression on my side when merging JACOCO and COBERTURA reports for a mono-repo application

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally I am inlining the changes of the coverage-model. In this case the upgrade was required for this PR so I forgot to add it here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs or performance problems
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants