Skip to content
This repository has been archived by the owner on Nov 16, 2024. It is now read-only.

Use Github actions cache for caching snaphots instead of an external server #302

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Kobzol
Copy link

@Kobzol Kobzol commented Jun 22, 2021

Hi! This action is really useful, however sadly it seems to me that it no longer works, since the external server used to store the computed snapshots seems to be offline. This would probably happen sooner or later with any server, so I tried to create a PR that completely removes the reliance on any external server.

When a push event occurs, a snapshot is computed and then stored into the github actions cache.
When a pull request event occurs, the reference snapshot is:

  1. Restored from cache, if the corresponding cache entry already exists
  2. Or computed from scratch, if it doesn't

Even if there is no cache hit, the reference snapshot recomputation will be usually quite fast, because the crate was already pre-built when the PR snapshot was computed, so typically there will not be too many changes that need to be compiled.

The code currently assumes that the workflow uses the checkout action, which is true for most workflows I suppose.

You can see the modified version in action here.

@alerque
Copy link

alerque commented Sep 22, 2023

I know some time has past (and @orf I saw the abuse from a user you got a few years back) but I'm happy to report that the code from this PR still works. Notably the existing version(s) are currently broken because of #403 and this caching mechanism fixes that an the action works as expected. I would recommend it for merging and a new release be tagged.

@Kobzol
Copy link
Author

Kobzol commented Sep 22, 2023

Well, this works, but it's not really ideal, security wise. pull_request_target is prone to cache poisoning, and GitHub kind of acts like this issue doesn't exist :/ It's sad that safely writing to cache (or even posting a PR comment) from a PR coming from a fork is so complicated on GitHub.

@Kobzol
Copy link
Author

Kobzol commented Sep 22, 2023

I think that a better solution is to avoid any cache at all, and just compile the baseline commit and the PR commit each time, and then display the difference. This still leaves the problem with posting comments on PRs from forks though. I think that these sorts of actions would be better implemented as GitHub apps.

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

Successfully merging this pull request may close these issues.

2 participants