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

fix: saveCache shouldn't error on existing cache, warn instead #40

Merged
merged 2 commits into from
Aug 14, 2020

Conversation

agilgur5
Copy link
Contributor

@agilgur5 agilgur5 commented Aug 14, 2020

Description

Commits

hotfix: saveCache shouldn't error on existing cache, warn instead

  • if your workflow has a race condition where similar jobs with the same
    cache key run in parallel, one will saveCache first and the next will
    error out when trying to saveCache
    • previously this was a warning, but after upgrading to official
      @actions/cache, it is now an error
    • this can occur on matrix installs with similar enough environments
      (e.g. different Node version, same OS) and did occur in workflows
      here too actually
      • there's an upstream issue tracking this, so it might actually have
        a different root cause

ci: also run all workflows on PRs to ensure they pass

  • previously only ran on push, meaning only for root repo branches,
    and not PRs from forks
    • meaning they could be failing unknowingly and it would only be seen
      after merge
      • as happened with my previous PR
    • this should make it run on PRs from forks as well, so failed CI
      checks should be very visible
      • (but branch protection needs to be turned on to prevent merging)

Tags

Fixes #39 , workaround for upstream actions/cache#144
Follow-up to bug introduced by #37

Adding PR check to CI pretty much identical to jaredpalmer/tsdx#373

Review Notes

#37 passed the CI check / self-integration test matrix I added in my fork and I believe it passed here too (says 0 checks now though, possibly due to the patch bump added there), but when it was merged here it then failed. Since then has caused many failures downstream per #39, which I too experienced

EDIT: nope, CI checks didn't run here as they weren't turned on for PRs, so I've added that to all CI checks now as a second commit in this PR

Testing

Screenshot differences in CI

Before on master:

Screen Shot 2020-08-14 at 2 29 22 AM

After on cache-busted version of current PR:

Screen Shot 2020-08-14 at 2 43 05 AM

While the same error is printed as I console.warn'd it, it no longer throws and therefore doesn't fail the job

It also passes on current PR, but these were all cache hits, probably because I was testing on this branch before.
As far as I understand, there is no way to force cache bust without changing the key in GitHub Actions right now (no API for it to be exact), which makes integration testing cache misses a bit difficult. If we were to add actual integration tests as opposed to this "self-CI integration test" as I've done here then we could randomize cache key there to force a cache miss

- if your workflow has a race condition where similar jobs with the same
  cache key run in parallel, one will saveCache first and the next will
  error out when trying to saveCache
  - previously this was a warning, but after upgrading to official
    @actions/cache, it is now an error
  - this can occur on matrix installs with similar enough environments
    (e.g. different Node version, same OS) and did occur in workflows
    here too actually
    - there's an upstream issue tracking this, so it might actually have
      a different root cause
- previously only ran on `push`, meaning only for root repo branches,
  and not PRs from forks
  - meaning they could be failing unknowingly and it would only be seen
    _after_ merge
    - as happened with my previous PR
  - this should make it run on PRs from forks as well, so failed CI
    checks should be very visible
    - (but branch protection needs to be turned on to prevent merging)
Copy link
Owner

@bahmutov bahmutov left a comment

Choose a reason for hiding this comment

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

nice, love it

@bahmutov bahmutov changed the title hotfix: saveCache shouldn't error on existing cache, warn instead fix: saveCache shouldn't error on existing cache, warn instead Aug 14, 2020
@bahmutov bahmutov merged commit 39a1dfc into bahmutov:master Aug 14, 2020
@github-actions
Copy link

🎉 This PR is included in version 1.4.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when installing packages
2 participants