Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
83e94b7
Add initial golangci-lint action
cce Jul 28, 2021
f163ffe
enable staticcheck linter, which will report issues across the repo
cce Jul 28, 2021
577a0bf
enable "only-new-issues: true" golangci-lint setting
cce Jul 28, 2021
33ab2cd
check in some code that makes lint issues to see what annotations loo…
cce Jul 28, 2021
a911dae
Adding initial reviewdog workflow
algojack Jul 28, 2021
912bd9f
Adding golandci to reviewdog workflow
algojack Jul 28, 2021
f16169a
Added place where we can add flags
algojack Jul 28, 2021
e3e5b18
Added place where we can add flags
algojack Jul 28, 2021
7a9935b
add warning vs error severity to golangci config to see how it works …
cce Jul 29, 2021
435da04
use reviewdog instead of golangci-lint action
cce Jul 29, 2021
677a6d5
set golangci-lint version in reviewdog config
cce Jul 29, 2021
5cad770
Revert "use reviewdog instead of golangci-lint action"
cce Jul 29, 2021
6311575
fix typo in reviewdog config
cce Jul 29, 2021
388b2f9
re-enable go mod caching used by reviewdog & golangci-lint actions
cce Jul 29, 2021
956a90e
fix checkout for reviewdog
cce Jul 29, 2021
0587f66
Added reporter option to reviewdog
algojack Jul 29, 2021
f044c6a
CircleCI: parameterizing no_output_timeout and -short (#2618)
algobarb Jul 28, 2021
bebdb13
Update the Version, BuildNumber, genesistimestamp.data
Algo-devops-service Jul 17, 2021
a53ace2
Change spec file name to INSTALLER_DIR (#2591)
onetechnical Jul 20, 2021
0ec39a9
Bump Version, Remove buildnumber.dat and genesistimestamp.dat files.
Algo-devops-service Jul 28, 2021
4f447ab
partition router_test.go (#2652)
algobarb Jul 29, 2021
f3c0a51
Update systemd-setup.sh to install system.json (#2651)
bricerisingalgorand Jul 29, 2021
a55f1a1
Implement partitiontest_linter (#2635)
algojack Jul 29, 2021
41e6794
Integrating custom linter
algojack Jul 29, 2021
46b46b7
Merge remote-tracking branch 'origin/master' into feature/gha-golangc…
algojack Jul 29, 2021
7aaccbb
replaced disable list with disable-all
algojack Jul 29, 2021
0197a34
fixed enabled linters list
algojack Jul 29, 2021
17a5544
Added parallel runners for error and warnings
algojack Jul 29, 2021
5e9706a
Removed config reference
algojack Jul 29, 2021
e3cd61c
Disabled .golangci.yml
algojack Jul 29, 2021
f397574
Disabled golangci-lint pipeline
algojack Jul 29, 2021
ab362f2
Trying with two golangci config files
algojack Aug 2, 2021
e73cd3b
Fixed new flag
algojack Aug 2, 2021
b2f2402
Fixed config file name typo
algojack Aug 2, 2021
7b1c431
Removing comments and trying info level in golangci
algojack Aug 2, 2021
c75e01e
Fixing severity levels
algojack Aug 2, 2021
59632ae
Took out custom linter for now
algojack Aug 2, 2021
68823c1
Fixed custom linter
algojack Aug 2, 2021
ed22248
Building custom linter
algojack Aug 2, 2021
f96d8ff
fixing makefile
algojack Aug 2, 2021
094e871
fixing makefile
algojack Aug 2, 2021
d95fa34
Fixing building of custom linter
algojack Aug 2, 2021
bd3c4b2
Fixing plugin build
algojack Aug 2, 2021
dfd4d15
Fixing plugin build
algojack Aug 2, 2021
a9705fe
Fixing plugin build
algojack Aug 2, 2021
d62a640
Fixing plugin build
algojack Aug 2, 2021
34b217e
Adding test step for custom linter build
algojack Aug 2, 2021
dffc83f
Replaced reviewdog action with manual steps
algojack Aug 3, 2021
57fb45e
Fixing curls for golangci-lint and reviewdog
algojack Aug 3, 2021
4e72e3b
Fixing curls for golangci-lint and reviewdog
algojack Aug 3, 2021
d55ea35
Fixing curls for golangci-lint and reviewdog
algojack Aug 3, 2021
4f90c29
Fixing install for golangci-lint and reviewdog
algojack Aug 3, 2021
0e67ce7
Fixing install for golangci-lint and reviewdog
algojack Aug 3, 2021
60b4267
Fixing install for golangci-lint and reviewdog
algojack Aug 3, 2021
fa229db
Fixing install for golangci-lint and reviewdog
algojack Aug 3, 2021
5366666
Fixing install for golangci-lint and reviewdog
algojack Aug 3, 2021
b4578b9
Fixing install for golangci-lint and reviewdog
algojack Aug 3, 2021
b5a6761
Fixing install for golangci-lint and reviewdog
algojack Aug 3, 2021
2125bf0
Fixing install for golangci-lint and reviewdog
algojack Aug 3, 2021
e4d39ee
Fixing install for golangci-lint and reviewdog
algojack Aug 3, 2021
f785878
added environment config scripts
algojack Aug 4, 2021
1219293
Added make install
algojack Aug 4, 2021
63c34ab
Enabled CGO for custom plugin build
algojack Aug 4, 2021
4aecb2e
Building golangci-lint with CGO_ENABLED=true
algojack Aug 4, 2021
85bc4e2
Building golangci-lint with CGO_ENABLED=true
algojack Aug 4, 2021
7754e21
Trying to build golangci-lint
algojack Aug 4, 2021
9b7d08d
Caching custom golangci-lint
algojack Aug 4, 2021
92dbf00
Fixing typo
algojack Aug 4, 2021
d996e55
Added github token to env for reviewdog
algojack Aug 4, 2021
6c6add3
Testing different formatting
algojack Aug 4, 2021
4eecf36
Updated lint test file ignore and latest commit sha
algojack Aug 4, 2021
b23578a
Fixed typo
algojack Aug 4, 2021
d546b46
Merge branch 'master' of github.com:algorand/go-algorand into feature…
algojack Aug 5, 2021
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
90 changes: 90 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: "ReviewDog workflow"
on:
pull_request:
jobs:
# Blocking Errors Section
reviewdog-errors:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0 # required for new-from-rev option in .golangci.yml
- name: Install libraries
run: sudo apt-get -y -q install libboost-math-dev
# move go out of the way temporarily to avoid "go list ./..." from installing modules
- name: Make libsodium.a
run: sudo mv /usr/bin/go /usr/bin/go.bak && make crypto/libs/linux/amd64/lib/libsodium.a && sudo mv /usr/bin/go.bak /usr/bin/go
- name: reviewdog-golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
golangci_lint_version: "v1.41.1"
golangci_lint_flags: "-c .golangci.yml --allow-parallel-runners"
reporter: "github-pr-review"
tool_name: "Lint Errors"
level: "error"
fail_on_error: true
# Non-Blocking Warnings Section
reviewdog-warnings:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0 # required for new-from-rev option in .golangci.yml
- name: Install libraries
run: sudo apt-get -y -q install libboost-math-dev
# move go out of the way temporarily to avoid "go list ./..." from installing modules
- name: Make libsodium.a
run: sudo mv /usr/bin/go /usr/bin/go.bak && make crypto/libs/linux/amd64/lib/libsodium.a && sudo mv /usr/bin/go.bak /usr/bin/go
- name: Add bin to PATH
run: |
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
echo "$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)/bin" >> $GITHUB_PATH
- name: Install specific golang
uses: actions/setup-go@v2
with:
go-version: '1.16.6'
- name: Create folders for golangci-lint
run: mkdir -p cicdtmp/golangci-lint
- name: Check if custom golangci-lint is already built
id: cache-golangci-lint
uses: actions/cache@v2
with:
path: cicdtmp/golangci-lint/golangci-lint-cgo
key: cicd-golangci-lint-cgo-v0.0.1

- name: Build custom golangci-lint with CGO_ENABLED
if: steps.cache-golangci-lint.outputs.cache-hit != 'true'
run: |
cd cicdtmp/golangci-lint
git clone https://github.com/golangci/golangci-lint.git .
git checkout tags/v1.41.1
CGO_ENABLED=true go build -trimpath -o golangci-lint-cgo ./cmd/golangci-lint
./golangci-lint-cgo --version
cd ../../
- name: Install reviewdog
run: |
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/v0.13.0/install.sh | sh -s
reviewdog --version
- name: Build custom linters
run: |
cd cmd/partitiontest_linter/
CGO_ENABLED=true go build -buildmode=plugin -trimpath plugin/plugin.go
cd ../../
ls -la cmd/partitiontest_linter/
- name: Run golangci-lint with reviewdog
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
./cicdtmp/golangci-lint/golangci-lint-cgo run
--out-format line-number
-c .golangci-warnings.yml
--allow-parallel-runners
| reviewdog
-f=golangci-lint
-name="Lint Warnings"
-reporter=github-check
-filter-mode=added
-fail-on-error=false
-level=warning
76 changes: 76 additions & 0 deletions .golangci-warnings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
run:
timeout: 5m
tests: true

linters:
disable-all: true
enable:
- staticcheck
- structcheck
- typecheck
- varcheck
- deadcode
- gosimple
- unused
- partitiontest


linters-settings:
custom:
partitiontest:
path: cmd/partitiontest_linter/plugin.so
description: This custom linter checks files that end in '_test.go', specifically functions that start with 'Test' and have testing argument, for a line 'partitiontest.ParitionTest(<testing arg>)'
original-url: github.com/algorand/go-algorand/cmd/partitiontest_linter

severity:
default-severity: warning

issues:
# use these new lint checks on code since #2574
new-from-rev: eb019291beed556ec6ac1ceb4a15114ce4df0c57

# Disable default exclude rules listed in `golangci-lint run --help` (selectively re-enable some below)
exclude-use-default: false

# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0

# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0

exclude:
# ignore govet false positive fixed in https://github.com/golang/go/issues/45043
- "sigchanyzer: misuse of unbuffered os.Signal channel as argument to signal.Notify"
# ignore golint false positive fixed in https://github.com/golang/lint/pull/487
- "exported method (.*).Unwrap` should have comment or be unexported"
# ignore issues about the way we use _struct fields to define encoding settings
- "`_struct` is unused"

# Enable some golangci-lint default exception rules:
# "EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok"
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
# "EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore"
- ineffective break statement. Did you mean to break out of the outer loop

exclude-rules:
# be more lenient with test code
- path: _test\.go
linters:
- staticcheck
- structcheck
- typecheck
- varcheck
- deadcode
- gosimple
- unused
# Add all linters here -- Comment this block out for testing linters
- path: test/linttest/lintissues\.go
linters:
- staticcheck
- structcheck
- typecheck
- varcheck
- deadcode
- gosimple
- unused
- partitiontest
59 changes: 32 additions & 27 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
run:
timeout: 5m
tests: true
tests: false

linters:
disable-all: true
enable:
- errcheck
- gofmt
- golint
- misspell
- govet
- ineffassign
- partitiontest
- misspell

disable:
- deadcode
- errcheck
- gosimple
- staticcheck
- structcheck
- unused
- varcheck

linters-settings:
custom:
partitiontest:
path: cmd/partitiontest_linter/plugin.so
description: This custom linter checks files that end in '_test.go', specifically functions that start with 'Test' and have testing argument, for a line 'partitiontest.ParitionTest(<testing arg>)'
original-url: github.com/algorand/go-algorand/cmd/partitiontest_linter
# govet:
# check-shadowing: true
severity:
default-severity: error

issues:
# don't use default exclude rules listed in `golangci-lint run --help`
# use these new lint checks on code since #2574
new-from-rev: eb019291beed556ec6ac1ceb4a15114ce4df0c57

# Disable default exclude rules listed in `golangci-lint run --help` (selectively re-enable some below)
exclude-use-default: false

# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
Expand All @@ -38,12 +28,27 @@ issues:
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0

exclude-rules:
exclude:
# ignore govet false positive fixed in https://github.com/golang/go/issues/45043
- linters:
- govet
text: "sigchanyzer: misuse of unbuffered os.Signal channel as argument to signal.Notify"
- "sigchanyzer: misuse of unbuffered os.Signal channel as argument to signal.Notify"
# ignore golint false positive fixed in https://github.com/golang/lint/pull/487
- linters:
- "exported method (.*).Unwrap` should have comment or be unexported"
# ignore issues about the way we use _struct fields to define encoding settings
- "`_struct` is unused"

# Enable some golangci-lint default exception rules:
# "EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok"
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
# "EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore"
- ineffective break statement. Did you mean to break out of the outer loop

exclude-rules:
# Add all linters here -- Comment this block out for testing linters
- path: test/linttest/lintissues\.go
linters:
- errcheck
- gofmt
- golint
text: "exported method (.*).Unwrap` should have comment or be unexported"
- govet
- ineffassign
- misspell
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,5 @@ archive:
aws s3 cp tmp/node_pkgs s3://algorand-internal/channel/$(CHANNEL)/$(FULLBUILDNUMBER) --recursive --exclude "*" --include "*$(FULLBUILDNUMBER)*"

build_custom_linters:
cd cmd/partitiontest_linter/
go build -buildmode=plugin -trimpath plugin/plugin.go
cd -
cd $(SRCPATH)/cmd/partitiontest_linter/ && go build -buildmode=plugin -trimpath plugin/plugin.go && ls plugin.so
cd $(SRCPATH)
3 changes: 3 additions & 0 deletions cmd/partitiontest_linter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ module github.com/algorand/go-algorand/cmd/partitiontest_linter

go 1.16

require golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
require golang.org/x/sys v0.0.0-20210510120138-977fb7262007
require golang.org/x/mod v0.4.2
require golang.org/x/tools v0.1.3
36 changes: 36 additions & 0 deletions test/linttest/lintissues.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (C) 2019-2021 Algorand, Inc.
// This file is part of go-algorand
//
// go-algorand is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// go-algorand is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package linttest

import (
"fmt"
)

type myStruct struct {
a int32
b float64
c bool
}

func (m *myStruct) couldError() error {
return fmt.Errorf("an error occurred")
}

func doSomething() {
m := myStruct{a: 2, b: 2.0}
m.couldError()
}