-
Notifications
You must be signed in to change notification settings - Fork 524
Add initial golangci-lint action #2647
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
Merged
Merged
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 f163ffe
enable staticcheck linter, which will report issues across the repo
cce 577a0bf
enable "only-new-issues: true" golangci-lint setting
cce 33ab2cd
check in some code that makes lint issues to see what annotations loo…
cce a911dae
Adding initial reviewdog workflow
algojack 912bd9f
Adding golandci to reviewdog workflow
algojack f16169a
Added place where we can add flags
algojack e3e5b18
Added place where we can add flags
algojack 7a9935b
add warning vs error severity to golangci config to see how it works …
cce 435da04
use reviewdog instead of golangci-lint action
cce 677a6d5
set golangci-lint version in reviewdog config
cce 5cad770
Revert "use reviewdog instead of golangci-lint action"
cce 6311575
fix typo in reviewdog config
cce 388b2f9
re-enable go mod caching used by reviewdog & golangci-lint actions
cce 956a90e
fix checkout for reviewdog
cce 0587f66
Added reporter option to reviewdog
algojack f044c6a
CircleCI: parameterizing no_output_timeout and -short (#2618)
algobarb bebdb13
Update the Version, BuildNumber, genesistimestamp.data
Algo-devops-service a53ace2
Change spec file name to INSTALLER_DIR (#2591)
onetechnical 0ec39a9
Bump Version, Remove buildnumber.dat and genesistimestamp.dat files.
Algo-devops-service 4f447ab
partition router_test.go (#2652)
algobarb f3c0a51
Update systemd-setup.sh to install system.json (#2651)
bricerisingalgorand a55f1a1
Implement partitiontest_linter (#2635)
algojack 41e6794
Integrating custom linter
algojack 46b46b7
Merge remote-tracking branch 'origin/master' into feature/gha-golangc…
algojack 7aaccbb
replaced disable list with disable-all
algojack 0197a34
fixed enabled linters list
algojack 17a5544
Added parallel runners for error and warnings
algojack 5e9706a
Removed config reference
algojack e3cd61c
Disabled .golangci.yml
algojack f397574
Disabled golangci-lint pipeline
algojack ab362f2
Trying with two golangci config files
algojack e73cd3b
Fixed new flag
algojack b2f2402
Fixed config file name typo
algojack 7b1c431
Removing comments and trying info level in golangci
algojack c75e01e
Fixing severity levels
algojack 59632ae
Took out custom linter for now
algojack 68823c1
Fixed custom linter
algojack ed22248
Building custom linter
algojack f96d8ff
fixing makefile
algojack 094e871
fixing makefile
algojack d95fa34
Fixing building of custom linter
algojack bd3c4b2
Fixing plugin build
algojack dfd4d15
Fixing plugin build
algojack a9705fe
Fixing plugin build
algojack d62a640
Fixing plugin build
algojack 34b217e
Adding test step for custom linter build
algojack dffc83f
Replaced reviewdog action with manual steps
algojack 57fb45e
Fixing curls for golangci-lint and reviewdog
algojack 4e72e3b
Fixing curls for golangci-lint and reviewdog
algojack d55ea35
Fixing curls for golangci-lint and reviewdog
algojack 4f90c29
Fixing install for golangci-lint and reviewdog
algojack 0e67ce7
Fixing install for golangci-lint and reviewdog
algojack 60b4267
Fixing install for golangci-lint and reviewdog
algojack fa229db
Fixing install for golangci-lint and reviewdog
algojack 5366666
Fixing install for golangci-lint and reviewdog
algojack b4578b9
Fixing install for golangci-lint and reviewdog
algojack b5a6761
Fixing install for golangci-lint and reviewdog
algojack 2125bf0
Fixing install for golangci-lint and reviewdog
algojack e4d39ee
Fixing install for golangci-lint and reviewdog
algojack f785878
added environment config scripts
algojack 1219293
Added make install
algojack 63c34ab
Enabled CGO for custom plugin build
algojack 4aecb2e
Building golangci-lint with CGO_ENABLED=true
algojack 85bc4e2
Building golangci-lint with CGO_ENABLED=true
algojack 7754e21
Trying to build golangci-lint
algojack 9b7d08d
Caching custom golangci-lint
algojack 92dbf00
Fixing typo
algojack d996e55
Added github token to env for reviewdog
algojack 6c6add3
Testing different formatting
algojack 4eecf36
Updated lint test file ignore and latest commit sha
algojack b23578a
Fixed typo
algojack d546b46
Merge branch 'master' of github.com:algorand/go-algorand into feature…
algojack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,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 | ||
This file contains hidden or 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,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 | ||
algojack marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # 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 | ||
algojack marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # 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 | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,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() | ||
algojack marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.