spotify / XCRemoteCache

Other
825 stars 50 forks source link

Improve mechanism of finding cache artifacts #143

Closed canhth closed 2 years ago

canhth commented 2 years ago

Problems

Not sure if I missed something else, but I have a problem with finding the cache artifacts in my real project.

The job run in CICD machines

Screen Shot 2022-05-31 at 18 44 49

Expected/desired behavior

Relevant integration setup

[x ] CocoaPods cocoapods-xcremotecache plugin

polac24 commented 2 years ago

Hi! Finding the most recent commit sha with artifacts is indeed a lengthy process - it makes a HEAD request for all commits one-by-one. If you generate artifacts so seldom (even I suggest running that more often than twice a day), a history count should be higher.

Regarding the image, it works a bit differently. It starts counting since a first common sha, not from a current sha (note we call something like git log -50 --pretty=format:%H --first-parent COMMON_SHA_HERE. Here is the code that finds the COMMON_SHA: https://github.com/spotify/XCRemoteCache/blob/b6318e97855f8f23b2dc670a8765baad80340d25/Sources/XCRemoteCache/Git/GitClient.swift#L76-L85

common

Do you see room for implement?

canhth commented 2 years ago

Thank you for clarifying.

If you generate artifacts so seldom (even I suggest running that more often than twice a day), a history count should be higher.

Starting the most recent commit with the primary branch (master) check 100 commits if has artifacts ready Do you see room for implement?

I'm sorry but I'm a bit confused here, could you please help to point out which one is correct:

  1. You mean it starts counting since a first common sha and then the result will be only the commits history of master branch? (merge-base commit only)
- Commit 4            - Commit A2
- Commit 3            - Commit A1
- Commit 2     --> - Checkout from commit 2 
- Commit 1   
- Commit 0
- Commit -1
** master **          ** feature A **

After run git log -50 --pretty=format:%H --first-parent COMMON_SHA, the list will be:

- Commit 2
- Commit 1   
- Commit 0
- Commit -1
-........

Is that correct? And no need to implement anything else because searching commit history from master branch already supported? I ran this in my project and the most of the commits in master branch.

  1. "Starting the most recent commit with the primary branch (master) check 100 commits if has artifacts ready" is not ready yet? And we can support this option?
polac24 commented 2 years ago

XCRemoteCache works according to the scenario 1. so no need to implement anything.