danger / swift

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

Suffix temporary directory with unique path #530

Closed squarefrog closed 1 year ago

squarefrog commented 1 year ago

Fixes #529

Reusing the temporary directory can cause issues with concurrent instances of Danger. By appending a unique identifier we can prevent race conditions when running Danger from concurrent processes.

squarefrog commented 1 year ago

Of course! Looks like I've broken all of the pipelines though :(

squarefrog commented 1 year ago

All set for review now @f-meloni, sorry for the CI spam!

When the runner is run, it creates a new temporary directory with a unique ID, for example:

/var/folders/86/1vtftp_j2rn_wdcq6232q_z80000gq/T/danger/4FE1BABB-D918-4FB6-9CCF-D27B45034149/

The temporary files are then created within this folder. Upon completion (either success or failure), then the unique folder is cleaned up leaving only the parent folder:

/var/folders/86/1vtftp_j2rn_wdcq6232q_z80000gq/T/danger/

One thing I'm unsure of though, is the dslJSONPath. I'm unsure where this is as it's passed from Danger JS, so I've left the cleanup for that as-is.

squarefrog commented 1 year ago

Do I need to do anything else to get this merged in?

f-meloni commented 1 year ago

No, I thought I merged it already, sorry

squarefrog commented 1 year ago

Thanks so much!