-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2413502
commit e19ddde
Showing
87 changed files
with
385 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: golangci-lint | ||
|
||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.16 | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/go/bin/golangci-lint | ||
key: golangci-lint-1.45.2 | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- run: git config --global url."https://${{ secrets.GH_ACCESS_TOKEN }}@github.com".insteadOf "https://github.com" | ||
- run: go env -w GOPRIVATE="github.com/bnb-chain/*" | ||
- name: golangci-lint | ||
run: make lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Options for analysis running. | ||
run: | ||
# The default concurrency value is the number of available CPU. | ||
# concurrency: 4 | ||
# Timeout for analysis, e.g. 30s, 5m. | ||
# Default: 1m | ||
timeout: 5m | ||
# Exit code when at least one issue was found. | ||
# Default: 1 | ||
# issues-exit-code: 2 | ||
# Include test files or not. | ||
# Default: true | ||
tests: false | ||
# List of build tags, all linters use it. | ||
# Default: []. | ||
# build-tags: | ||
# - mytag | ||
# Which dirs to skip: issues from them won't be reported. | ||
# Can use regexp here: `generated.*`, regexp is applied on full path. | ||
# Default value is empty list, | ||
# but default dirs are skipped independently of this option's value (see skip-dirs-use-default). | ||
# "/" will be replaced by current OS file path separator to properly work on Windows. | ||
# skip-dirs: | ||
# - src/external_libs | ||
# - autogenerated_by_my_lib | ||
# Enables skipping of directories: | ||
# - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ | ||
# Default: true | ||
# skip-dirs-use-default: false | ||
# Which files to skip: they will be analyzed, but issues from them won't be reported. | ||
# Default value is empty list, | ||
# but there is no need to include all autogenerated files, | ||
# we confidently recognize autogenerated files. | ||
# If it's not please let us know. | ||
# "/" will be replaced by current OS file path separator to properly work on Windows. | ||
# skip-files: | ||
# - ".*\\.my\\.go$" | ||
# - lib/bad.go | ||
# If set we pass it to "go list -mod={option}". From "go help modules": | ||
# If invoked with -mod=readonly, the go command is disallowed from the implicit | ||
# automatic updating of go.mod described above. Instead, it fails when any changes | ||
# to go.mod are needed. This setting is most useful to check that go.mod does | ||
# not need updates, such as in a continuous integration and testing system. | ||
# If invoked with -mod=vendor, the go command assumes that the vendor | ||
# directory holds the correct copies of dependencies and ignores | ||
# the dependency descriptions in go.mod. | ||
# | ||
# Allowed values: readonly|vendor|mod | ||
# By default, it isn't set. | ||
# modules-download-mode: readonly | ||
# Allow multiple parallel golangci-lint instances running. | ||
# If false (default) - golangci-lint acquires file lock on start. | ||
# allow-parallel-runners: false | ||
# Define the Go version limit. | ||
# Mainly related to generics support in go1.18. | ||
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.17 | ||
# go: '1.16' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,9 +144,13 @@ format: | |
|
||
######################################## | ||
### Lint | ||
lint: | ||
install_lint: | ||
which golangci-lint || go install github.com/golangci/golangci-lint/cmd/[email protected] | ||
golangci-lint --version | ||
|
||
lint: install_lint | ||
@echo "-->Lint" | ||
golint $(PACKAGES) | ||
golangci-lint run | ||
|
||
######################################## | ||
### Testing | ||
|
@@ -167,13 +171,13 @@ set_with_deadlock: | |
cp go.sum go.sum_bak | ||
find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.mutex_bak 's/sync.RWMutex/deadlock.RWMutex/' | ||
find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.mutex_bak 's/sync.Mutex/deadlock.Mutex/' | ||
find . -name "*.go" | grep -v "vendor/" | xargs -n 1 goimports -w | ||
find . -name "*.go" | grep -v "vendor/" | grep -v ".git/" | xargs -n 1 goimports -w | ||
|
||
# cleanes up after you ran test_with_deadlock | ||
cleanup_after_test_with_deadlock: | ||
find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.mutex_bak 's/deadlock.RWMutex/sync.RWMutex/' | ||
find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.mutex_bak 's/deadlock.Mutex/sync.Mutex/' | ||
find . -name "*.go" | grep -v "vendor/" | xargs -n 1 goimports -w | ||
find . -name "*.go" | grep -v "vendor/" | grep -v ".git/" | xargs -n 1 goimports -w | ||
find . -name "*.go.mutex_bak" | grep -v "vendor/" | xargs rm | ||
mv go.mod_bak go.mod | ||
mv go.sum_bak go.sum | ||
|
@@ -193,7 +197,7 @@ integration_test: build | |
|
||
######################################## | ||
### Pre Commit | ||
pre_commit: build test format | ||
pre_commit: build test format lint | ||
|
||
######################################## | ||
### Local validator nodes using docker and docker-compose | ||
|
@@ -227,3 +231,4 @@ localnet-stop: | |
# unless there is a reason not to. | ||
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html | ||
.PHONY: build install test test_unit build-linux build-docker-node localnet-start localnet-stop | ||
.PHONY: lint install_lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.