kube-score icon indicating copy to clipboard operation
kube-score copied to clipboard

Feature request: Support JUnit XML output format

Open atombrella opened this issue 2 years ago • 9 comments

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/

atombrella avatar Apr 11 '22 19:04 atombrella

Good idea! Do you want to work on it, or should I mark this issue as up-for-grabs?

zegl avatar Apr 12 '22 08:04 zegl

I can give it a go, but will probably reach out for assistance once I have something ready for a PR.

atombrella avatar Apr 16 '22 07:04 atombrella

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>

kmarteaux avatar Jun 06 '22 20:06 kmarteaux

@zegl can you assign this issues to me? I will try to upload a pr within the next week.

kaluzaaa avatar Aug 07 '22 16:08 kaluzaaa

@kaluzaaa any progress on the PR. I think this is a useful feature to integrate with gitlab CI

baracoder avatar Oct 26 '22 12:10 baracoder

@zegl please lmk if this is up for grabs, or if not what's the timeline

wscourge avatar Dec 21 '22 07:12 wscourge

@wscourge I don't think that anyone is working on this at the moment. Feel free to work on it, and send a PR. :-)

zegl avatar Dec 21 '22 09:12 zegl

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

image

qunabu avatar Feb 28 '24 14:02 qunabu