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

GitHub actions issue with caching? #61

Closed
lervag opened this issue Jun 6, 2023 · 6 comments
Closed

GitHub actions issue with caching? #61

lervag opened this issue Jun 6, 2023 · 6 comments

Comments

@lervag
Copy link
Owner

lervag commented Jun 6, 2023

After #59 was merged the GitHub actions step fails due to missing dependency of mypy:

image

I believe this is because of this part:

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

But I'm not sure exactly what's wrong. I hope @ckp95 or @denismaciel would be able to help me here?

lervag added a commit that referenced this issue Jun 6, 2023
lervag added a commit that referenced this issue Jun 6, 2023
@lervag
Copy link
Owner Author

lervag commented Jun 6, 2023

I believe there is a problem with the hash key. From the CICD log, we see that the key is venv-Linux-, i.e. the ${{ hashFiles('**/poetry.lock') }} seems to return an empty string. I assume this is the part that should account for changes to the dependencies in pyproject.toml? Things work again now after I change the key, but I assume that it did not really fix the problem.

@ckp95
Copy link
Contributor

ckp95 commented Jun 6, 2023

https://github.com/actions/setup-python#caching-packages-dependencies

The action defaults to searching for a dependency file (requirements.txt or pyproject.toml for pip, Pipfile.lock for pipenv or poetry.lock for poetry) in the repository, and uses its hash as a part of the cache key. Input cache-dependency-path is used for cases when multiple dependency files are used, they are located in different subdirectories or different files for the hash that want to be used.

we don't commit the poetry.lock file so that might be it. we can either change the CI script to check for a changed pyproject.toml, or commit the lockfile.

I didn't commit the lockfile at first because I thought it wouldn't matter, but I have no strong opinion about it.

@denismaciel
Copy link
Contributor

Yeah, I think @ckp95 is right.

From poetry docs... I think apy falls in the application bucket, so I'd vote for committing the lock file.

@lervag
Copy link
Owner Author

lervag commented Jun 7, 2023

we don't commit the poetry.lock file so that might be it. we can either change the CI script to check for a changed pyproject.toml, or commit the lockfile.

Yes, that sounds correct. I'm pushing the lockfile now, I think it makes sense for applications to have the lockfile as part of the repo.

@lervag
Copy link
Owner Author

lervag commented Jun 7, 2023

The relevant pipeline after adding the lock file: https://github.com/lervag/apy/actions/runs/5197352890.

@lervag
Copy link
Owner Author

lervag commented Nov 15, 2023

I believe it is safe to close this issue.

@lervag lervag closed this as completed Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants