SplittyDev / spacebadgers

Fast and clean SVG badges
https://badgers.space
MIT License
253 stars 3 forks source link

Incorrect GitHub Actions result #26

Closed rossmacarthur closed 7 months ago

rossmacarthur commented 1 year ago

I've been having some issues with this although I'm struggling to identify what the main issue is.

Currently happening right now on my sheldon repository. I'm using the following to generate a badge for the trunk branch:

https://badgers.space/github/checks/rossmacarthur/sheldon/trunk?label=build

The latest build for the trunk branch is passing but the badge still shows an error. I have also observed the reverse, where there is an error but it is showing success.

Edit this is strange, there is a failing build but it doesn't show on the commit because the same commit is on another branch where the same build succeeded with the same commit.

SplittyDev commented 1 year ago

Hey Ross, I've also observed this, and I'm not quite sure why it's happening. For me, the issue corrected itself after some time, but it took a lot longer than it should've. I'm guessing this is a caching issue, but I can't quite put my finger on it.

Caching in SpaceBadgers is a bit unconventional, since we have three interlocking parts here:

There might even be another layer of caching done by GitHub, and I'm not sure how that affects things, but I've noticed a few times now that images with a fixed URL within a markdown file don't refresh immediately when the image changes.

Maybe the solution here is to completely disable caching in the worker and send out responses with a cache-control of something like max-age=300, must-revalidate, since the worker can process a lot of images very fast and shouldn't really have to enforce any caching in the first place..

I'm a bit unsure how exactly Vercel's edge cache works though, since I've already tried disabling caching for certain routes and it doesn't seem to have the effect I expected it to have.

SplittyDev commented 1 year ago

I've just tried invalidating the browser cache by appending &x=1 to your badge URL, and since that doesn't resolve the issue, I'm now quite sure that it's not the browser cache. My suspicion falls on Vercel Edge cache.

SplittyDev commented 1 year ago

I just updated cache-controls in the worker, but that doesn't seem to resolve it. I checked the code in the NextJS app again, and cache-control headers are forwarded 1:1 from the worker, which seems to work just fine, looking at the response headers in devtools.

This is really weird, either Edge Cache is doing some really strange stuff, or the API actually fetches the wrong build status from GitHub.

rossmacarthur commented 7 months ago

Tentatively going to close this since I haven't seen it happen again, quite possibly was a GitHub thing