Skip to content

Commit 6a39634

Browse files
committed
Fix method to read
Made-with: Cursor
1 parent 2543bde commit 6a39634

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

examples/github_actions_gcs.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
name: Run Tests
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
- name: Set up Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: '1.25'
21+
# Use our own cache, obviously.
22+
cache: false
23+
- name: Install gobuildcache
24+
run: go install github.com/richardartoul/gobuildcache@latest
25+
- name: Authenticate to Google Cloud
26+
uses: google-github-actions/auth@v2
27+
with:
28+
credentials_json: ${{ secrets.GCP_SA_KEY }}
29+
- name: Run short tests
30+
env:
31+
GOBUILDCACHE_BACKEND_TYPE: gcs
32+
GOBUILDCACHE_GCS_BUCKET: ${{ secrets.GCS_BUCKET }}
33+
GOBUILDCACHE_GCS_PREFIX: go-build-cache/${{ github.repository }}
34+
GOCACHEPROG: gobuildcache
35+
run: go test ./...

pkg/backends/gcs.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ type GCS struct {
2828
func NewGCS(bucket, prefix string) (*GCS, error) {
2929
ctx := context.Background()
3030

31-
// Create GCS client using Application Default Credentials
32-
// This will use GOOGLE_APPLICATION_CREDENTIALS env var or metadata service
33-
client, err := storage.NewClient(ctx)
31+
// Create GCS client using Application Default Credentials.
32+
// WithJSONReads forces the JSON API for downloads (default is XML).
33+
// This is required for GCS Anywhere Cache compatibility.
34+
client, err := storage.NewClient(ctx, storage.WithJSONReads())
3435
if err != nil {
3536
return nil, fmt.Errorf("failed to create GCS client: %w", err)
3637
}

0 commit comments

Comments
 (0)