question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible to use specific OS version for cache keys?

See original GitHub issue

Hi! We’re loving github actions so far. This is a small request related to variables available for cache keys.

We use {{ runner.os }} in our cache keys, like most of the docs here and examples I’ve seen around the internet. When ubuntu-latest was updated from 18 to 20, the build failed and I was surprised to see that it was because the cache wasn’t busted. Looking into it, {{ runner.os }} returns “Linux” (or “macOS” or similar), so it didn’t change even though our OS did. I would prefer to include the actual os version (e.g. ubuntu-20-04 or similar) in my cache keys so that the cache is busted when we change the os version. After looking around a bit, I don’t see an easy way to do this. I posted this in the community, but so far no one seems to have a workaround.

What do you all think about having runner.os_version variable or something similar available?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:13
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
matt335672commented, Mar 5, 2021

Hi @albaer

For info, I’ve proposed a workaround to the xrdp project where we cache a version of cppcheck. We got bitten by this too.

Have a look at the first commit neutrinolabs/xrdp@984e8d12c062e2517487198edbe040e3cdbb928b in the PR.

We’d like a better solution too! Hope this is useful in the meantime however.

1reaction
Kurt-von-Lavencommented, May 22, 2022

Since there are a lot of folks on this thread, please note that the first step simply creates a file containing random contents and is for illustration purposes only. You would only need to copy the second step (reproduced below for your convenience) and use it in your cache step as illustrated in the third step (by referencing ${{ steps.os.outputs.image }}). On a side note, you must specify the shell as Bash on Windows and in composite actions, the inner use of echo in the second step is unnecessary, and the correct key is runs-on rather than runs-os.

- name: Get operating system name and version.
  id: os
  run: echo "::set-output name=image::$ImageOS"
  shell: bash
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cache Keys - Cloudflare Docs
Cache Keys. A Cache Key is an identifier that Cloudflare uses for a file in our cache, and the Cache Key Template defines...
Read more >
Caching dependencies to speed up workflows - GitHub Docs
To cache dependencies for a job, you can use GitHub's cache action. The action creates and restores a cache identified by a unique...
Read more >
Caching Strategies - CircleCI
This document is a guide to the various caching strategies available for managing dependency caches in CircleCI.
Read more >
Caching in GitLab CI/CD
If you do not want to use cache key names, you can have all branches (protected and unprotected) use the same cache. The...
Read more >
Build Cache - Gradle User Manual
The task path is not an input to the build cache key. This means that tasks with different task paths can re-use each...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found