Skip to content

Commit

Permalink
ci: Set Go version consistently via .go-version
Browse files Browse the repository at this point in the history
Ensure Go version is determined consistently for CI and Docker builds
rather than spread across several different files.

The intent is to eventually replace this with use of the `toolchain`
directive in Go 1.21.

c.f. hashicorp/consul#20058
  • Loading branch information
zalimeni committed Jan 5, 2024
1 parent dc307e1 commit 1839bb7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 14 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,7 @@ jobs:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
# pinning this to 1.20.5 because this issue in go-testcontainers occurs
# in 1.20.6 with the error "http: invalid Host header, host port waiting failed"
# https://github.com/testcontainers/testcontainers-go/issues/1359
# remove setting this when the above issue is fixed so that the job will
# just get the go version from .go-version.
go-version: 1.20.5
go-version: ${{ needs.get-go-version.outputs.go-version }}
- id: run-tests
run: cd integration-tests && go test -v -output-dir=./output -dataplane-image=hashicorppreview/${{env.repo}}:${{env.dev_tag}}-${{github.sha}} -server-image=${{matrix.server.image}} -server-version=${{matrix.server.version}}
continue-on-error: true
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/consul-dataplane-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ jobs:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
# pinning this to 1.20.5 because this issue in go-testcontainers occurs
# in 1.20.6 with the error "http: invalid Host header, host port waiting failed"
# https://github.com/testcontainers/testcontainers-go/issues/1359
# remove setting this when the above issue is fixed so that the job will
# just get the go version from .go-version.
go-version: 1.20.5
go-version: ${{ needs.get-go-version.outputs.go-version }}
- run: make docker
# Currently the server version below is set to 1.15-dev: integration-tests/main_test.go
- run: echo "VERSION=$(make version)" >> $GITHUB_ENV
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ FROM debian:bullseye-slim AS setcap-envoy-fips-binary
ARG BIN_NAME=consul-dataplane
ARG TARGETARCH
ARG TARGETOS
ARG GOLANG_VERSION

COPY --from=envoy-fips-binary /usr/local/bin/envoy /usr/local/bin/
COPY dist/$TARGETOS/$TARGETARCH/$BIN_NAME /usr/local/bin/
Expand All @@ -43,7 +44,7 @@ RUN setcap CAP_NET_BIND_SERVICE=+ep /usr/local/bin/$BIN_NAME

# go-discover builds the discover binary (which we don't currently publish
# either).
FROM golang:1.20.12-alpine as go-discover
FROM golang:${GOLANG_VERSION}-alpine as go-discover
RUN CGO_ENABLED=0 go install github.com/hashicorp/go-discover/cmd/discover@214571b6a5309addf3db7775f4ee8cf4d264fd5f

# Pull in dumb-init from alpine, as our distroless release image doesn't have a
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ REVISION = $(shell git rev-parse HEAD)

# Docker Stuff.
export DOCKER_BUILDKIT=1
BUILD_ARGS = BIN_NAME=$(BIN_NAME) PRODUCT_VERSION=$(VERSION) PRODUCT_REVISION=$(REVISION)
BUILD_ARGS = BIN_NAME=$(BIN_NAME) PRODUCT_VERSION=$(VERSION) PRODUCT_REVISION=$(REVISION) GOLANG_VERSION=$(GOLANG_VERSION)
TAG = $(PRODUCT_NAME):$(VERSION)
BA_FLAGS = $(addprefix --build-arg=,$(BUILD_ARGS))
FLAGS = --target $(TARGET) --platform $(PLATFORM) --tag $(TAG) $(BA_FLAGS)
Expand Down

0 comments on commit 1839bb7

Please sign in to comment.