Skip to content

Commit

Permalink
use gettool and fix makefile paths
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyTVu authored and TonyTVu committed Dec 6, 2022
1 parent 72292a9 commit 7a75192
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ $(BIN_DIR)/tools/protoc: protoc.version
$(BIN_DIR)/tools/prometheus: prometheus.version
go run ./devtools/gettool -t prometheus -v $(shell cat prometheus.version) -o $@

$(BIN_DIR)/tools/golangci-lint: golangci-lint.version
go run ./devtools/gettool -t golangci-lint -v $(shell cat golangci-lint.version) -o $@

$(BIN_DIR)/tools/protoc-gen-go: go.mod
GOBIN=$(abspath $(BIN_DIR))/tools go install google.golang.org/protobuf/cmd/protoc-gen-go
$(BIN_DIR)/tools/protoc-gen-go-grpc: go.mod
GOBIN=$(abspath $(BIN_DIR))/tools go install google.golang.org/grpc/cmd/protoc-gen-go-grpc

$(BIN_DIR)/tools/golangci-lint: golangci-lint.version
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BIN_DIR)/tools $(shell cat golangci-lint.version)

system.ca.pem:
go run ./cmd/goalert gen-cert ca
system.ca.key:
Expand Down Expand Up @@ -145,10 +145,10 @@ check-js: force-yarn generate node_modules
yarn run lint
yarn workspaces run check

check-go: generate $(BIN_DIR)/tools/golangci-lint bin/tools/golangci-lint
check-go: generate $(BIN_DIR)/tools/golangci-lint
@go mod tidy
# go run ./devtools/ordermigrations -check
./bin/tools/golangci-lint run
$(BIN_DIR)/tools/golangci-lint run

graphql2/mapconfig.go: $(CFGPARAMS) config/config.go graphql2/generated.go devtools/configparams/*
(cd ./graphql2 && go run ../devtools/configparams -out mapconfig.go && go run golang.org/x/tools/cmd/goimports -w ./mapconfig.go) || go generate ./graphql2
Expand Down
37 changes: 37 additions & 0 deletions devtools/gettool/getgolangcilint.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

import (
"archive/tar"
"compress/gzip"
"fmt"
"runtime"
)

func getGolangCiLint(version, output string) error {
os := runtime.GOOS + "-" + runtime.GOARCH
url := fmt.Sprintf("https://github.com/golangci/golangci-lint/releases/download/v%s/golangci-lint-%s-%s.tar.gz",
version, version,
os,
)

fd, _, err := fetchFile(url)
if err != nil {
return fmt.Errorf("fetch: %w", err)
}
defer fd.Close()

gzr, err := gzip.NewReader(fd)
if err != nil {
return fmt.Errorf("deflate: %w", err)
}
defer gzr.Close()

r := tar.NewReader(gzr)

err = extractFromTar(r, "*/golangci-lint", output, true)
if err != nil {
return fmt.Errorf("extract: %w", err)
}

return nil
}
2 changes: 2 additions & 0 deletions devtools/gettool/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func main() {
err = getPrometheus(*version, *output)
case "protoc":
err = getProtoC(*version, *output)
case "golangci-lint":
err = getGolangCiLint(*version, *output)
default:
log.Fatalf("unknown tool '%s'", *tool)
}
Expand Down
2 changes: 1 addition & 1 deletion golangci-lint.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.50.1
1.50.1

0 comments on commit 7a75192

Please sign in to comment.