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

How to set Build path & coverage location #2

Closed
ishayan18 opened this issue May 10, 2022 · 12 comments · Fixed by #3
Closed

How to set Build path & coverage location #2

ishayan18 opened this issue May 10, 2022 · 12 comments · Fixed by #3

Comments

@ishayan18
Copy link

I'm unable to set build path and coverage location for my CI workflow, I'm using GitHub actions custom runners with Xcode.

Below is my workflow file

    steps:
      - uses: actions/checkout@v1
      - run: arch -arm64 xcodebuild test -project $PROJECT_NAME.xcodeproj -scheme $PROJECT_NAME -configuration Debug -destination 'platform=iOS Simulator,name=${{ matrix.device }},OS=latest' -enableCodeCoverage YES
      - uses: michaelhenry/[email protected]
        with:
          build-path: ~/Library/Developer/Xcode/DerivedData
          target: $PROJECT_NAME.app
          is-spm: false
      - name: Publish to code climate
        uses: paambaati/[email protected]
        env:
          CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
        with:
          coverageCommand: arch -arm64 xcodebuild test -scheme $PROJECT_NAME -destination 'platform=iOS Simulator,name=${{ matrix.device }},OS=latest'  -enableCodeCoverage YES  -disableAutomaticPackageResolution
          coverageLocations: |
            fastlane/xcov_report
@michaelhenry
Copy link
Owner

michaelhenry commented May 11, 2022

@ShayanPapershift

oh I see. how about specifying the derivedDataPath to the same folder.

eg.

 steps:
      - uses: actions/checkout@v1
      - run: arch -arm64 xcodebuild test -project $PROJECT_NAME.xcodeproj -scheme $PROJECT_NAME -configuration Debug -destination 'platform=iOS Simulator,name=${{ matrix.device }},OS=latest' -enableCodeCoverage YES -derivedDataPath DerivedData
      - uses: michaelhenry/[email protected]
        with:
          build-path: DerivedData
          target: $PROJECT_NAME.app
          is-spm: false
      - name: Publish to code climate
        uses: paambaati/[email protected]
        env:
          CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
        with:
          coverageCommand: arch -arm64 xcodebuild test -scheme $PROJECT_NAME -destination 'platform=iOS Simulator,name=${{ matrix.device }},OS=latest'  -enableCodeCoverage YES  -disableAutomaticPackageResolution
          coverageLocations: |
            fastlane/xcov_report

@ishayan18
Copy link
Author

Works fine, just wanna know how how to upload test coverage for swift packages?

@ishayan18
Copy link
Author

Here is my CI workflow job, could you please check what am I missing here?

  - name: Build & Run Tests
        run: arch -arm64 xcodebuild test -scheme ApiClient -destination 'platform=iOS Simulator,name=iPhone 12,OS=latest' -enableCodeCoverage YES -derivedDataPath .build

      - uses: michaelhenry/[email protected]
        with:
          build-path: .build
          target: $PROJECT_NAME
          is-spm: true
      - name: Publish to code climate
        uses: paambaati/[email protected]
        env:
          CC_TEST_REPORTER_ID: 0aeb70a0fd8414c0d88bd2e835c3c945b62ddce08c54bd3553a07b46951d53a1
        with:
          coverageCommand: arch -arm64 xcodebuild test -scheme ApiClient -destination "platform=iOS Simulator,name=${{ matrix.device }},OS=latest"  -enableCodeCoverage YES
          coverageLocations: |
            coverage/lcov.info:lcov

Also the screenshot of failing CI
Screenshot 2022-06-09 at 3 33 56 PM

@ishayan18
Copy link
Author

ishayan18 commented Jun 14, 2022

@michaelhenry I'm waiting for your response :)

@michaelhenry
Copy link
Owner

michaelhenry commented Jun 16, 2022

@ShayanPapershift oops, sorry. Please try to update the ‘is-spm’ to false

@ishayan18
Copy link
Author

Hi Henry, thank you for the reply, it says "Failed to load coverage: No such file or directory"
Screenshot 2022-06-16 at 4 55 02 PM

@michaelhenry
Copy link
Owner

michaelhenry commented Jun 16, 2022

@ShayanPapershift please set the. target to ApiClient.app. (with .app filename extension)

@ishayan18
Copy link
Author

@michaelhenry Same issue, it is not finding the coverage directory. Please note that ApiClient is a Swift package.

@michaelhenry
Copy link
Owner

michaelhenry commented Jun 17, 2022

@ShayanPapershift ah i see. please use the swift command instead of the xcodebuild.
Eg.

swift test --enable-code-coverage

@michaelhenry
Copy link
Owner

here is an example:

- run: swift test --enable-code-coverage
- uses: michaelhenry/[email protected]
  with:
    build-path: .build
    target: ApiClient.xctest
    is-spm: true
    output: "coverage/lcov.info"
    output-artifact-name: "codeclimate-artifact"   
- name: Publish code coverage
  uses: paambaati/[email protected]
  env:
    CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
  with:
  coverageLocations: |
    coverage/lcov.info:lcov

@ishayan18
Copy link
Author

ishayan18 commented Jun 20, 2022

@michaelhenry thanks for the support. Please update the readme file and add more instruction on how to upload code coverage for Swift packages!. Right now it's really hard to implement the action for swift package.

@ishayan18 ishayan18 reopened this Jun 20, 2022
@michaelhenry
Copy link
Owner

@ShayanPapershift you’re welcome. Happy to help. Sounds good to me. Thanks

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

Successfully merging a pull request may close this issue.

2 participants