Skip to content

Commit bedc1f2

Browse files
skitttpantelis
authored andcommitted
Build golangci-lint with the installed Go compiler
golangci-lint fails if the Go environment used to analyse code is newer than the version it was built with. This isn't usually a problem on devel because golangci-lint is updated regularly, but it's the main reason why Go linting jobs fail on release branches: those stay on older versions of golangci-lint that quickly end up older than the Go compiler in the base Shipyard image. This changes the base image construction so that golangci-lint is always built using the installed compiler. Signed-off-by: Stephen Kitt <[email protected]>
1 parent e53ef04 commit bedc1f2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

package/Dockerfile.shipyard-dapper-base

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,12 @@ RUN dnf -y install --nodocs --setopt=install_weak_deps=False \
7777

7878
COPY tools/go.mod /tools.mod
7979

80-
# This layer's versioning is determined by us, and thus could be rebuilt more frequently to test different versions
80+
# This layer's versioning is determined by us,
81+
# and thus could be rebuilt more frequently to test different versions.
82+
# golangci-lint must be built with a version of Go equal to or newer
83+
# than the version used to analyse the code, so this rebuilds it.
8184
RUN LINT_VERSION=$(awk '/golangci-lint/ { print $2 }' /tools.mod) && \
82-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin -d ${LINT_VERSION} && \
85+
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${LINT_VERSION} && \
8386
KIND_VERSION=$(awk '/sigs.k8s.io.kind/ { print $2 }' /tools.mod) && \
8487
curl -Lo /go/bin/kind "https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-${ARCH}" && chmod a+x /go/bin/kind && \
8588
mkdir -p /usr/local/libexec/docker/cli-plugins && \

0 commit comments

Comments
 (0)