-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add cache warm and cache evict workflows #2944
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments!
I felt the shell script inside the yaml was way too obtuse, so I moved it to a node.js script. (Made it with no dependencies and using the preinstalled Node version in I made a dry-run at https://github.com/wasp-lang/wasp/actions/runs/16296955021/job/46021046403?pr=2944 @infomiho recheck pls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some suggestions
scripts/cache-evict.mjs
Outdated
const lsRemoteOutput = listRemoteRefs(githubRepository); | ||
|
||
// Find refs that have caches but do not exist in the remote repository anymore. | ||
const remoteRefs = new Set(lsRemoteOutput.map(([, ref]) => ref)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not do the mapping in the listRemoteRefs
?
scripts/cache-evict.mjs
Outdated
); | ||
console.log(`Found ${cachesToDelete.length} caches to delete`); | ||
|
||
// Delete those cache keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant comment
scripts/cache-evict.mjs
Outdated
const ghCachesOutput = listGitHubCaches(); | ||
const lsRemoteOutput = listRemoteRefs(githubRepository); | ||
|
||
// Find refs that have caches but do not exist in the remote repository anymore. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is probably above the wrong line, and maybe it's even redundant since it's clear from the code that you are finding caches that are not in the remote refs.
scripts/cache-evict.mjs
Outdated
for (const { key, ref } of cachesToDelete) { | ||
try { | ||
console.group(`Deleting cache "${key}" for ref "${ref}"`); | ||
runCmd("gh", ["cache", "delete", key], { collectStdout: false }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd maybe even extract this into a function e.g. deleteGithubCache
to make it cleaner.
scripts/cache-evict.mjs
Outdated
// We use `git ls-remote` so we also receive refs such as `refs/pull/123/head` | ||
// which are not downloaded by `git fetch` or `git pull`. | ||
// | ||
// According to https://git-scm.com/docs/git-ls-remote, the output is: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This format comment could go into parseTabSeparatedLines
function if we rename the function to handle the remote refs format specifically. See the comment: https://github.com/wasp-lang/wasp/pull/2944/files#r2212842477
scripts/cache-evict.mjs
Outdated
} | ||
|
||
function listRemoteRefs(githubRepository) { | ||
const lsRemoteOutput = /** @type {[objectId: string, ref: string][]} */ ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this is not the lsRemoteOutput
but the parsed output, maybe a better name would be remoteRefs
since that's what you function says it lists.
scripts/cache-evict.mjs
Outdated
}); | ||
} | ||
|
||
function parseTabSeparatedLines(/** @type {string} */ str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be specific here since the script is quite specific, name this helper parse git remotes output
and put the explainer comment on top.
You can even make the output not be [str1, str2]
but provide names for the values you already have names for in the format <oid> TAB <ref> LF
-> { oid, ref }
. I'm not sure what oid
is in this case, maybe the name can reflect that.
@infomiho ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful
Resolves #2919
Context:
main
. They can't be shared the opposite direction, nor between any other branches. (docs)Therefore:
main
branch is never stale and never at risk of being evicted. An evictedmain
cache means un-cached runs for all the PRs.main
's)This PR:
Adds two new workflows:
main
caches are warm, by runningwaspc-ci
andwaspc-build