Android Killer
Android Killer

Reputation: 18509

How to upload kover report into circle ci "Test" tab (dashboard)

We have one kotlin multiplatfor project and we are using kover tool for generating test coverage report and we are using circleci pipeline. So I have the config.yml file as shown below:

code_coverage:
    <<: *build_config
    steps:
      - checkout
      - *restore_gradle_cache
      - run:
          name: code coverage
          command: ./gradlew koverReport
      - run:
          name: Save test results
          command: |
            mkdir -p ~/test-results/junit/
            find . -type f -regex ".*/build/reports/kover/xml/*.xml" -exec cp {} ~/test-results/junit/ \;
            when: always
      - store_test_results:
          path: ~/test-results
      - *save_gradle_cache
      - store_artifacts:
          path: shared/build/reports/kover/html
      - run:
          name: code coverage minimum value
          command: ./gradlew koverVerify

while saving the test result:

#!/bin/bash -eo pipefail mkdir -p ~/test-results/junit/ find . -type f -regex ".*/build/reports/kover/xml/report.xml" -exec cp {} ~/test-results/junit/ ; when: always /bin/bash: line 2: when:: command not found

Exited with code exit status 127

And while uploading test result: I am getting following error in CI:

Archiving the following test results * /home/circleci/test-results/junit/report.xml

failed uploading test results: File: home/circleci/test-results/junit/report.xml had the following problems: * invalid top level element: typeIN

The image is shown below: enter image description here

What could be the reason, please do help

Upvotes: 0

Views: 274

Answers (1)

mhugh
mhugh

Reputation: 31

There's a problem with the indentation on the when key, since it's at the same indentation as what's under the command block bash will try to run:

mkdir -p ~/test-results/junit/
find . -type f -regex ".*/build/reports/kover/xml/*.xml" -exec cp {} ~/test-results/junit/ \;
when: always

and fail on the last line, you should be able to fix it be outdenting that line:

@@ -9,7 +9,7 @@ code_coverage:
           command: |
             mkdir -p ~/test-results/junit/
             find . -type f -regex ".*/build/reports/kover/xml/*.xml" -exec cp {} ~/test-results/junit/ \;
-            when: always
+          when: always
       - store_test_results:
           path: ~/test-results
       - store_artifacts:

Upvotes: 0

Related Questions