Is attach_workspace used for restoring cache? What is the main purpose for?
In the documentation, restore_cache restores gems at working directory not to use attach_workspace. I sometimes see that attach_workspace and persist_to_workspace is used for restoring and caching gems.
build:
working_directory: ~/app
steps:
- checkout
- restore_cache:
keys:
- rails-bundle-v1-{{ checksum "Gemfile.lock" }}
- rails-bundle-v1-
- run:
name: bundle install
command: bundle check --path vendor/bundle || bundle install --deployment
- save_cache:
key: rails-bundle-v1-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- persist_to_workspace:
root: ~/app
paths:
- vendor/bundle
deploy:
working_directory: ~/app
steps:
- checkout
- attach_workspace: # <- Is it possible to restore cache????
at: ~/app
I also tried restoring gems without persist_to_workspace and attach_workspace. Please refer .circleci/config.yml and its results form following links. It has finished successfully!
The core difference between workspaces and caching is that workspaces are scoped to your workflow whereas caches are available across all workflows in your project.