Skip to content
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

Use hash of all requirements files in cache keys for ci #6061

Merged
merged 1 commit into from
Apr 13, 2023

Conversation

maffoo
Copy link
Contributor

@maffoo maffoo commented Apr 12, 2023

I ran into some strange CI failures while trying to update mypy in #6059 and tracked them down to a bad cache of python dependencies. While looking at this I realized that the way we compute a cache key for python dependencies in CI is broken, since it doesn't actually take all requirements files into account.

@CirqBot CirqBot added the size: S 10< lines changed <50 label Apr 12, 2023
@maffoo maffoo marked this pull request as ready for review April 12, 2023 23:11
@maffoo maffoo requested review from a team, vtomole and cduck as code owners April 12, 2023 23:11
@maffoo maffoo requested a review from verult April 12, 2023 23:11
@maffoo maffoo mentioned this pull request Apr 12, 2023
@@ -280,7 +280,7 @@ jobs:
- uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('dev-requirements.txt') }}
key: ${{ env.pythonLocation }}-${{ hashFiles('**/requirements.txt', 'dev_tools/requirements/**/*.txt') }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, the key was sensitive to setup.py, too. Should we keep that? It seems to me safer to do so.

Also, if you agree we should keep sensitivity to setup.py, then it might be prudent to broaden it to all setup.py files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's necessary since we don't install any of the cirq modules themselves in ci, we just run tests from the checked out cirq source. This may have come from very early days when we declared some dependencies in setup.py itself, but we stopped doing that probably even before we got rid of dev-requirements.txt.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, the cached content is for the Python environment content after pip install -r some/requirement.txt
We don't install cirq as check/pytest works directly with repository sources.

If so, we should not hash setup.py as it is not used in the CI run.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM!

@maffoo maffoo merged commit 6a5b3ea into master Apr 13, 2023
@maffoo maffoo deleted the u/maffoo/cache-key branch April 13, 2023 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: S 10< lines changed <50
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants