Closed dambem closed 1 year ago
Hi @dambem, I did some investigation on your issue, and I believe the root cause is that this is a bug in aws-sam-cli
. In your workflow file, you're using path: .aws-sam/cache
.
- name: Cache SAM dependencies
id: cache
uses: actions/cache@v3.2.4
with:
path: |
.aws-sam/cache
key: ${{ runner.os }}-SAM_BUILD-${{hashFiles('**/requirements.txt')}}
In my testing, I noticed that the cache
folder is empty and that's why when you load the cache, it's saying it's invalid. I can confirm that this happens in both GitHub Actions and locally.
Workaround:
The temporary workaround for you to use cache is to use the entire .aws-sam
or .aws-sam/deps
folder. I tested it and it worked in github action, see below screenshot.
Going to cut a ticket to aws-sam-cli
team to look into why .aws-sam/cache
folder is empty. According to SAM CLI documentation, ./aws-sam/cache
is the default cache directory and it is where the cache artifacts are stored.
Ticket cut: https://github.com/aws/aws-sam-cli/issues/6144
I'm going to mark this issue as closed and monitor the aws-sam-cli
ticket to learn more on why the cache
folder is empty. Feel free to create an new issue or re-open this issue if you have any additional problems.
Just tested this morning and can confirm it works, thank you for looking into it!
Issue
When using
setup-sam@v2
alongsideactions/cache@v3.2.4', despite the
.aws-sam/cache` directory succefully being stored by the github cache, the following response is always given:Cache is invalid, running build and copying resources for following functions
This appears to have something to do with the way the cache is being stored, leading to the cache being unable to be accessed.
As a recreateable example, the following action showcases a succesful cache store of
.aws-sam/cache
with an invalid cache hit.This has also been attempted using the cache created by using
use-installer
andversion
, with a cache invalid response returned.Proposal
I'd like to request the ability to cache using the
sam build --cached
option, in the same capacity as other dependency caching found Cahing Dependencies to Speed Up Workflows. I'm aware there is SAM CLI caching as found in #73, however, this appears to not be supported by the github runner, and only works for self hosted runners.I'm unsure if this is a bug, or if it's intended that caching is only supported via self-hosted runners, so please let me know any further logs that may be useful for debugging this issue.
Please let me know if i'm using the setup-sam incorrectly to cache, or if there's a different recommended method for doing so.