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

update indexer reviewdog configuration #1610

Merged
merged 5 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
58 changes: 13 additions & 45 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ jobs:
uses: actions/[email protected]
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
- name: Install specific golang
uses: actions/[email protected]
with:
go-version: '1.20.14'
- name: reviewdog-golangci-lint
uses: reviewdog/[email protected]
with:
go_version_file: go.mod
golangci_lint_version: "v1.53.2"
golangci_lint_flags: "-c .golangci.yml --allow-parallel-runners"
reporter: "github-pr-review"
reporter: "github-pr-check"
tool_name: "Lint Errors"
level: "error"
fail_on_error: true
filter_mode: "nofilter"
# Non-Blocking Warnings Section
reviewdog-warnings:
runs-on: ubuntu-latest
Expand All @@ -33,50 +33,18 @@ jobs:
uses: actions/[email protected]
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
- name: Install specific golang
uses: actions/[email protected]
with:
go-version: '1.20.14'
- name: Add bin to PATH
run: |
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
echo "$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)/bin" >> $GITHUB_PATH
- 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/[email protected]
- name: reviewdog-golangci-lint
uses: reviewdog/[email protected]
with:
path: cicdtmp/golangci-lint/golangci-lint-cgo
key: cicd-golangci-lint-cgo-v0.0.2

- 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.53.2
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.14.1/install.sh | sh -s
reviewdog --version
- 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
go_version_file: go.mod
golangci_lint_version: "v1.53.2"
golangci_lint_flags: "-c .golangci-warnings.yml --allow-parallel-runners"
reporter: "github-pr-check"
tool_name: "Lint Warnings"
level: "warning"
fail_on_error: false
filter_mode: "added"
5 changes: 2 additions & 3 deletions config/datadir.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package config

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand All @@ -29,7 +28,7 @@ func algodStat(netpath string) (lastmod time.Time, err error) {
func AlgodArgsForDataDir(datadir string) (netAddr string, token string, lastmod time.Time, err error) {
netpath, tokenpath := algodPaths(datadir)
var netaddrbytes []byte
netaddrbytes, err = ioutil.ReadFile(netpath)
netaddrbytes, err = os.ReadFile(netpath)
if err != nil {
err = fmt.Errorf("%s: %v", netpath, err)
return
Expand All @@ -39,7 +38,7 @@ func AlgodArgsForDataDir(datadir string) (netAddr string, token string, lastmod
netAddr = "http://" + netAddr
}

tokenBytes, err := ioutil.ReadFile(tokenpath)
tokenBytes, err := os.ReadFile(tokenpath)
if err != nil {
err = fmt.Errorf("%s: %v", tokenpath, err)
return
Expand Down
7 changes: 5 additions & 2 deletions util/test/account_testutil.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package test

import (
"crypto/rand"
"crypto/sha512"
"fmt"
"math/rand"

"github.com/algorand/indexer/v3/util"

Expand Down Expand Up @@ -58,7 +58,10 @@ func DecodeAddressOrPanic(addr string) sdk.Address {
// This is necessary to ensure the hash of any two txns used in tests are never the same.
func ArbitraryString() []byte {
arb := make([]byte, config.MaxTxnNoteBytes)
rand.Read(arb)
_, err := rand.Read(arb)
if err != nil {
panic("rand.Read error")
}
return arb
}

Expand Down
3 changes: 1 addition & 2 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -233,7 +232,7 @@ func ReadGenesis(in io.Reader) (sdk.Genesis, error) {
if in == nil {
return sdk.Genesis{}, fmt.Errorf("ReadGenesis() err: reader is nil")
}
gbytes, err := ioutil.ReadAll(in)
gbytes, err := io.ReadAll(in)
if err != nil {
return sdk.Genesis{}, fmt.Errorf("ReadGenesis() err: %w", err)
}
Expand Down
Loading