Prepare Go GitHub action#10709
Conversation
| # 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 |
There was a problem hiding this comment.
This was the reason for of the change
addd5dd to
a78e947
Compare
| 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- |
There was a problem hiding this comment.
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 }} |
There was a problem hiding this comment.
Drive-by improvement; key cache to include Go version, too. A stale cache with an old version is useless.
517cec8 to
0d2ccf9
Compare
| 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 |
There was a problem hiding this comment.
Drive-by improvement; save some seconds by caching the .bin folder
0d2ccf9 to
65081e2
Compare
| echo "gocache=$(go env GOCACHE)" >> "$GITHUB_OUTPUT" | ||
| echo "gomodcache=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT" |
There was a problem hiding this comment.
No longer hard-coded
| # 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) |
There was a problem hiding this comment.
COMPILED_TEST_ARGS ensures that the cache this produces matches what the functional tests need; otherwise there's a cache mismatch
09d8f9e to
a0789aa
Compare
a0789aa to
d92297e
Compare
What changed?
Added an explicit
go downloadstep with retry.Extracted a new GitHub action for the "setup Go" steps across test jobs; to reduce duplication.
Why?
Sometimes the
go downloadfails and could be retried: https://github.com/temporalio/temporal/actions/runs/27560870829/job/81473394249?pr=9160Also; pre-build is now faster.
It is usually 1-2min.