Skip to content

Prepare Go GitHub action#10709

Merged
stephanos merged 2 commits into
mainfrom
stephanos/retry-go-download
Jun 16, 2026
Merged

Prepare Go GitHub action#10709
stephanos merged 2 commits into
mainfrom
stephanos/retry-go-download

Conversation

@stephanos

@stephanos stephanos commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

What changed?

Added an explicit go download step with retry.

Extracted a new GitHub action for the "setup Go" steps across test jobs; to reduce duplication.

Why?

Sometimes the go download fails and could be retried: https://github.com/temporalio/temporal/actions/runs/27560870829/job/81473394249?pr=9160

go: go.opentelemetry.io/otel@v1.43.0: read "https://proxy.golang.org/go.opentelemetry.io/otel/@v/v1.43.0.zip": stream error: stream ID 1335; INTERNAL_ERROR; received from peer
Error: Process completed with exit code 1.

Also; pre-build is now faster.

image

It is usually 1-2min.

# Cache restore can miss modules after go.sum changes or partial cache saves.
# Retrying download here isolates transient Go proxy failures from the Go command.
- name: Download Go modules
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the reason for of the change

@stephanos stephanos force-pushed the stephanos/retry-go-download branch 4 times, most recently from addd5dd to a78e947 Compare June 15, 2026 17:18
path: ~/.cache/go-build
key: go-${{ runner.os }}${{ runner.arch }}-${{ steps.setup-go.outputs.go-version }}-build-${{ env.COMMIT }}
restore-keys: |
go-${{ runner.os }}${{ runner.arch }}-${{ steps.setup-go.outputs.go-version }}-build-

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by improvement; we restore previous cache to increase cache hit likelihood instead of starting from scratch. This is safe in Go as its build outputs are content-addressed.

uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.cache/go-build
key: go-${{ runner.os }}${{ runner.arch }}-${{ steps.setup-go.outputs.go-version }}-build-${{ env.COMMIT }}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by improvement; key cache to include Go version, too. A stale cache with an old version is useless.

@stephanos stephanos force-pushed the stephanos/retry-go-download branch 5 times, most recently from 517cec8 to 0d2ccf9 Compare June 15, 2026 18:14
path: ${{ steps.go-env.outputs.gomodcache }}
key: go-${{ runner.os }}${{ runner.arch }}-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.mod') }}-deps-${{ hashFiles('go.sum') }}

- name: Restore Go tools

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by improvement; save some seconds by caching the .bin folder

@stephanos stephanos force-pushed the stephanos/retry-go-download branch from 0d2ccf9 to 65081e2 Compare June 15, 2026 18:16
@stephanos stephanos changed the title Setup Go action Prepare Go GitHub action Jun 15, 2026
Comment on lines +46 to +47
echo "gocache=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
echo "gomodcache=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer hard-coded

Comment thread Makefile
# This should use the same build flags as functional-test-coverage and functional-test-{xdc,ndc}-coverage for best build caching.
pre-build-functional-test-coverage: prepare-coverage-test
go test -c -cover -o /dev/null $(FUNCTIONAL_TEST_ROOT) $(TEST_ARGS) $(TEST_TAG_FLAG) $(COVERPKG_FLAG)
go test -c -cover -o /dev/null $(COMPILED_TEST_ARGS) $(COVERPKG_FLAG) $(FUNCTIONAL_TEST_ROOT)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

COMPILED_TEST_ARGS ensures that the cache this produces matches what the functional tests need; otherwise there's a cache mismatch

@stephanos stephanos force-pushed the stephanos/retry-go-download branch from 09d8f9e to a0789aa Compare June 15, 2026 19:10
@stephanos stephanos force-pushed the stephanos/retry-go-download branch from a0789aa to d92297e Compare June 15, 2026 19:16
@stephanos stephanos requested review from chaptersix and spkane31 June 15, 2026 19:16
@stephanos stephanos marked this pull request as ready for review June 15, 2026 19:17
@stephanos stephanos requested review from a team as code owners June 15, 2026 19:17
@stephanos stephanos merged commit ff5557b into main Jun 16, 2026
49 checks passed
@stephanos stephanos deleted the stephanos/retry-go-download branch June 16, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants