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

Builds failing on Bitrise with stack Xcode 13.3.x (beta) #417

Closed
brandtdaniels opened this issue Feb 17, 2022 · 38 comments
Closed

Builds failing on Bitrise with stack Xcode 13.3.x (beta) #417

brandtdaniels opened this issue Feb 17, 2022 · 38 comments
Labels

Comments

@brandtdaniels
Copy link

brandtdaniels commented Feb 17, 2022

Bitrise stack "Xcode 13.3.x (beta) on macOS 12.2 (Monterey)" is failing builds with the following error message

Last lines of the build log:
Script path: /Users/vagrant/git/CRM
xargs: /Users/vagrant/git/CRM/cuckoo_generator: terminated with signal 4; aborting
Command PhaseScriptExecution failed with a nonzero exit code

Test session results, code coverage, and logs:
	/var/folders/62/0p2cg52j6r16xjxfqch4vgt40000gn/T/XCUITestOutput573379856/Test.xcresult

Testing failed:
	Command PhaseScriptExecution failed with a nonzero exit code
	Testing cancelled because the build failed.

** TEST FAILED **

The following build commands failed:
	PhaseScriptExecution Cuckoo\ Run\ Script /Users/vagrant/Library/Developer/Xcode/DerivedData/CRM-gfmkxxwjwsejasaegkkqxuwbswfa/Build/Intermediates.noindex/CRM.build/Debug-iphonesimulator/CRMTests.build/Script-3312E990D1E37BD0916B2578.sh (in target 'CRMTests' from project 'CRM')
(1 failure)

Recently included the following conditionals in the Cuckoo Run Script which seems to have no improvement

if [ $ACTION == "indexbuild" ]; then
  echo "Not running Cuckoo generator during indexing."
  exit 0 
fi

# Skip for preview builds
if [ "${ENABLE_PREVIEWS}" = "YES" ]; then
  echo "Not running Cuckoo generator during preview builds."
  exit 0
fi
@brandtdaniels brandtdaniels changed the title Builds failing on Bitrise with stack Xcode 13.3.x Builds failing on Bitrise with stack Xcode 13.3.x (beta) Feb 17, 2022
@brandtdaniels
Copy link
Author

@MatyasKriz Have you seen any issues with the latest Xcode beta?

@MatyasKriz
Copy link
Collaborator

Hey, @brandtdaniels. I haven't tried compiling nor running Cuckoo on the beta builds of Xcode. Not sure what the issue could be.

@MatyasKriz
Copy link
Collaborator

Is there more info somewhere in the logs? My internet connection isn't stellar to download the Xcode beta just to find an issue.

@brandtdaniels
Copy link
Author

I didn't really see anything more in the logs

@MatyasKriz
Copy link
Collaborator

MatyasKriz commented Feb 23, 2022

Is it possible to switch to an earlier Xcode on Bitrise, or is this just a heads up that Cuckoo fails to run in Xcode 13.3 beta?

I'll have to take a look at the missing CI in this project.

@MatyasKriz MatyasKriz added the bug label Feb 23, 2022
@brandtdaniels
Copy link
Author

brandtdaniels commented Feb 23, 2022

We typically prepare for upcoming versions of Xcode/iOS as soon as they become available. We try to catch these issues proactively. This is sort of a heads up, but would also like to resolve this as we have nightly builds that run specs against the latest stacks (including betas)

@karim-alweheshy
Copy link

For me it is failing on lastest xcode xargs: /{fill_in_dir}/Pods/Cuckoo/cuckoo_generator: terminated with signal 5; aborting

@jandrewmoore
Copy link

My project is failing after updating Xcode, as well, but with signal 4.

xargs: [redacted]/Pods/Cuckoo/cuckoo_generator: terminated with signal 4; aborting
Command PhaseScriptExecution failed with a nonzero exit code

Doesn't seem like adding --debug is adding any additional information in this case.

@antoniocasero
Copy link

Same problem here, usually, I would try my best to fix it, but it crashes without reason.
I observed this issue only happens for some specific files.

@antoniocasero
Copy link

Ok, after exploring why only some files were making the script crash. I found out that if the protocol defines a function without a label, it crashes.

func foo(_ bar: Bar) // It crashes
func foo(bar: Bar) // All good

@JavaAdam
Copy link

My project is failing after updating Xcode, as well, but with signal 4.

xargs: [redacted]/Pods/Cuckoo/cuckoo_generator: terminated with signal 4; aborting
Command PhaseScriptExecution failed with a nonzero exit code

Doesn't seem like adding --debug is adding any additional information in this case.

It's the same for me.

@samshiffman321
Copy link

I'm also seeing the same issue after upgrading Xcode to 13.3 cuckoo_generator: terminated with signal 4; aborting

@dongdonggaui
Copy link

Ok, after exploring why only some files were making the script crash. I found out that if the protocol defines a function without a label, it crashes.

func foo(_ bar: Bar) // It crashes
func foo(bar: Bar) // All good

It seems that SourceKit has been updated. When parsing parameters without a label such as func foo(_ bar: Bar), the parameter key.nameoffset and key.namelength 2 values are lost.

dongdonggaui pushed a commit to dongdonggaui/Cuckoo that referenced this issue Mar 17, 2022
@MatyasKriz
Copy link
Collaborator

Hey everyone! Thanks a lot for the leads, especially @antoniocasero and @dongdonggaui for finding the issue. 🙂 I've verified that the problem is indeed because of the missing properties, though the name range isn't used, so I've just made it optional for now.

I've merged and released the fix, please try it out and let me know if it helped. 🙂

@brandtdaniels
Copy link
Author

I've merged and released the fix, please try it out and let me know if it helped. 🙂

Does it take time to propagate the release? The update isn't being picked up when trying to update the package on my end.

@MatyasKriz
Copy link
Collaborator

Does it take time to propagate the release?

Which package manager?

@brandtdaniels
Copy link
Author

Which package manager?

Sorry, SPM

@MatyasKriz
Copy link
Collaborator

MatyasKriz commented Mar 17, 2022

I see, that's my bad. The change here is actually in the generator, not Cuckoo itself, but the binary hasn't been uploaded for some reason. I've fixed that, so now the newest one should get downloaded. 🙂

@brandtdaniels
Copy link
Author

@MatyasKriz I'm getting this error message when trying to resolve packages:

Dependencies could not be resolved because root depends on 'Cuckoo' 1.7.0..<2.0.0.
'Cuckoo' >= 1.7.0 cannot be used because package 'cuckoo' is required using a stable-version but 'cuckoo' depends on an unstable-version package 'ocmock' and no versions of 'Cuckoo' match the requirement 1.7.1..<2.0.0.

@MatyasKriz
Copy link
Collaborator

MatyasKriz commented Mar 17, 2022

@brandtdaniels hm, that must be the addition of OCMock, I'll see what I can do. In the meantime, as these changes are in the generator binary only, you can fallback to 1.6.0 for now.

@brandtdaniels
Copy link
Author

@brandtdaniels hm, that must be the addition of OCMock, I'll see what I can do. In the meantime, as these changes are in the generator binary only, you can fallback to 1.6.0 for now.

Can you clarify how 1.6.0 on SPM will pick up the new generator? I know there were some steps I took to manually copy some scripts/binaries into the project to get Cuckoo to work with SPM.

@MatyasKriz
Copy link
Collaborator

Can you clarify how 1.6.0 on SPM will pick up the new generator?

The run script is responsible for downloading and running the generator. SwiftPM itself is way too limited for that.

@MatyasKriz
Copy link
Collaborator

@ajpallares sorry to ping you in this issue, but do you happen to know how to work around the OCMock unstability?

@sskjames
Copy link

Hi @MatyasKriz, using cocoapods here, got the Cuckoo 1.7.0 release. It's working for me. Thank you very much for the fix.

@ajpallares
Copy link
Contributor

@MatyasKriz I'm afraid that a simple workaround is not possible. It looks like referencing a dependency using the commit hash or branch name) is considered an "unstable reference" by SPM. And a stable reference, i.e. a tag, can only depend on unstable references... (a better explanation here)
This was my mistake, I did not realize of this limitation of the SPM.

This is, in fact, pointed out in the very OCMock repo, but which I did not see beforehand :(

There might be a possible workaround for this, which involves having a local Swift Package which wraps the unstable package. I need to investigate this in depth. We might take advantage of the fact that we actually need to have the Swift wrapper Cuckoo+OCMock.

Sorry for the inconvenience and I hope I can solve this soon using that workaround.

@MatyasKriz
Copy link
Collaborator

@ajpallares thanks for the thorough analysis. 🙂 Don't worry about it, this kind of stuff happens. I'm glad you're here to help us push through. I'll release 1.7.1 without the SPM changes for now, so there's no pressure at all.

@brandtdaniels
Copy link
Author

@brandtdaniels hm, that must be the addition of OCMock, I'll see what I can do. In the meantime, as these changes are in the generator binary only, you can fallback to 1.6.0 for now.

@MatyasKriz It sounds like you're saying I don't need to do anything and the Bitrise build should just pick up the new generator binary. This doesn't seem to be the case. Can you clarify a little more how an older version of Cuckoo will pickup a new generator binary?

@MatyasKriz
Copy link
Collaborator

@brandtdaniels Depending on how you call the run script, you can download a specific version of the generator or the latest one if no version is specified. However, this happens only if there isn't a generator binary already present. To override, pass the `--clean‘ flag as well.

@brandtdaniels
Copy link
Author

brandtdaniels commented Mar 21, 2022

@brandtdaniels Depending on how you call the run script, you can download a specific version of the generator or the latest one if no version is specified. However, this happens only if there isn't a generator binary already present. To override, pass the `--clean‘ flag as well.

Thank you. Bitrise starts clean every build, so I would assume that it would download the generator every time. I did just notice though that we have "cuckoo_generator" committed to our repository. Is having it committed good practice? with SPM?

Locally, I deleted the cuckoo_generator and ran the specs to see if it would download a newer one and I got this error

No Cuckoo Generator found.
~/Developer/git/mobile.crm.ios/CRM ~/Developer/git/mobile.crm.ios/CRM
Couldn't build. Generator source code not found. (expected in the 'Generator' directory)
Downloading version ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   126  100   126    0     0    372      0 --:--:-- --:--:-- --:--:--   381
Error: Failed to fetch download URL for the Cuckoo Generator.
Command PhaseScriptExecution failed with a nonzero exit code

@brandtdaniels
Copy link
Author

To work with SPM, I had to download the latest cuckoo_generator Add execute permissions chmod +x cuckoo_generator and commit to my repository. I was then able to build and run specs on Xcode 13.3.x

@MatyasKriz
Copy link
Collaborator

@brandtdaniels I'd highly recommend against commiting binaries into the git repo. Every time you update a binary in git, it essentially doubles in size. I'd also suggest you delete the commits that added the binary in the first place.

The problem you're facing is that there's no way for us to update your run script at the moment, as it has been fixed a while back. Simply download the latest run script from master and run it with arguments --download --clean. Let me know if that works for you.

@jgavris
Copy link
Contributor

jgavris commented Mar 22, 2022

If you're using Git LFS (large file storage), you can check in the binaries (cuckoo generator etc) into your repo and mostly have constant size over time, which is not terrible. Aka if you upgrade cuckoo a few times, the overall repo / checkout size won't change.

Git LFS only requires downloading the versions of the files (tracked by LFS) that are reachable from the commit you are checking out, not every delta in between like normal git tracked files. We (and possibly a lot of other Cocoapods users) 'vendor' the entire Pods directory into git repo (checked in) and added this hook to our Podfile to automatically track any files over 300k (change to suite your taste) after running pod install.

post_install do |installer_representation|
  # Update git-lfs tracked files.
  Dir.chdir("Pods") do
    system "rm -f .gitattributes | find . -size +300k | xargs git lfs track"
    system "sort -n .gitattributes > /tmp/.gitattributes && mv /tmp/.gitattributes .gitattributes"
  end
end

Automatic tracking of large files in Git LFS is a highly requested feature (see git-lfs/git-lfs#282), but one fairly easily worked around with a little bit of scripting.

@MatyasKriz
Copy link
Collaborator

@jgavris I don't know your setup and I assumed that the binary was not in LFS. Of course, if you want to keep the binary in the repo, it's your call. 🙂

@brandtdaniels
Copy link
Author

Simply download the latest run script from master and run it with arguments --download --clean. Let me know if that works for you.

It looks like the run script on master hasn't been updated in 2 years

@MatyasKriz
Copy link
Collaborator

Simply download the latest run script from master and run it with arguments --download --clean. Let me know if that works for you.

It looks like the run script on master hasn't been updated in 2 years

I see, time flies. 😅 Though the current version seems to work without problems.

@brandtdaniels
Copy link
Author

@brandtdaniels I'd highly recommend against commiting binaries into the git repo. Every time you update a binary in git, it essentially doubles in size. I'd also suggest you delete the commits that added the binary in the first place.

The problem you're facing is that there's no way for us to update your run script at the moment, as it has been fixed a while back. Simply download the latest run script from master and run it with arguments --download --clean. Let me know if that works for you.

After removing the binary from the repo, and adding --clean --download to the script, I am facing the same problem I originally had with Xcode 13.3.x:

 The following build commands failed:
	PhaseScriptExecution Cuckoo\ Run\ Script /Users/vagrant/Library/Developer/Xcode/DerivedData/CRM-gfmkxxwjwsejasaegkkqxuwbswfa/Build/Intermediates.noindex/CRM.build/Debug-iphonesimulator/CRMTests.build/Script-3312E990D1E37BD0916B2578.sh (in target 'CRMTests' from project 'CRM')
(1 failure)

@brandtdaniels brandtdaniels reopened this Mar 22, 2022
@MatyasKriz
Copy link
Collaborator

Let's keep this issue closed and not ping all the other participants with debugging. The original issue has been fixed and now we just need to find out how to get your build script to correctly download the latest binary. Please open a new issue with some more information – if you run the run script by itself with the parameters, does it work? You mentioned something about a custom script, can that cause interference somehow?

@ppamorim
Copy link

ppamorim commented Apr 6, 2023

@MatyasKriz This is not fixed, it's returning signal 9 on cuckoo runner. I tested the version 1.10.1. I have to use the version 1.0.0 to make my tests work. I am using Xcode 14.2.

The code used to generate the mock is:

"${PROJECT_DIR}/Scripts/cuckoo" --clean --download generate --testable "${PROJECT_NAME}" \
--output "${OUTPUT_FILE}" \

Results into:

Generated Mocks File = /Users/me/myProject/MyProjectTests/GeneratedMocks.swift
Mocks Input Directory = /Users/me/myProject/MyProject
Script path: /Users/me/myProject/Scripts
Performing clean build.
No Cuckoo Generator found.
~/Repository/myProject/Scripts ~/Repository/myProject
Downloading latest version...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  3891  100  3891    0     0   9305      0 --:--:-- --:--:-- --:--:--  9421
Downloading Cuckoo Generator from URL: https://github.com/Brightify/Cuckoo/releases/download/1.10.1/cuckoo_generator
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

  5 9328k    5  552k    0     0   624k      0  0:00:14 --:--:--  0:00:14  624k
 41 9328k   41 3871k    0     0  2044k      0  0:00:04  0:00:01  0:00:03 3289k
 71 9328k   71 6655k    0     0  2312k      0  0:00:04  0:00:02  0:00:02 3059k
100 9328k  100 9328k    0     0  2509k      0  0:00:03  0:00:03 --:--:-- 3098k
~/Repository/myProject
xargs: /Users/me/myProject/Scripts/cuckoo_generator: terminated with signal 9; aborting
Command PhaseScriptExecution failed with a nonzero exit code

Generated Mocks File = /Users/me/myProject/MyProjectTests/GeneratedMocks.swift

Mocks Input Directory = /Users/me/myProject/MyProject

Script path: /Users/me/myProject/Scripts

Performing clean build.

No Cuckoo Generator found.

~/Repository/myProject/Scripts ~/Repository/myProject

Downloading latest version...

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed


  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  3891  100  3891    0     0   9305      0 --:--:-- --:--:-- --:--:--  9421

Downloading Cuckoo Generator from URL: https://github.com/Brightify/Cuckoo/releases/download/1.10.1/cuckoo_generator

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed


  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0


  5 9328k    5  552k    0     0   624k      0  0:00:14 --:--:--  0:00:14  624k
 41 9328k   41 3871k    0     0  2044k      0  0:00:04  0:00:01  0:00:03 3289k
 71 9328k   71 6655k    0     0  2312k      0  0:00:04  0:00:02  0:00:02 3059k
100 9328k  100 9328k    0     0  2509k      0  0:00:03  0:00:03 --:--:-- 3098k

~/Repository/myProject

xargs: /Users/me/myProject/Scripts/cuckoo_generator: terminated with signal 9; aborting

Command PhaseScriptExecution failed with a nonzero exit code

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

No branches or pull requests