Skip to content

Commit 39e7a8a

Browse files
committed
pin GOLANGCI_LINT
1 parent 7515f32 commit 39e7a8a

File tree

3 files changed

+66
-7
lines changed

3 files changed

+66
-7
lines changed

.github/workflows/golangci-lint.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@ jobs:
1313
go-version: 'stable'
1414
- uses: actions/checkout@v4
1515
- name: golangci-lint
16-
uses: golangci/golangci-lint-action@v6
17-
with:
18-
args: --timeout=5m
16+
run: make lint

Makefile

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
export API_TAGS ?= ExternalClusterAPI,AuthTokenAPI,OperationsAPI,AutoscalerAPI
22
export SWAGGER_LOCATION ?= https://api.cast.ai/v1/spec/openapi.json
33

4+
GO_INSTALL = ./hack/go-install.sh
5+
6+
TOOLS_DIR=bin
7+
ROOT_DIR=$(abspath .)
8+
TOOLS_GOBIN_DIR := $(abspath $(TOOLS_DIR))
9+
10+
GOLANGCI_LINT_VER := v1.62.2
11+
GOLANGCI_LINT_BIN := golangci-lint
12+
GOLANGCI_LINT := $(TOOLS_GOBIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
13+
14+
$(GOLANGCI_LINT):
15+
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)
16+
417
build:
518
CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -o bin/castai-cluster-controller-amd64 .
619
docker build -t us-docker.pkg.dev/castai-hub/library/cluster-controller:$(VERSION) .
@@ -10,12 +23,12 @@ push:
1023

1124
release: build push
1225

13-
lint:
14-
golangci-lint run ./...
26+
lint: $(GOLANGCI_LINT)
27+
$(GOLANGCI_LINT) run --timeout 20m ./...
1528
.PHONY: lint
1629

17-
fix:
18-
golangci-lint run --fix ./...
30+
fix: $(GOLANGCI_LINT)
31+
$(GOLANGCI_LINT) run --fix ./...
1932
.PHONY: fix
2033

2134
test:

hack/go-install.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
3+
# Originally copied from
4+
# https://github.com/kubernetes-sigs/cluster-api-provider-gcp/blob/c26a68b23e9317323d5d37660fe9d29b3d2ff40c/scripts/go_install.sh
5+
6+
set -o errexit
7+
set -o nounset
8+
set -o pipefail
9+
10+
if [[ -z "${1:-}" ]]; then
11+
echo "must provide module as first parameter"
12+
exit 1
13+
fi
14+
15+
if [[ -z "${2:-}" ]]; then
16+
echo "must provide binary name as second parameter"
17+
exit 1
18+
fi
19+
20+
if [[ -z "${3:-}" ]]; then
21+
echo "must provide version as third parameter"
22+
exit 1
23+
fi
24+
25+
if [[ -z "${GOBIN:-}" ]]; then
26+
echo "GOBIN is not set. Must set GOBIN to install the bin in a specified directory."
27+
exit 1
28+
fi
29+
30+
mkdir -p "${GOBIN}"
31+
32+
tmp_dir=$(mktemp -d -t goinstall_XXXXXXXXXX)
33+
function clean {
34+
rm -rf "${tmp_dir}"
35+
}
36+
trap clean EXIT
37+
38+
rm "${GOBIN}/${2}"* > /dev/null 2>&1 || true
39+
40+
cd "${tmp_dir}"
41+
42+
# create a new module in the tmp directory
43+
go mod init fake/mod
44+
45+
# install the golang module specified as the first argument
46+
go install -tags kcptools "${1}@${3}"
47+
mv "${GOBIN}/${2}" "${GOBIN}/${2}-${3}"
48+
ln -sf "${GOBIN}/${2}-${3}" "${GOBIN}/${2}"

0 commit comments

Comments
 (0)