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

Feature request: Support JUnit XML output format #459

Open
atombrella opened this issue Apr 11, 2022 · 8 comments
Open

Feature request: Support JUnit XML output format #459

atombrella opened this issue Apr 11, 2022 · 8 comments

Comments

@atombrella
Copy link
Contributor

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/

@zegl
Copy link
Owner

zegl commented Apr 12, 2022

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

@atombrella
Copy link
Contributor Author

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

@kmarteaux
Copy link
Contributor

kmarteaux commented Jun 6, 2022

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>

@kaluzaaa
Copy link

kaluzaaa commented Aug 7, 2022

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

@baracoder
Copy link

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

@wscourge
Copy link

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

@zegl
Copy link
Owner

zegl commented Dec 21, 2022

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

@qunabu
Copy link

qunabu commented Feb 28, 2024

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

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

No branches or pull requests

7 participants