danger / swift

⚠️ Stop saying "you forgot to …" in code review
https://danger.systems/swift/
MIT License
1.05k stars 141 forks source link

Danger causing unexpected pipeline failures with concurrency enabled #529

Closed squarefrog closed 2 years ago

squarefrog commented 2 years ago

We run iOS CI pipelines using gitlab-runner hosted on MacStudium Mac Minis. When two pipelines run at a similar time we get random failures resulting from our Danger step. Danger is setup as a nested Swift Package, which our CI server builds at the start of each pipeline run.

When the runner clones the repo, it clones to a folder using the runner concurrency identifier. For example, here are two possible folders:

/Users/[username]/builds/[runner-id]/0/[project-name]/.git/
/Users/[username]/builds/[runner-id]/1/[project-name]/.git/

For the most part this works great, however we are getting failures related to the temporary directory Danger uses. Looking at two failed pipelines, I can see while the clone paths are different, the danger temporary path is the same:

$ cd Danger && arch -x86_64 swift run danger-swift ci -i post_build -f --dangerfile DangerfilePostBuild.swift --cwd ../ && cd -
[1/1] Planning build
[0/0] Build complete!
<unknown>:0: error: error opening input file '/var/folders/rm/_fdw_5ys44xb_2gswdqh8c4r0000gq/T/_tmp_dangerfile.swift' (No such file or directory)
ERROR: Dangerfile eval failed at DangerfilePostBuild.swift
Failing the build, there is 1 fail.
$ cd Danger && arch -x86_64 swift run danger-swift ci -i post_build -f --dangerfile DangerfilePostBuild.swift --cwd ../ && cd -
[1/1] Planning build
[0/0] Build complete!
<unknown>:0: error: error opening input file '/var/folders/rm/_fdw_5ys44xb_2gswdqh8c4r0000gq/T/_tmp_dangerfile.swift' (No such file or directory)
ERROR: Dangerfile eval failed at DangerfilePostBuild.swift
Failing the build, there is 1 fail.

Is there a way for us to define the temporary directory to use with Danger? That way we could just nest a .tmp folder within the clone directory.

squarefrog commented 2 years ago

Created a PR for this.

squarefrog commented 2 years ago

Could I ask if this is likely to make it into a tagged release soon? We've tried to update our pipeline to use our fork in the meantime, but this has been a failure as we also use Danger Xcode Summary, which doesn't use the fork.

I've tried updating that too, but I then get unexpectedCycle errors from SPM. It doesn't seem like theres a nice way to use a fork right now.

f-meloni commented 2 years ago

Yes, I will make a release a soon as I come back from the holidays, if I manage to find a Mac even earlier 😁

squarefrog commented 2 years ago

Thank you, we appreciate it. Enjoy your well-earned rest 🌴

f-meloni commented 2 years ago

I've managed to get a Mac, and made a release (3.14.0). Please let me know if everything is OK :)

squarefrog commented 2 years ago

That is fantastic news thank you! I’ll update our ci servers Monday and keep an eye on them throughout the week.