Fix slow CI/CD runs for Python 3.10#672
Merged
juhoinkinen merged 12 commits intomasterfrom Feb 13, 2023
Merged
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. |
Member
Author
|
Back to draft, there should be a better way to fix this. |
f6cffa3 to
39c46ea
Compare
Member
Author
|
Force-pushed to drop very many unsuccessful commits trying to make caching step conditional, with lines like |
|
Kudos, SonarCloud Quality Gate passed! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








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-lintvs.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 plainkeyis 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.ymlfile.