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

Commitf38ff28

Browse files
committed
ci: cache embedded postgres downloaded binaries
1 parent9c1feff commitf38ff28

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name:"Upload Embedded Postgres Cache"
2+
description:Uploads the embedded Postgres cache. This only runs on the main branch.
3+
inputs:
4+
cache-key:
5+
description:"Cache key"
6+
required:true
7+
cache-path:
8+
description:"Path to the cache directory"
9+
required:true
10+
runs:
11+
using:"composite"
12+
steps:
13+
-name:Upload Embedded Postgres cache
14+
if:${{ github.ref == 'refs/heads/main' }}
15+
uses:actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684# v4.2.3
16+
with:
17+
path:${{ inputs.cache-path }}
18+
key:${{ inputs.cache-key }}

‎.github/workflows/ci.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,14 @@ jobs:
497497
# Create a temp dir on the R: ramdisk drive for Windows. The default
498498
# C: drive is extremely slow: https://github.com/actions/runner-images/issues/8755
499499
mkdir -p "R:/temp/embedded-pg"
500-
go run scripts/embedded-pg/main.go -path "R:/temp/embedded-pg"
500+
mkdir -p "C:/temp/embedded-pg-cache"
501+
go run scripts/embedded-pg/main.go -path "R:/temp/embedded-pg" -cache "C:/temp/embedded-pg-cache"
501502
elif [ "${{ runner.os }}" == "macOS" ]; then
502503
# Postgres runs faster on a ramdisk on macOS too
503504
mkdir -p /tmp/tmpfs
505+
mkdir -p /tmp/embedded-pg-cache
504506
sudo mount_tmpfs -o noowners -s 8g /tmp/tmpfs
505-
go run scripts/embedded-pg/main.go -path /tmp/tmpfs/embedded-pg
507+
go run scripts/embedded-pg/main.go -path /tmp/tmpfs/embedded-pg -cache /tmp/embedded-pg-cache
506508
elif [ "${{ runner.os }}" == "Linux" ]; then
507509
make test-postgres-docker
508510
fi
@@ -571,6 +573,12 @@ jobs:
571573
with:
572574
cache-key:${{ steps.download-cache.outputs.cache-key }}
573575

576+
-name:Upload Embedded Postgres Cache
577+
uses:./.github/actions/embedded-pg-cache
578+
with:
579+
cache-key:${{ steps.download-cache.outputs.cache-key }}
580+
cache-path:${{ runner.os == 'Windows' ? 'C:/temp/embedded-pg-cache' : '/tmp/embedded-pg-cache' }}
581+
574582
-name:Upload test stats to Datadog
575583
timeout-minutes:1
576584
continue-on-error:true

‎scripts/embedded-pg/main.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,33 @@ import (
1212

1313
funcmain() {
1414
varcustomPathstring
15+
varcachePathstring
1516
flag.StringVar(&customPath,"path","","Optional custom path for postgres data directory")
17+
flag.StringVar(&cachePath,"cache","","Optional custom path for embedded postgres binaries")
1618
flag.Parse()
1719

1820
postgresPath:=filepath.Join(os.TempDir(),"coder-test-postgres")
1921
ifcustomPath!="" {
2022
postgresPath=customPath
2123
}
24+
iferr:=os.MkdirAll(postgresPath,os.ModePerm);err!=nil {
25+
panic(err)
26+
}
27+
ifcachePath=="" {
28+
cachePath=filepath.Join(postgresPath,"cache")
29+
}
30+
iferr:=os.MkdirAll(cachePath,os.ModePerm);err!=nil {
31+
panic(err)
32+
}
2233

2334
ep:=embeddedpostgres.NewDatabase(
2435
embeddedpostgres.DefaultConfig().
2536
Version(embeddedpostgres.V16).
2637
BinariesPath(filepath.Join(postgresPath,"bin")).
27-
// Default BinaryRepositoryURL repo1.maven.org is flaky.
2838
BinaryRepositoryURL("https://repo.maven.apache.org/maven2").
2939
DataPath(filepath.Join(postgresPath,"data")).
3040
RuntimePath(filepath.Join(postgresPath,"runtime")).
31-
CachePath(filepath.Join(postgresPath,"cache")).
41+
CachePath(cachePath).
3242
Username("postgres").
3343
Password("postgres").
3444
Database("postgres").

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp