From 52096627b95b6004a9de206c1cfac2744638dc2a Mon Sep 17 00:00:00 2001 From: Charles Treatman Date: Mon, 13 May 2024 11:08:45 -0500 Subject: [PATCH] chore: upgrade to Go 1.22 --- .github/workflows/golangci-lint.yml | 13 +++++---- Makefile | 24 ++++----------- go.mod | 2 +- hack/go_install.sh | 45 ----------------------------- 4 files changed, 15 insertions(+), 69 deletions(-) delete mode 100755 hack/go_install.sh diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 188b3a57..8c83925a 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -16,15 +16,18 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v5 - with: - go-version: 1.19 - uses: actions/checkout@v4 + - name: Determine golangci-lint version + id: golangcilint + run: | + line=$(grep -i GOLANGCI_LINT_VERSION Makefile) + version=$(echo ${line} | cut -d = -f2) + echo "version=$version" >> "$GITHUB_OUTPUT" - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - version: v1.49 + version: ${{ steps.golangcilint.outputs.version }} # Optional: working directory, useful for monorepos # working-directory: somedir @@ -43,4 +46,4 @@ jobs: # skip-pkg-cache: true # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. - # skip-build-cache: true \ No newline at end of file + # skip-build-cache: true diff --git a/Makefile b/Makefile index b6662b59..5b18da55 100644 --- a/Makefile +++ b/Makefile @@ -20,15 +20,12 @@ PLATFORMS?=darwin linux windows freebsd ARCHITECTURES?=amd64 arm64 GOBIN?=$(shell go env GOPATH)/bin FORMATTER?=$(GOBIN)/goimports -GO_INSTALL = ./hack/go_install.sh -TOOLS_DIR := hack/tools -TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/bin) - -# Binaries. -GOLANGCI_LINT_VER := v1.49 -GOLANGCI_LINT_BIN := golangci-lint -GOLANGCI_LINT := $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER) +CRI=docker +CRI_COMMAND_BASE=${CRI} run --rm -u ${CURRENT_UID}:${CURRENT_GID} $(DOCKER_EXTRA_ARGS) +GOLANGCI_LINT_VERSION=v1.56 +GOLANGCI_LINT_IMAGE=golangci/golangci-lint:${GOLANGCI_LINT_VERSION} +GOLANGCI_LINT=${CRI_COMMAND_BASE} -v $(CURDIR):/app -w /app -e GOLANGCI_LINT_CACHE=/tmp/.cache -e GOCACHE=/tmp/.cache ${GOLANGCI_LINT_IMAGE} golangci-lint # Setup linker flags option for build that interoperate with variable names in src code LDFLAGS?=-ldflags "-X $(PACKAGE_NAME)/cmd.Version=$(VERSION) -X $(PACKAGE_NAME)/cmd.Build=$(BUILD)" @@ -42,7 +39,7 @@ fmt: $(FORMATTER) $(FORMATTER): go get golang.org/x/tools/cmd/goimports -lint: $(GOLANGCI_LINT) ## Lint codebase +lint: ## Lint codebase $(GOLANGCI_LINT) run -v --fast=false build: @@ -69,12 +66,3 @@ generate-docs: clean-docs test: go test -v ./... -timeout 1000s - - -## -------------------------------------- -## Tooling Binaries -## -------------------------------------- - -$(GOLANGCI_LINT): ## Build golangci-lint from tools folder. - GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER) -golangci-lint: $(LINTER) diff --git a/go.mod b/go.mod index f7151f67..385c3490 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/equinix/metal-cli -go 1.19 +go 1.22 require ( github.com/equinix/equinix-sdk-go v0.35.0 diff --git a/hack/go_install.sh b/hack/go_install.sh deleted file mode 100755 index 94005784..00000000 --- a/hack/go_install.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2020 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -o errexit -set -o nounset -set -o pipefail - -if [ -z "${1}" ]; then - echo "must provide module as first parameter" - exit 1 -fi - -if [ -z "${2}" ]; then - echo "must provide binary name as second parameter" - exit 1 -fi - -if [ -z "${3}" ]; then - echo "must provide version as third parameter" - exit 1 -fi - -if [ -z "${GOBIN}" ]; then - echo "GOBIN is not set. Must set GOBIN to install the bin in a specified directory." - exit 1 -fi - -rm "${GOBIN}/${2}"* || true - -# install the golang module specified as the first argument -go install -tags tools "${1}@${3}" -mv "${GOBIN}/${2}" "${GOBIN}/${2}-${3}" -ln -sf "${GOBIN}/${2}-${3}" "${GOBIN}/${2}" \ No newline at end of file