-
Notifications
You must be signed in to change notification settings - Fork 925
ci: cache embedded postgres downloaded binaries #18477
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
base: main
Are you sure you want to change the base?
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.
Pull Request Overview
This PR adds support for caching downloaded Embedded Postgres binaries by introducing a --cache
flag in the helper script, updating CI workflows to populate and persist that cache across runs, and providing a composite action to upload the cache on main
.
- Introduce
cachePath
flag and default directory logic inmain.go
- Update CI steps to create cache directories and pass
-cache
to the script - Add
embedded-pg-cache
composite action for persisting the cache
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
scripts/embedded-pg/main.go | Added --cache flag, default cache directory, and MkdirAll |
.github/workflows/ci.yaml | Created cache dirs, passed -cache flag, and invoked upload |
.github/actions/embedded-pg-cache/action.yml | New composite action to save the cache via actions/cache |
Comments suppressed due to low confidence (5)
scripts/embedded-pg/main.go:17
- The new
--cache
flag should be documented in the project README or script usage section to ensure users know how to leverage caching.
flag.StringVar(&cachePath, "cache", "", "Optional custom path for embedded postgres binaries")
.github/workflows/ci.yaml:500
- [nitpick] This Windows-specific path is duplicated later; consider defining a variable for the cache path to reduce duplication and ease future updates.
mkdir -p "C:/temp/embedded-pg-cache"
.github/workflows/ci.yaml:500
mkdir -p
may not be available on Windows runners by default; ensure the shell supports this or use a PowerShell-native command likeNew-Item -ItemType Directory -Force
.
mkdir -p "C:/temp/embedded-pg-cache"
scripts/embedded-pg/main.go:27
- New fallback logic for
cachePath
isn't covered by existing tests; consider adding an integration test to verify caching behavior is applied correctly.
if cachePath == "" {
.github/actions/embedded-pg-cache/action.yml:15
- [nitpick] Pinning to a specific commit SHA can make upgrades harder; consider using the official version tag (
actions/cache@v4
) instead of a commit hash.
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
Co-authored-by: Copilot <[email protected]>
shell: bash | ||
run: | | ||
set -e | ||
mkdir -p "$EMBEDDED_PG_CACHE_DIR" |
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 ends up being C:\actions-runner\_temp\embedded-pg-cache
// Troubleshooting: list files in cachePath | ||
if err := filepath.Walk(cachePath, func(path string, info os.FileInfo, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
switch { | ||
case info.IsDir(): | ||
log.Printf("D: %s", path) | ||
case info.Mode().IsRegular(): | ||
log.Printf("F: %s [%s] (%d bytes) %s", path, info.Mode().String(), info.Size(), info.ModTime().Format(time.RFC3339)) | ||
default: | ||
log.Printf("Other: %s [%s] %s", path, info.Mode(), info.ModTime().Format(time.RFC3339)) | ||
} | ||
return nil | ||
}); err != nil { | ||
log.Printf("Failed to list files in cachePath %s: %v", cachePath, err) |
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.
review: I think it makes sense to leave this in; I found it useful for troubleshooting before I knew about the wush trick.
Fixes coder/internal#567
Embedded Postgres downloads binaries from
${REPO}/io/zonky/test/postgres/embedded-postgres-binaries-$OS-$ARCH/$VERSION/embedded-postgres-binaries-$OS-$ARCH-$VERSION.jar
toCachePath
:Example link for Darwin arm64: https://repo.maven.apache.org/maven2/io/zonky/test/postgres/embedded-postgres-binaries-darwin-arm64v8/16.4.0/
Making this a variable and adding it to be cached on merge to main.
Successful runs: