I’ve recently started experimenting with breaking down our massive single workflow into a couple. The major reason for the changes is to get the ability to establish two “workspaces”: one with production dependencies and another with development/test dependencies.
Before:
Install production, development, and test dependencies
Run all unit tests
Run all end-to-end tests
Deploy related jobs
After:
Production workflow
Install dependencies
Run end-to-end tests
Deploy related jobs
Development workflow
Install dependencies
Run all tests (6+ jobs)
I have a couple of questions:
Can I use a cache from 1 workflow in another?
I want to leverage the installed dependencies from production workflow in the development workflow (because the production set is a subset of the development set). Ideally, I would also make the install jobs dependent on each other.
Can I ensure a job from 1 workflow waits on another job from another workflow?
Hi @juanca! That’s great to hear you are making use of multiple workflows, hopefully my suggestions below can benefit your use case. To answer your questions:
Can I use a cache from 1 workflow in another
Yes! You will need to utilize the save_cache and restore_cache steps in order to save and restore the cache. Please note caches are immutable so you will need to increment the cache key in order to create a new cache. Additionally, caches expire in 15 days. You can read more about cache here: Caching, save_cache step, restore_cache step
Can I ensure a job from 1 workflow waits on another job from another workflow?
For this you can use the v2 API and Pipeline Parameters to trigger a workflow to begin once the when condition has been met. This ensures your development workflow will only run once production has completed.
Example API request and parameters passed, where the run_development_parameter parameter is passed as true and therefore will run the development_workflow based on the when condition being met.