-
Notifications
You must be signed in to change notification settings - Fork 42
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
Fix slow CI/CD runs for Python 3.10 #672
Conversation
To avoid reserved cache key error
Codecov ReportBase: 99.56% // Head: 99.56% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #672 +/- ##
=======================================
Coverage 99.56% 99.56%
=======================================
Files 87 87
Lines 6145 6158 +13
=======================================
+ Hits 6118 6131 +13
Misses 27 27
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Back to draft, there should be a better way to fix this. |
f6cffa3
to
39c46ea
Compare
Force-pushed to drop very many unsuccessful commits trying to make caching step conditional, with lines like
|
Kudos, SonarCloud Quality Gate passed! |
Lately the Python 3.10 test CI/CD jobs have been slow (~7 mins), because the Python dependencies have not been available from cache. First occurrence is in the CI/CD job #308, however it seems that the reason for the slow-down is introducing the linting job in PR #656, because this job has shared the cache keys with the Python 3.10 test job. This has prevented (re)creating/updating the cache by the test job (with the necessary optional dependencies); the "Post" steps for setup-python and caching steps in the test jobs have had errors like:
To avoid this in the caching step the cache key is appended with-${{ github.job }}
so the keys are now clearly different in lint and test jobs (poetry-installation-and-repos-3.10.8-1.2.0-lint
vs.poetry-installation-and-repos-3.10-1.2.0-test
). In the setup-python action the key cannot be specified, so the fix (for now) is to to pin the Python version to 3.10.8 in the linting job, but in the test job to more relaxed 3.10, which makes the keys different by the patch version (setup-python-Linux-python-3.10.8-poetry-<hash>
vs.setup-python-Linux-python-3.10.9-poetry-<hash>
).Now restoring and saving cache is more controlled by using separate cache/restore and cache/save actions: restoring is performed before every job, but saving only after the test jobs that have various optional dependencies installed.
Also now the cache should be updated/recreated if some dependency has been updated, as the cache key includes hash of the
poetry.lock
. The cache restoration is based on "closest matching" key by usingrestore-keys
(the plainkey
is not used at all).The cache/save step is conditional: it is skipped if there are no changes in dependencies.
To make the workflow setup more manageable, the caching, Poetry install and Python setup steps are gathered in one composite action in
.github/actions/prepare/action.yml
file.