e-square-io / nx-github-actions

A set of Github Actions for NX workspaces
MIT License
30 stars 6 forks source link

[BUG] cache doesnt work correctly for PRs #19

Closed ronnetzer closed 2 years ago

ronnetzer commented 2 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

When using the actions in a PR, a cache key is created for the first commit in that PR, subsequent commits wont get cached. Also cache is only requested once, for the entire runner and it contains the entire nx cache.

Expected behavior

cache key should include the hash of the task (the same hash that is used for the cache management in nx), which will invalidate the cache when the task or the deps have changed. we should use nx's hasher in order to calculate the hash of a task, and the cache should be splitted to be per task, with the following structure nx-cache-{PLATFORM}-{LOCKFILE_HASH}-{TASK_HASH}-{PR_REF} Instead of caching the entire nx cache directory once, we should cache each task separately, with its own cache key.

After this change we can expect to see the ReserveCacheError for the first run of the workflow because of duplicate tasks in different distributions