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

Golang ci #358

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19 # check with 1.19 because it matches dev envs. Does not need to affect go.mod.
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
92 changes: 92 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
run:
tests: true
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m

linters:
disable-all: true
enable:
- depguard
- dogsled
- errcheck
- exportloopref
- goconst
- gocritic
- gofumpt
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- revive
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused

# TODO: fix the sdkerrors.Wrap deprecation warning and re-enable staticcheck
# TODO: fix the use of deprecated gov style

issues:
exclude-rules:
- text: "SA1019: sdkerrors.Register"
linters:
- staticcheck
- text: "sdkerrors.ABCIInfo is deprecated"
linters:
- staticcheck
- text: "sdkerrors.IsOf is deprecated"
linters:
- staticcheck
- text: "Use WeightedProposalMsg instead"
linters:
- staticcheck
- text: "Use MsgSimulatorFn instead"
linters:
- staticcheck
- text: "Error return value of `flagSet.Set` is not checked"
linters:
- errcheck
- text: "SA1019: sdkerrors.Wrapf is deprecated: functionality of this package has been moved to it's own module"
linters:
- staticcheck
- text: "sdkerrors.Error is deprecated: the type has been moved to cosmossdk.io/errors module"
linters:
- staticcheck
- text: "sdkerrors.Wrap is deprecated"
linters:
- staticcheck
- text: "Use of weak random number generator"
linters:
- gosec
- text: "ST1003:"
linters:
- stylecheck
# FIXME: Disabled until golangci-lint updates stylecheck with this fix:
# https://github.com/dominikh/go-tools/issues/389
- text: "ST1016:"
linters:
- stylecheck
- path: "migrations"
text: "SA1019:"
linters:
- staticcheck

max-issues-per-linter: 10000
max-same-issues: 10000

linters-settings:
dogsled:
max-blank-identifiers: 3
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
nolintlint:
allow-unused: false
allow-leading-space: true
require-explanation: false
require-specific: false
18 changes: 10 additions & 8 deletions cmd/demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,33 @@ package main

import (
"fmt"
"io/ioutil"
"os"

wasmvm "github.com/CosmWasm/wasmvm"
)

const (
SUPPORTED_FEATURES = "staking"
PRINT_DEBUG = true
MEMORY_LIMIT = 32 // MiB
CACHE_SIZE = 100 // MiB
SupportedFeatures = "staking"
PrintDebug = true
MemoryLimit = 32 // MiB
CacheSize = 100 // MiB
)

// This is just a demo to ensure we can compile a static go binary
func main() {
file := os.Args[1]
fmt.Printf("Running %s...\n", file)
bz, err := ioutil.ReadFile(file)
bz, err := os.ReadFile(file)
if err != nil {
panic(err)
}
fmt.Println("Loaded!")

os.MkdirAll("tmp", 0o755)
vm, err := wasmvm.NewVM("tmp", SUPPORTED_FEATURES, MEMORY_LIMIT, PRINT_DEBUG, CACHE_SIZE)
err = os.MkdirAll("tmp", 0o755)
if err != nil {
panic(err)
}
vm, err := wasmvm.NewVM("tmp", SupportedFeatures, MemoryLimit, PrintDebug, CacheSize)
if err != nil {
panic(err)
}
Expand Down