lervag/apy

GitHub actions issue with caching?

Closed this issue · 6 comments

lervag commented

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 commented

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 commented

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.

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 commented

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 commented

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

I believe it is safe to close this issue.