uses : with : bundler-cache : true # Now run your actual CI command. Github actions cache install#needs : cache_gems steps : - uses : # Each dependant job still need to install Ruby and ensure that it reads # from the cache before installing the gems (which is as simple as # specifying `bundler-cache: true` when using ruby/setup-ruby). bundler-cache : true brakeman : name : Brakeman runs-on : ubuntu-latest # Tell this job to wait for the `cache_gems` job to successfully complete # before it runs. Here’s an example of installing gems, note the job cache_gems and how the other jobs declare it as a dependency by specifying needs: cache_gems: on : jobs : cache_gems : name : Cache gems runs-on : ubuntu-latest steps : - uses : - uses : with : # We always need to tell ruby/setup-ruby to cache the gems for us. Rather than store the installed dependencies as a workflow artifact I prefer to treat this step as warming a cache - which may be a little more verbose but I think is simpler overall (also, with this approach, the cache is treated as a performance optimisation and each dependant job is still able to run if it isn’t present for for some reason). The simple fix is to declare an initial job whose sole purpose is to do the work of installing dependencies and to make them available for the other jobs. Nothing will blow up, but all of those separate jobs installing dependencies are wasting billable time. The thing I want to prevent is each job having to download and install its dependencies, when this occurs one of the jobs will finish first and write to the cache and then we’ll see something like Cache hit occurred on the primary key BIG-LONG-KEY, not saving cache from the Post Run output in other jobs. I previously wrote about caching gems on CircleCI and although this is even easier to achieve with GitHub Actions there’s still a useful approach worth applying that will minimise the overall time spent installing dependencies when a workflow contains many jobs.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |