kube-score
kube-score copied to clipboard
Feature request: Support JUnit XML output format
I've experimented a bit with this tool on some YAML files at work. The output format is currently limited to human
(which is neat for just finding and fixing potential issues) and ci
(just one line per test). It'd be nice to support also junit. This format allows to see the results more clearly for each of the tests. JUnit is supported also by GitLab, and on other platforms (GitHub), and despite the misleading name, it appears to be a more universal format.
https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-test-results?view=azure-devops&tabs=trx%2Cyaml https://docs.gitlab.com/ee/ci/unit_test_reports.html https://support.atlassian.com/bitbucket-cloud/docs/test-reporting-in-pipelines/
Good idea! Do you want to work on it, or should I mark this issue as up-for-grabs?
I can give it a go, but will probably reach out for assistance once I have something ready for a PR.
There is a tool already available one could leverage -- https://github.com/jstemmer/go-junit-report. I did the following in my local env --
$ go get github.com/jstemmer/go-junit-report
$ go install github.com/jstemmer/go-junit-report
$ go test -v $(pwd)/cmd/kube-score | go-junit-report > report.html
$ cat report.html
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite tests="2" failures="0" time="0.000" name="github.com/zegl/kube-score/cmd/kube-score">
<properties>
<property name="go.version" value="go1.18.1"></property>
</properties>
<testcase classname="kube-score" name="TestParseCli" time="0.000"></testcase>
<testcase classname="kube-score" name="TestExecName" time="0.000"></testcase>
</testsuite>
</testsuites>
@zegl can you assign this issues to me? I will try to upload a pr within the next week.
@kaluzaaa any progress on the PR. I think this is a useful feature to integrate with gitlab CI
@zegl please lmk if this is up for grabs, or if not what's the timeline
@wscourge I don't think that anyone is working on this at the moment. Feel free to work on it, and send a PR. :-)
example in gitlab ci
kube-score-junit:
stage: test
when: always
needs:
- kube-score
image:
name: node
before_script:
- npm install -g sarif-junit@latest
script:
- sarif-junit -i result.json -o result.xml
artifacts:
reports:
junit: "result.xml"
kube-score:
stage: test
# allow_failure: true
image:
name: zegl/kube-score
entrypoint: [""]
script:
- $(/kube-score score *.yaml -v -o sarif > result.json) || true
- /kube-score score *.yaml
artifacts:
when: always
paths:
- result.json