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

Support diversified remote cache with hash value(like PODFILE CHECKSUM in Podfile.lock) #86

Closed
wants to merge 4 commits into from
Closed

Support diversified remote cache with hash value(like PODFILE CHECKSUM in Podfile.lock) #86

wants to merge 4 commits into from

Conversation

wooseongkim-29cm
Copy link

@wooseongkim-29cm wooseongkim-29cm commented Jul 1, 2021

Checklist

  • I've read the Contribution Guidelines
  • I've run bundle exec rspec from the root directory to run my changes against rspec tests
  • I've run bundle exec rubocop to check code style

Description

(Related Issue : #46)

Remote cache is very useful to sync pods among developer machines & build machines, but there is a problem when we needs various cache.

Swift versions can be various(like 5.3.1 & 5.4), Pod composition or prebuild setup can be various between master and other branches. That's why we needs diversified remote caches for seamless adoption of this library for multi environment and machines.

actions/cache in GitHub Actions support this feature with key like below and it's useful.

- name: Cache Ruby Dependencies
  uses: actions/[email protected]
  id: ruby-bundle-cache-step
  with:
    path: ruby-bundle-cache
    key: ${{ env.machine_name }}-${{ env.ruby_version }}-ruby-bundle-cache-${{ hashFiles('Gemfile.lock') }}

With this change, user programmers can cache specific state with composited key with hash value like PODFILE CHECKSUM in Podfile.lock which is used for remote branch name like below:

# Makefile

# Mostly for build machine
project:
  make xcodegen_generate
  make pod_install

# For daily development for developer
project_fast:
  make xcodegen_generate
  bundle exec pod install

...

podfile_lock_checksum:
  @echo `grep "PODFILE CHECKSUM: " Podfile.lock | awk '{print $$3}'`

# Need to execute on Podfile changes
# Branch name would be 'swift5.4-PODFILE_CHECKSUM'
pod_install:
  bundle exec pod binary prebuild "swift$$(make swift_version)-$$(make podfile_lock_checksum)" --no-fetch # Previous CHECKSUM
  bundle exec pod binary fetch "swift$$(make swift_version)-$$(make podfile_lock_checksum)" # Needs to create new branch if needed (I found `pod binary fetch` handle this)
  bundle exec pod binary push "swift$$(make swift_version)-$$(make podfile_lock_checksum)" # with new CHECKSUM if it is changed after prebuild

...

Changes

  • Can clone with branch name which doesn't exist on remote origin
  • Can fetch with branch name which doesn't exist on remote origin
  • Can push cache with new branch (composited name with swift version or changed CHECKSUM)
  • Create new branch before commit & push when the new cache will be pushed

- Prevent fatal error when fetching not-existing remote branch
- This change will resolve the issue that the newly created branch cannot be pushed to remote repo beacuse of commit fail.
@wooseongkim-29cm wooseongkim-29cm changed the title feature request: Support diversified remote cache with hash value(like PODFILE CHECKSUM in Podfile.lock) Support diversified remote cache with hash value(like PODFILE CHECKSUM in Podfile.lock) Jul 1, 2021
- This will be used when the new cache is pushed
@wooseongkim-29cm
Copy link
Author

@trinhngocthuyen It would be grateful if you review this when you available 🙏

@29CM-Developers 29CM-Developers closed this by deleting the head repository Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants