-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CI: Set environment cache key based on current week of year to avoid outdated cache in the "Setup Micromamba" step #3234
Conversation
With the latest packages installed, now we can also see the Fiona errors reported in #3180 (comment)
|
Ping @GenericMappingTools/pygmt-maintainers for comments before I apply the same changes to other workflows. |
@@ -58,8 +58,6 @@ jobs: | |||
channels: | |||
- conda-forge | |||
- nodefaults | |||
cache-downloads: false | |||
cache-environment: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow is only scheduled to run weekly. We don't care about the speed of the workflow, so no need to cache the enviroment.
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
Take the latest run of the "Tests" workflow on the main branch as an example. The "Setup Micromamba" step in the "Ubuntu + Python 3.10" job uses the cache with key
micromamba-environment--linux-64-pygmt-args-4fc7725-root-dcc80ee
, which was cached last month as shown here (https://github.com/GenericMappingTools/pygmt/actions/caches).The setup-micromamba action says (https://github.com/mamba-org/setup-micromamba#caching):
And GitHub says (https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy):
So, the cached environment won't be refreshed unless we make changes to the packages listed in the
create-args
argument. We're using outdated packages in our workflows, which explains why sometimes we see old packages installed in CI.The solution is to define the cache key based on the current date.
We can define the cache key like
micromamba-environment-2024-05-07
, which means the cache will expire on the next day so the first CI run on the next day will be slower since the cache is missing. I feel one day is a little too short for PyGMT, so in this PR, the cache key is defined likemicromamba-environment-2024-W19
, in which2024-W19
means the 19th week of 2024. The cache will persist for one week.Patches #2946.