Title: Allow partial cache keys · Issue #627 · actions/setup-python · GitHub
Open Graph Title: Allow partial cache keys · Issue #627 · actions/setup-python
X Title: Allow partial cache keys · Issue #627 · actions/setup-python
Description: Description: When restoring cache, the current cache management system only uses the primary cache key. GitHub Actions cache allows specifying multiple prefixes, and restoring older caches, to speed up setup even when there has been a de...
Open Graph Description: Description: When restoring cache, the current cache management system only uses the primary cache key. GitHub Actions cache allows specifying multiple prefixes, and restoring older caches, to spee...
X Description: Description: When restoring cache, the current cache management system only uses the primary cache key. GitHub Actions cache allows specifying multiple prefixes, and restoring older caches, to spee...
Opengraph URL: https://github.com/actions/setup-python/issues/627
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow partial cache keys","articleBody":"**Description:**\r\n\r\nWhen restoring cache, the current cache management system only uses the primary cache key.\r\n\r\nGitHub Actions cache allows specifying multiple prefixes, and restoring older caches, to speed up setup even when there has been a dependency change. Cf [corresponding documentation](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key)\r\n\r\nI'd recommend setting this as an opt-in behaviour, toggleable with a new input, because :\r\n* That way, this would not be a breaking change\r\n* Never rebuilding from scratch means stale data could stay forever in cache, which can be dangerous (e.g. a former dependency still present in a virtualenv)\r\n\r\nHere's an example of what the configuration could look like (for poetry) : \r\n\r\n```yaml\r\n - uses: actions/setup-python@v4\r\n id: setup-python\r\n with:\r\n python-version: \"3.10\"\r\n cache: \"poetry\"\r\n allow-partial-restores: true\r\n```\r\n\r\nHere's a configuration roughly equivalent to what I'm proposing here (the cache key is slightly different, but the idea is the same)\r\n\r\n```yaml\r\n - uses: actions/setup-python@v4\r\n id: setup-python\r\n with:\r\n python-version: \"3.10\"\r\n - uses: actions/cache@v3\r\n with:\r\n path: /home/runner/.cache/pypoetry/virtualenvs\r\n key: poetry-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}\r\n restore-keys: |\r\n poetry-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}\r\n poetry-${{ steps.setup-python.outputs.python-version }}-\r\n```\r\n\r\nWe could also expose cache key management to the users through an input parameter, but that seems much more complex and brittle.\r\n\r\n**Justification:**\r\n\r\nThis change can represent a significant performance improvement on lockfile change, easily several minutes, depending on the project.\r\n\r\n**Are you willing to submit a PR?**\r\nNot at the time, as I have a working workaround (presented above).","author":{"url":"https://github.com/toadjaune","@type":"Person","name":"toadjaune"},"datePublished":"2023-03-15T16:27:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/627/setup-python/issues/627"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:40671554-7fa9-cb17-6e8e-e7cbbeed246f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E4EE:150E55:10C209F:10FDE7D:6A4D552E |
| html-safe-nonce | 368217a1dc8504487011c0b0f852a1155b34ed77f40c48a79ce0f688dcab4ac9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNEVFOjE1MEU1NToxMEMyMDlGOjEwRkRFN0Q6NkE0RDU1MkUiLCJ2aXNpdG9yX2lkIjoiMzQ5MjIxNDM0Njg0MTY3NDcxIiwicmVnaW9uX2VkZ2UiOiJzZWEiLCJyZWdpb25fcmVuZGVyIjoic2VhIn0= |
| visitor-hmac | 63be6561ecbb4c924dcbe139430d0f6b1821d7944ee3cce28c6c2f7da9af1f54 |
| hovercard-subject-tag | issue:1625859125 |
| github-keyboard-shortcuts | repository,issues,actions,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/actions/setup-python/627/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d313737a1a61c07301696dbb43be6b36fff9fb7cdd112eabd3a7e0879b47f914/actions/setup-python/issues/627 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d313737a1a61c07301696dbb43be6b36fff9fb7cdd112eabd3a7e0879b47f914/actions/setup-python/issues/627 |
| og:image:alt | Description: When restoring cache, the current cache management system only uses the primary cache key. GitHub Actions cache allows specifying multiple prefixes, and restoring older caches, to spee... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | toadjaune |
| hostname | github.com |
| expected-hostname | github.com |
| None | 92571a8944142227b7e19cd10918b1ddd06e5066c1ad5bc7e4769cf6140a87e6 |
| turbo-cache-control | no-preview |
| go-import | github.com/actions/setup-python git https://github.com/actions/setup-python.git |
| octolytics-dimension-user_id | 44036562 |
| octolytics-dimension-user_login | actions |
| octolytics-dimension-repository_id | 192625525 |
| octolytics-dimension-repository_nwo | actions/setup-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 192625525 |
| octolytics-dimension-repository_network_root_nwo | actions/setup-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 56fc8347865a14e2ec811533d68f929cf4e0ec19 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width