Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup develop environment of circleCI #42

Merged
merged 6 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,21 @@ jobs:
# - "*.zip"
# - "tendermint_linux_amd64"

lint:
executor: golang
parallelism: 1
steps:
- checkout
- restore_cache:
name: "Restore go modules cache"
keys:
- go-mod-v1-{{ checksum "go.sum" }}
- run:
name: "Run linter"
command: |
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.8
make lint

release_artifacts:
executor: golang
steps:
Expand Down Expand Up @@ -412,7 +427,10 @@ workflows:
branches:
only:
- docs-theme-latest
- setup_dependencies
- lint
- setup_dependencies:
requires:
- lint
- test_abci_apps:
requires:
- setup_dependencies
Expand Down
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,8 @@ linters-settings:
# disabled-checks:
# - wrapperFunc
# - commentFormatting # https://github.com/go-critic/go-critic/issues/755

# options for analysis running
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ fmt:
@go fmt ./...

lint:
@echo "--> Running linter"
@golangci-lint run
sh -c "$(CURDIR)/scripts/current_branch_lint.sh"
find . -name '*.go' -type f -not -path "*.git*" | xargs gofmt -d -s
go mod verify

DESTINATION = ./index.html.md

Expand Down
14 changes: 14 additions & 0 deletions scripts/current_branch_lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# get the base commit hash of this branch. The branch should be brached from master.
base_commit=$(diff -u <(git rev-list --first-parent HEAD) \
<(git rev-list --first-parent master) | \
sed -ne 's/^ //p' | head -1)

if [ "$base_commit" ]; then
#if base commit of this branch is exist, run linter from base commit to HEAD
golangci-lint run -v --new-from-rev "$base_commit"
else
# if not, check current don't commited files.
golangci-lint run -v -n
fi