Codecov and xCode Cloud

I have searched for similar issues before creating this topic.
I have verified that my repository is using the Codecov GitHub app, if using GitHub
I have validated my codecov.yaml configuration file.
I have filled out the below sections to the best of my ability.

Description

Hello everyone.
Has anyone managed to set up xCode Cloud to upload coverage reports to Codecov successfully? I’ve managed to configure ci_post_xcodebuild.sh to upload reports, but for some reason they’re empty.

Codecov Output

Run command: 'source /Volumes/Task/ci_build.env && source /Volumes/Task/ci_plan.env && cd /Volumes/workspace/repository/<project-name>/ci_scripts && CI_XCODEBUILD_EXIT_CODE=0 /Volumes/workspace/repository/<project-name>/ci_scripts/ci_post_xcodebuild.sh'
/Volumes/workspace/repository/<project-name>/ci_scripts/ci_post_xcodebuild.sh: line 3: cd: /Volumes/workspace/repository/<project-name>/ci_scripts/resources: No such file or directory
[2022-08-08T10:10:41.553Z] ['verbose'] Start of uploader: 1659953441553...
[2022-08-08T10:10:41.555Z] ['info'] 
     _____          _
    / ____|        | |
   | |     ___   __| | ___  ___ _____   __
   | |    / _ \ / _` |/ _ \/ __/ _ \ \ / /
   | |___| (_) | (_| |  __/ (_| (_) \ V /
    \_____\___/ \__,_|\___|\___\___/ \_/
  Codecov report uploader 0.2.5
[2022-08-08T10:10:41.576Z] ['info'] => Project root located at: /Volumes/workspace/repository
[2022-08-08T10:10:41.579Z] ['info'] ->  Token found by arguments
[2022-08-08T10:10:41.580Z] ['verbose'] Start of network processing...
[2022-08-08T10:10:41.580Z] ['verbose'] Searching for files in /Volumes/workspace/repository
[2022-08-08T10:10:41.604Z] ['info'] Running xcode coversion...
[2022-08-08T10:10:42.672Z] ['verbose'] Writing coverage to ./coverage-report-resultbundle.json
[2022-08-08T10:10:42.681Z] ['verbose'] ./coverage-report-resultbundle.json
[2022-08-08T10:10:42.688Z] ['verbose'] coveragepy is not installed
[2022-08-08T10:10:42.688Z] ['info'] Searching for coverage files...
[2022-08-08T10:10:42.946Z] ['info'] Warning: Some files located via search were excluded from upload.
[2022-08-08T10:10:42.946Z] ['info'] If Codecov did not locate your files, please review https://docs.codecov.com/docs/supported-report-formats
[2022-08-08T10:10:42.946Z] ['verbose'] Preparing to clean the following coverage paths: <project-name>/ci_scripts/coverage-report-resultbundle.json
[2022-08-08T10:10:42.946Z] ['info'] => Found 1 possible coverage files:
  <project-name>/ci_scripts/coverage-report-resultbundle.json
[2022-08-08T10:10:42.946Z] ['verbose'] End of network processing
[2022-08-08T10:10:42.947Z] ['info'] Processing /Volumes/workspace/repository/<project-name>/ci_scripts/coverage-report-resultbundle.json...
[2022-08-08T10:10:42.949Z] ['info'] Using manual override from args.
[2022-08-08T10:10:42.967Z] ['info'] Detected Local as the CI provider.
[2022-08-08T10:10:42.968Z] ['verbose'] -> Using the following env variables:
[2022-08-08T10:10:42.968Z] ['verbose']      BRANCH_NAME: undefined
[2022-08-08T10:10:42.968Z] ['verbose']      CI: TRUE
[2022-08-08T10:10:42.968Z] ['verbose']      GIT_BRANCH: undefined
[2022-08-08T10:10:42.968Z] ['verbose']      GIT_COMMIT: undefined
[2022-08-08T10:10:42.984Z] ['verbose'] Using the following upload parameters:
[2022-08-08T10:10:42.985Z] ['verbose'] branch
[2022-08-08T10:10:42.985Z] ['verbose'] build
[2022-08-08T10:10:42.985Z] ['verbose'] buildURL
[2022-08-08T10:10:42.985Z] ['verbose'] commit
[2022-08-08T10:10:42.985Z] ['verbose'] job
[2022-08-08T10:10:42.985Z] ['verbose'] pr
[2022-08-08T10:10:42.985Z] ['verbose'] service
[2022-08-08T10:10:42.985Z] ['verbose'] slug
[2022-08-08T10:10:42.985Z] ['verbose'] name
[2022-08-08T10:10:42.985Z] ['verbose'] tag
[2022-08-08T10:10:42.985Z] ['verbose'] flags
[2022-08-08T10:10:42.985Z] ['verbose'] parent
[2022-08-08T10:10:42.986Z] ['info'] Pinging Codecov: https://codecov.io/upload/v4?package=uploader-0.2.5&token=*******&branch=1490-codecov&build=389&build_url=&commit=<commit>&job=&pr=1493&service=&slug=<slug>&name=&tag=&flags=&parent=<parent>
[2022-08-08T10:10:42.987Z] ['verbose'] Passed token was 36 characters long
[2022-08-08T10:10:42.987Z] ['verbose'] https://codecov.io/upload/v4?package=uploader-0.2.5&branch=1490-codecov&build=389&build_url=&commit=<commit>&job=&pr=1493&service=&slug=<slug>&name=&tag=&flags=&parent=<parent>
        Content-Type: 'text/plain'
        Content-Encoding: 'gzip'
        X-Reduced-Redundancy: 'false'
[2022-08-08T10:10:43.571Z] ['info'] https://codecov.io/github/<ogr-name>/<repo>/commit/<commit>
https://storage.googleapis.com/codecov/v4/raw/2022-08-08/BFE9A5CBB0EDAC879D8584FD0E061090/df69939178f23f7f224739d6e587dddc926f6034/5000b464-9ab1-41dc-8d2f-bee8cd1adabc.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GOOG1EJOGFN2JQ4OCTGA2MU5AEIT7OT5Z7HTFOAN2SPG4NWSN2UJYOY5U6LZQ%2F20220808%2FUS%2Fs3%2Faws4_request&X-Amz-Date=20220808T101043Z&X-Amz-Expires=10&X-Amz-SignedHeaders=host&X-Amz-Signature=145100b0ae2042f7a57eb201ec6d5d0b2412e4c5b587ea9d1285fb00207bf5d3
[2022-08-08T10:10:43.571Z] ['verbose'] Returned upload url: https://storage.googleapis.com/codecov/v4/raw/2022-08-08/BFE9A5CBB0EDAC879D8584FD0E061090/df69939178f23f7f224739d6e587dddc926f6034/5000b464-9ab1-41dc-8d2f-bee8cd1adabc.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GOOG1EJOGFN2JQ4OCTGA2MU5AEIT7OT5Z7HTFOAN2SPG4NWSN2UJYOY5U6LZQ%2F20220808%2FUS%2Fs3%2Faws4_request&X-Amz-Date=20220808T101043Z&X-Amz-Expires=10&X-Amz-SignedHeaders=host&X-Amz-Signature=145100b0ae2042f7a57eb201ec6d5d0b2412e4c5b587ea9d1285fb00207bf5d3
[2022-08-08T10:10:43.571Z] ['info'] Uploading...
[2022-08-08T10:10:43.832Z] ['info'] {"status":"success","resultURL":"https://codecov.io/github/<org-name>/<repo>/commit/<commit>"}
[2022-08-08T10:10:43.832Z] ['verbose'] End of uploader: 2279 milliseconds
Command executed successfully

Expected Results

Successfully uploaded report.

Actual Results


Screenshot 2022-08-15 at 16.58.37

Additional Information

Upload script:

#!/bin/sh

 cd $CI_WORKSPACE/<repo>/ci_scripts/resources
 curl -Os https://uploader.codecov.io/latest/macos/codecov
 chmod +x codecov

 ./codecov -t $CODECOV_TOKEN --branch $CI_PULL_REQUEST_SOURCE_BRANCH --build $CI_BUILD_NUMBER --sha $CI_PULL_REQUEST_SOURCE_COMMIT --parent $CI_PULL_REQUEST_TARGET_COMMIT --pr $CI_PULL_REQUEST_NUMBER --verbose --xcode --xcodeArchivePath $CI_RESULT_BUNDLE_PATH

@dsk1306 can you share a commit SHA?

@tom I think it was df69939178f23f7f224739d6e587dddc926f6034

@dsk1306 got it, my guess is that you are passing in the wrong directory for xcodeArchivePath. From the docs, it says Specify the xcode archive path. Likely specified as the -resultBundlePath and should end in .xcresult

Unfortunately, I’m not an xcode developer so I’m a little bit out of my league here. Does that make sense? Else, can you share how you are collecting coverage?

@tom I use xCode Cloud provided $CI_RESULT_BUNDLE_PATH variable to specify the path to .xcresult. According to Apple docs, it should be ok, but I will double check it.

@dsk1306, no I think that probably is fine. Are you able to do a cat on that bundle to make sure it has data? I’m not sure if it’s compressed

@tom Ok, I’ve added cat $CI_RESULT_BUNDLE_PATH to my runscript and I’ve got

cat: /Volumes/workspace/resultbundle.xcresult: Is a directory

Do I need to perform extra compression here?

@tom Ok I’ve tried to preview the bundle with xccov view and it looks like xCode Cloud doesn’t collect coverage data because it failed

I’ve contacted Apple to see if I’m missing something.

@dsk1306 ahhhh I see. Is there anything I can do to help?

@tom I’ve created a ticket on the Apple Dev portal. Hopefully, they will give me an answer. Meanwhile, I will just use another CI. Thank you for your help!

1 Like