Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
Version golangci-lint and build it with make (#651)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
  • Loading branch information
Jakub Sztandera committed Jul 14, 2020
1 parent 7e9ee41 commit 464ba38
Show file tree
Hide file tree
Showing 7 changed files with 617 additions and 33 deletions.
17 changes: 2 additions & 15 deletions .circleci/config.yml
Expand Up @@ -93,24 +93,11 @@ jobs:
- install-deps
- prepare
- run:
command: make build
- run:
name: Install golangci-lint
command: >
(
cd $(mktemp -d);
go mod init a;
go get github.com/golangci/golangci-lint/cmd/golangci-lint@v<< parameters.golangci-lint-version >>
go build github.com/golangci/golangci-lint/cmd/golangci-lint
mkdir -p $HOME/.local/bin
mv -f golangci-lint $HOME/.local/bin/
)
- run:
command: make .nomaprange.so
command: make -j3 support/tools/bin/golangci-lint support/tools/bin/no-map-range.so
- run:
name: Lint
command: |
$HOME/.local/bin/golangci-lint run -v --skip-dirs-use-default=false\
support/tools/bin/golangci-lint run -v \
--concurrency << parameters.concurrency >> << parameters.args >>
lint-all:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -15,3 +15,5 @@
# vendor/

.idea

support/tools/bin
11 changes: 5 additions & 6 deletions .golangci.yml
@@ -1,14 +1,13 @@
linters-settings:
custom:
# 2020-07-13 @anorth disabled, local build failing with "Unable to load custom analyzer nomaprange:.nomaprange.so, plugin: not implemented"
#nomaprange:
# path: .nomaprange.so
# description: Checks for range over maps
# original-url: github.com/Kubuxu/go-no-map-range
nomaprange:
path: support/tools/bin/no-map-range.so
description: Checks for range over maps
original-url: github.com/Kubuxu/go-no-map-range

linters:
enable:
#- nomaprange
- nomaprange

run:
skip-dirs-use-default: false
Expand Down
29 changes: 17 additions & 12 deletions Makefile
@@ -1,6 +1,4 @@
GO_BIN ?= go
GOLINT ?= golangci-lint

all: build lint test tidy
.PHONY: all

Expand All @@ -20,16 +18,23 @@ tidy:
$(GO_BIN) mod tidy
.PHONY: tidy

lint: .nomaprange.so
$(GOLINT) run ./...
.PHONY: lint

.nomaprange.so:
$(eval TMP=$(shell mktemp -d))
(cd $(TMP); go mod init a; go build -buildmode=plugin -o .nomaprange.so github.com/Kubuxu/go-no-map-range/plugin)
cp $(TMP)/.nomaprange.so .nomaprange.so
rm -rf $(TMP)

gen:
$(GO_BIN) run ./gen/gen.go
.PHONY: gen


# tools
toolspath:=support/tools

$(toolspath)/bin/golangci-lint: $(toolspath)/go.mod
@mkdir -p $(dir $@)
(cd $(toolspath); go build -tags tools -o $(@:$(toolspath)/%=%) github.com/golangci/golangci-lint/cmd/golangci-lint)


$(toolspath)/bin/no-map-range.so: $(toolspath)/go.mod
@mkdir -p $(dir $@)
(cd $(toolspath); go build -tags tools -buildmode=plugin -o $(@:$(toolspath)/%=%) github.com/Kubuxu/go-no-map-range/plugin)

lint: $(toolspath)/bin/golangci-lint $(toolspath)/bin/no-map-range.so
$(toolspath)/bin/golangci-lint run ./...
.PHONY: lint
8 changes: 8 additions & 0 deletions support/tools/go.mod
@@ -0,0 +1,8 @@
module github.com/filecoin-project/specs-actors/support/tools

go 1.13

require (
github.com/Kubuxu/go-no-map-range v0.0.1
github.com/golangci/golangci-lint v1.28.2
)
575 changes: 575 additions & 0 deletions support/tools/go.sum

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions support/tools/tools.go
@@ -0,0 +1,8 @@
//+build tools

package tools

import (
_ "github.com/Kubuxu/go-no-map-range/pkg/analyzer"
_ "github.com/golangci/golangci-lint/pkg/lint"
)

0 comments on commit 464ba38

Please sign in to comment.