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

add linter action and task, fix append bug in sql/client #194

Merged
merged 2 commits into from
Aug 17, 2023
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
16 changes: 14 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '1.20.0'
go-version: '1.20'
cache: true

- name: Install dependencies
Expand All @@ -48,6 +48,18 @@ jobs:
run: |
task pb:compile:v1

- name: Compile all packages
run: |
go build ./...

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
install-mode: "binary"
version: "latest"
skip-pkg-cache: true
# args: --timeout=30m --config=.golangci.yml --issues-exit-code=0

- name: Generate go vendor
#for faster builds and private repos, need to run this after pb:compile:v1
run: |
Expand Down Expand Up @@ -80,7 +92,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '1.20.0'
go-version: '1.20'
cache: true

- name: Install dependencies
Expand Down
29 changes: 29 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
run:
deadline: 10m

output:
format: github-actions,colored-line-number

linters:
disable-all: true
enable:
- asciicheck
- bidichk
- durationcheck
- exportloopref
- gofmt
- goimports
- gosimple
- govet
- grouper
- ineffassign
- makezero
- misspell
- nosprintfhostport
- reassign
- rowserrcheck
- sqlclosecheck
- tparallel
- typecheck
- unconvert
- unused
26 changes: 13 additions & 13 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ tasks:
- task -l

install:deps:
aliases: [tools]
desc: Install tools required to build this app
cmds:
- cat tools.go | grep _ | awk -F'"' '{print $2}' | xargs -tI % go install %
- grep _ tools.txt | awk -F'"' '{print $2}' | xargs -tI % go install %

vendor:
desc: Generate vendor
Expand Down Expand Up @@ -42,6 +43,17 @@ tasks:
cmds:
- go mod download

fmt:
desc: Format the code
cmds:
- goimports -format-only -w .

lint:
desc: Lint with golangci-lint
deps: [pb:compile:v1]
cmds:
- golangci-lint run -c .golangci.yml

build:
desc: Build cli & kwild
cmds:
Expand All @@ -64,18 +76,6 @@ tasks:
generates:
- .build/kwild

build:abi:
desc: Builds Golang bindings for EVM contract ABIs
internal: true
cmds:
- abigen --abi ./pkg/chain/contracts/escrow/evm/abi/escrow.json --bin ./pkg/chain/contracts/escrow/evm/abi/escrow.bin --pkg abi --type Escrow --out ./pkg/chain/contracts/escrow/evm/abi/escrow.go
- abigen --abi ./pkg/chain/contracts/token/evm/abi/erc20.json --bin ./pkg/chain/contracts/token/evm/abi/erc20.bin --pkg abi --type Erc20 --out ./pkg/chain/contracts/token/evm/abi/erc20.go
sources:
- ./pkg/chain/contracts/*/evm/abi/*.json
- ./pkg/chain/contracts/*/evm/abi/*.bin
generates:
- ./pkg/chain/contracts/*/evm/abi/*.go

# ************ docker ************
build:docker:
desc: Build the docker image for the kwild
Expand Down
2 changes: 1 addition & 1 deletion cmd/kwil-cli/cmds/common/roundtripper.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func DialClient(ctx context.Context, flags uint8, fn RoundTripper) error {
}

options := []client.ClientOpt{}

// We were previously mixing up the eth rpc url with the cometBFT RPC url. Do we need to set it here?

if flags&WithoutPrivateKey == 0 {
Expand Down
6 changes: 4 additions & 2 deletions cmd/kwil-cli/cmds/database/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ func UnmarshalJson(file *os.File) (*transactions.Schema, error) {

// parseComments parses the comments from the file
// and returns the bytes of the file without the comments
func parseComments(file *os.File) ([]byte, error) {
// @brennanjs remove?
func parseComments(file *os.File) ([]byte, error) { //nolint:unused
reader := bufio.NewReader(file)
var result bytes.Buffer
for {
Expand All @@ -132,7 +133,8 @@ func parseComments(file *os.File) ([]byte, error) {
}

// removeComments removes the comments from the line
func removeComments(line string) string {
// @brennanjs remove?
func removeComments(line string) string { //nolint:unused
// Check if the line contains a comment
if idx := strings.Index(line, "//"); idx != -1 {
// Check if the comment is within a string (either single, double, or backtick quotes)
Expand Down
3 changes: 2 additions & 1 deletion cmd/kwil-cli/cmds/database/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ func createActionInputs(inputs []map[string]any, action *transactions.Action) ([
return tuples, nil
}

func printActionResults(results []map[string]any) {
// @brennanjs unused, remove, comment, or leave the nolint tag?
func printActionResults(results []map[string]any) { //nolint:unused
for _, row := range results {
for k, v := range row {
fmt.Printf("%s: %v", k, v)
Expand Down
9 changes: 5 additions & 4 deletions cmd/kwil-cli/cmds/system/version.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package system

import (
"github.com/kwilteam/kwil-db/internal/pkg/build"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/tonistiigi/go-rosetta"
"html/template"
"os"
"runtime"
"text/tabwriter"

"github.com/kwilteam/kwil-db/internal/pkg/build"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/tonistiigi/go-rosetta"
)

var versionTemplate = `
Expand Down
3 changes: 2 additions & 1 deletion cmd/kwil-cli/cmds/utils/printConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package utils

import (
"fmt"
"github.com/kwilteam/kwil-db/cmd/kwil-cli/config"
"reflect"

"github.com/kwilteam/kwil-db/cmd/kwil-cli/config"

"github.com/spf13/cobra"
)

Expand Down
3 changes: 2 additions & 1 deletion cmd/kwil-cli/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package main

import (
"github.com/kwilteam/kwil-db/cmd/kwil-cli/app"
"os"

"github.com/kwilteam/kwil-db/cmd/kwil-cli/app"
)

func main() {
Expand Down
3 changes: 2 additions & 1 deletion cmd/kwild/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package main

import (
"github.com/kwilteam/kwil-db/internal/app/kwild"
"os"

"github.com/kwilteam/kwil-db/internal/app/kwild"
)

func main() {
Expand Down
8 changes: 1 addition & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230512164433-5d1fd1a340c9
github.com/buger/jsonparser v1.1.1
github.com/cstockton/go-conv v1.0.0
github.com/docker/go-connections v0.4.0
github.com/ethereum/go-ethereum v1.12.0
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.5
github.com/grpc-ecosystem/grpc-gateway/v2 v2.12.0
Expand All @@ -31,7 +30,6 @@ require (
golang.org/x/sync v0.2.0
google.golang.org/genproto/googleapis/api v0.0.0-20230706204954-ccb25ca9f130
google.golang.org/grpc v1.56.2
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0
google.golang.org/protobuf v1.31.0
)

Expand Down Expand Up @@ -70,6 +68,7 @@ require (
github.com/docker/compose/v2 v2.17.3 // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/fsnotify/fsevents v0.1.1 // indirect
Expand Down Expand Up @@ -118,7 +117,6 @@ require (
github.com/moby/sys/symlink v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20230110094441-db37f07504ce // indirect
github.com/onsi/gomega v1.16.0 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
Expand Down Expand Up @@ -172,7 +170,6 @@ require (
require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/btcutil v1.1.3 // indirect
Expand All @@ -188,7 +185,6 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
github.com/golang/glog v1.1.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
Expand All @@ -215,13 +211,11 @@ require (
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/shirou/gopsutil v3.21.5+incompatible // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/tklauser/go-sysconf v0.3.6 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.11.0 // indirect
Expand Down
Loading
Loading