Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 15 commits intomainfromcj/cache-embedded-postgres
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from2 commits
Commits
Show all changes
15 commits
Select commitHold shift + click to select a range
f38ff28
ci: cache embedded postgres downloaded binaries
johnstcnJun 20, 2025
dc585db
log.fatal errors instead of panic
johnstcnJun 20, 2025
f66007c
use step output for cache path
johnstcnJun 20, 2025
8cfd0ff
Merge remote-tracking branch 'origin/cj/cache-embedded-postgres' into…
johnstcnJun 20, 2025
0196ab6
praise log
johnstcnJun 20, 2025
0e5366c
testing
johnstcnJun 23, 2025
3d3aaaa
fix path
johnstcnJun 23, 2025
d268942
use EMBEDDED_PG_CACHE_DIR
johnstcnJun 24, 2025
e6a7997
make embedded-pg less panicky
johnstcnJun 24, 2025
4a27039
troubleshoot cache dir
johnstcnJun 24, 2025
4c4f5e1
maybe this???
johnstcnJun 24, 2025
9ec2b1b
fix upload cache destination
johnstcnJun 24, 2025
1554d6b
also show file modtime
johnstcnJun 24, 2025
5b81b29
i heart actionlint
johnstcnJun 24, 2025
4d69612
ok this should work now
johnstcnJun 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions.github/actions/embedded-pg-cache/action.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
name: "Upload Embedded Postgres Cache"
description: Uploads the embedded Postgres cache. This only runs on the main branch.
inputs:
cache-key:
description: "Cache key"
required: true
cache-path:
description: "Path to the cache directory"
required: true
runs:
using: "composite"
steps:
- name: Upload Embedded Postgres cache
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ${{ inputs.cache-path }}
key: ${{ inputs.cache-key }}
12 changes: 10 additions & 2 deletions.github/workflows/ci.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -497,12 +497,14 @@ jobs:
# Create a temp dir on the R: ramdisk drive for Windows. The default
# C: drive is extremely slow: https://github.com/actions/runner-images/issues/8755
mkdir -p "R:/temp/embedded-pg"
go run scripts/embedded-pg/main.go -path "R:/temp/embedded-pg"
mkdir -p "C:/temp/embedded-pg-cache"
go run scripts/embedded-pg/main.go -path "R:/temp/embedded-pg" -cache "C:/temp/embedded-pg-cache"
elif [ "${{ runner.os }}" == "macOS" ]; then
# Postgres runs faster on a ramdisk on macOS too
mkdir -p /tmp/tmpfs
mkdir -p /tmp/embedded-pg-cache
sudo mount_tmpfs -o noowners -s 8g /tmp/tmpfs
go run scripts/embedded-pg/main.go -path /tmp/tmpfs/embedded-pg
go run scripts/embedded-pg/main.go -path /tmp/tmpfs/embedded-pg -cache /tmp/embedded-pg-cache
elif [ "${{ runner.os }}" == "Linux" ]; then
make test-postgres-docker
fi
Expand DownExpand Up@@ -571,6 +573,12 @@ jobs:
with:
cache-key: ${{ steps.download-cache.outputs.cache-key }}

- name: Upload Embedded Postgres Cache
uses: ./.github/actions/embedded-pg-cache
with:
cache-key: ${{ steps.download-cache.outputs.cache-key }}
cache-path: ${{ runner.os == 'Windows' ? 'C:/temp/embedded-pg-cache' : '/tmp/embedded-pg-cache' }}

- name: Upload test stats to Datadog
timeout-minutes: 1
continue-on-error: true
Expand Down
14 changes: 12 additions & 2 deletionsscripts/embedded-pg/main.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,23 +12,33 @@ import (

func main() {
var customPath string
var cachePath string
flag.StringVar(&customPath, "path", "", "Optional custom path for postgres data directory")
flag.StringVar(&cachePath, "cache", "", "Optional custom path for embedded postgres binaries")
flag.Parse()

postgresPath := filepath.Join(os.TempDir(), "coder-test-postgres")
if customPath != "" {
postgresPath = customPath
}
if err := os.MkdirAll(postgresPath, os.ModePerm); err != nil {
log.Fatalf("Failed to create directory %s: %v", postgresPath, err)
}
if cachePath == "" {
cachePath = filepath.Join(postgresPath, "cache")
}
if err := os.MkdirAll(cachePath, os.ModePerm); err != nil {
log.Fatalf("Failed to create directory %s: %v", cachePath, err)
}

ep := embeddedpostgres.NewDatabase(
embeddedpostgres.DefaultConfig().
Version(embeddedpostgres.V16).
BinariesPath(filepath.Join(postgresPath, "bin")).
// Default BinaryRepositoryURL repo1.maven.org is flaky.
BinaryRepositoryURL("https://repo.maven.apache.org/maven2").
DataPath(filepath.Join(postgresPath, "data")).
RuntimePath(filepath.Join(postgresPath, "runtime")).
CachePath(filepath.Join(postgresPath, "cache")).
CachePath(cachePath).
Username("postgres").
Password("postgres").
Database("postgres").
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp