braze-inc / braze-swift-sdk

Braze SDK for the Apple ecosystem, including: iOS, macOS, iPadOS, visionOS, tvOS
https://www.braze.com
Other
52 stars 19 forks source link

[Bug]: Github Actions is always failing when Braze is added via SPM #16

Closed krzys-bfi closed 2 years ago

krzys-bfi commented 2 years ago

Platform

iOS

Platform Version

16.0

Braze SDK Version

5.5.0

Xcode Version

Xcode 14.0.1

Computer Processor

Intel

Repro Rate

100%

Steps To Reproduce

Example:

  1. Add Braze Swift as SPM dependency: .package(url: "https://github.com/braze-inc/braze-swift-sdk.git", .upToNextMajor(from: "5.0.0")
  2. Push to CI

There are around 30 dependencies in our SPM and this is only triggered when new Braze SDK is added. Everything works ok locally. Tested this and managed to reproduce in few CI pipelines. Tested pipeline with small custom SPM with just Braze as dependency, same result.

Main commands run are:

- name: Get cached Swift Packages managed by Xcode
      uses: actions/cache@v3
      with:
        path: Users/runner/Library/Developer/Xcode/DerivedData/**/SourcePackages/checkouts
        key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
        restore-keys: |
          ${{ runner.os }}-spm-

    - name: Run unit tests
      run: |
        xcodebuild \
        -scheme MyScheme \
        -workspace MyWorkspace.xcworkspace \
        -configuration Testing \
        -sdk iphonesimulator \
        -destination 'platform=iOS Simulator,name=iPhone 8,OS=16.0' \
        -verbose \
        build
        xcodebuild \
        -scheme MyScheme \
        -workspace MyWorkspace.xcworkspace \
        -configuration Testing \
        -sdk iphonesimulator \
        -destination 'platform=iOS Simulator,name=iPhone 8,OS=16.0' \
        -verbose \
        test

Expected Behavior

CI workflow works when BrazeSDK is integrated via SPM

Actual Incorrect Behavior

xcodebuild can't resolve dependencies and CI hangs for few hours

Verbose Logs

No response

Additional Information

Everything works properly as long as Braze Swift SDK is integrated through CocoaPods

krzys-bfi commented 2 years ago

As additional info, Package.resolved for Braze:

{
      "identity" : "braze-swift-sdk",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/braze-inc/braze-swift-sdk.git",
      "state" : {
        "revision" : "b8147a77d726f6c75e0ef7efcf0b26f9d1c7b4b5",
        "version" : "5.5.0"
      }
    }
krzys-bfi commented 2 years ago

@lowip maybe you could provide Example project that imports Braze Swift SDK via SPM? I had a look at your example projects to do the migration, but they are not really integrating Braze Swift SDK as external dependency, as its package is just included in example project's local files 🙏

lowip commented 2 years ago

Hi @krzys-bfi, sorry for the delayed response.

Unfortunately, we were unable to reproduce this issue. You can find an example project successfully using Github Actions here.

The only guess I can make is that your cache might be faulty, have you tried performing the CI step disabling / re-generating the cache?

krzys-bfi commented 2 years ago

Yes, normally we use:


    - name: Get cached Swift Packages managed by Xcode
      uses: actions/cache@v3
      with:
        path: Users/runner/Library/Developer/Xcode/DerivedData/**/SourcePackages/checkouts
        key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
        restore-keys: |
          ${{ runner.os }}-spm-

For SPM caching, I've tried disabling it, but it didn't help.

Thanks for retesting it on the project, I'll close the issue, as it must have been something else affecting a build process 🙏