Skip to content

Commit

Permalink
Merge pull request #46 from Lorenzo-Protocol/sheldon/chore
Browse files Browse the repository at this point in the history
chore(ci): add github workflow
  • Loading branch information
oris0alden authored Jun 14, 2024
2 parents bf0898b + 7aeb700 commit c8314e4
Show file tree
Hide file tree
Showing 71 changed files with 355 additions and 166 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Dockerfile
dymension-testnet.pem
build/
vendor/
.github
.gitignore
41 changes: 41 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "CodeQL"

on:
pull_request:
paths:
- "**.go"
push:
# The branches below must be a subset of the branches above
branches:
- main
- release/**
paths:
- "**.go"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "1.20"
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: "go"
queries: crypto-com/cosmos-sdk-codeql@main,security-and-quality

- name: Build
run: make build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
32 changes: 32 additions & 0 deletions .github/workflows/golangci_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- main
pull_request:

jobs:
golangci:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "1.20"
check-latest: true
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/*.go
go.mod
go.sum
**/go.mod
**/go.sum
- name: run linting
if: env.GIT_DIFF
run: |
make lint
65 changes: 65 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
run:
concurrency: 4
timeout: 5m
tests: true
modules-download-mode: readonly

output:
# Format: colored-line-number|line-number|json|colored-tab|tab|checkstyle|code-climate|junit-xml|github-actions|teamcity
#
# Multiple can be specified by separating them by comma, output can be provided
# for each of them by separating format name and path by colon symbol.
# Output path can be either `stdout`, `stderr` or path to the file to write to.
# Example: "checkstyle:report.xml,json:stdout,colored-line-number"
#
# Default: colored-line-number
format: colored-line-number
# Print lines of code with issue.
# Default: true
print-issued-lines: true
# Print linter name in the end of issue text.
# Default: true
print-linter-name: true
# Make issues output unique by line.
# Default: true
uniq-by-line: true
# Add a prefix to the output file references.
# Default: ""
path-prefix: ""
# Sort results by: filepath, line and column.
# Default: false
sort-results: true

linters:
disable-all: true
enable:
- errcheck
- gocyclo
- gofmt
- gofumpt
- goimports
- gosec
- gosimple
- govet
- ineffassign
- misspell
- revive
- staticcheck
- typecheck
- unconvert
- unused
- errorlint

issues:
exclude-use-default: false
exclude:
- "^.*SA1019.*$" # Excluding SA1019 errors

linters-settings:
revive:
rules:
- name: exported
severity: warning
disabled: true
errcheck:
check-type-assertions: true
24 changes: 24 additions & 0 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"default": true
"MD001": false
"MD004": false
"MD007":
"indent": 4
"MD024":
"siblings_only": true
"MD025": false
"MD026":
"punctuation": ".;:"
"MD029": false
"MD033": false
"MD034": false
"MD036": false
"MD040": false
"MD041": false
"MD051": false
"MD049":
"style": "asterisk"
"MD013":
"line_length": 120
"code_blocks": false
"tables": false
"no-hard-tabs": false
1 change: 1 addition & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHANGELOG.md
61 changes: 61 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,64 @@ proto-lint:
proto-check-breaking:
@echo "Checking Protobuf files for breaking changes"
$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main

###############################################################################
### Releasing ###
###############################################################################

PACKAGE_NAME:=github.com/Lorenzo-Protocol/lorenzo
GOLANG_CROSS_VERSION = v1.20
GOPATH ?= '$(HOME)/go'
release-dry-run:
docker run \
--rm \
--privileged \
-e CGO_ENABLED=1 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-v ${GOPATH}/pkg:/go/pkg \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--clean --skip-validate --skip-publish --snapshot

release:
@if [ ! -f ".release-env" ]; then \
echo "\033[91m.release-env is required for release\033[0m";\
exit 1;\
fi
docker run \
--rm \
--privileged \
-e CGO_ENABLED=1 \
--env-file .release-env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --clean --skip-validate

.PHONY: release-dry-run release


###############################################################################
### Linting ###
###############################################################################
golangci_lint_cmd=golangci-lint
golangci_version=v1.53.3

lint:
@echo "--> Running linter"
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
@$(golangci_lint_cmd) run --timeout=10m

lint-fix:
@echo "--> Running linter"
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
@$(golangci_lint_cmd) run --fix --out-format=tab --issues-exit-code=0

format:
@go install mvdan.cc/gofumpt@latest
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name "*.pb.go" -not -name "*.pb.gw.go" -not -name "*.pulsar.go" -not -path "./crypto/keys/secp256k1/*" | xargs gofumpt -w -l
$(golangci_lint_cmd) run --fix
.PHONY: format
1 change: 0 additions & 1 deletion app/ante/btc_validation_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func newBtcValidationDecorator(
}

func (bvd BtcValidationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {

// only do this validation when handling mempool addition. During DeliverTx they
// should be performed by btclightclient and btccheckpoint modules
if ctx.IsCheckTx() || ctx.IsReCheckTx() {
Expand Down
4 changes: 1 addition & 3 deletions app/ante/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
ethante.NewEthSetUpContextDecorator(options.EvmKeeper),

//FIXME: need to allow universal fees for Eth as well
// FIXME: need to allow universal fees for Eth as well
ethante.NewEthMempoolFeeDecorator(options.EvmKeeper), // Check eth effective gas price against minimal-gas-prices
ethante.NewEthMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper), // Check eth effective gas price against the global MinGasPrice

Expand All @@ -33,7 +33,6 @@ func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
// newLegacyCosmosAnteHandlerEip712 creates an AnteHandler to process legacy EIP-712
// transactions, as defined by the presence of an ExtensionOptionsWeb3Tx extension.
func newLegacyCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {

return sdk.ChainAnteDecorators(
NewRejectMessagesDecorator(), // reject MsgEthereumTxs and vesting messages
ethante.NewAuthzLimiterDecorator([]string{ // disable the Msg types that cannot be included on an authz.MsgExec msgs field
Expand Down Expand Up @@ -62,7 +61,6 @@ func newLegacyCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {
}

func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {

return sdk.ChainAnteDecorators(
NewRejectMessagesDecorator(), // reject MsgEthereumTxs and vesting msgs
ethante.NewAuthzLimiterDecorator([]string{ // disable the Msg types that cannot be included on an authz.MsgExec msgs field
Expand Down
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ func NewLorenzoApp(
keys: keys,
tkeys: tkeys,
memKeys: memKeys,
invCheckPeriod: invCheckPeriod,
}

app.ParamsKeeper = initParamsKeeper(
Expand Down Expand Up @@ -494,8 +495,7 @@ func NewLorenzoApp(
app.EvmKeeper,
)

var transferStack ibcporttypes.IBCModule
transferStack = ibctransfer.NewIBCModule(app.TransferKeeper)
transferStack := ibctransfer.NewIBCModule(app.TransferKeeper)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ func CreateTestAddrs(numAddrs int) []sdk.AccAddress {
// start at 100 so we can make up to 999 test addresses with valid test addresses
for i := 100; i < (numAddrs + 100); i++ {
numString := strconv.Itoa(i)
buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") //base address string
buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") // base address string

buffer.WriteString(numString) //adding on final two digits to make addresses unique
buffer.WriteString(numString) // adding on final two digits to make addresses unique
res, _ := sdk.AccAddressFromHexUnsafe(buffer.String())
bech := res.String()
addresses = append(addresses, testAddr(buffer.String(), bech))
Expand Down
8 changes: 4 additions & 4 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func getGovProposalHandlers() []govclient.ProposalHandler {

govProposalHandlers = append(govProposalHandlers,
paramsclient.ProposalHandler,
//distrclient.ProposalHandler,
// distrclient.ProposalHandler,
upgradeclient.LegacyProposalHandler,
upgradeclient.LegacyCancelProposalHandler,
ibcclientclient.UpdateClientProposalHandler,
Expand Down Expand Up @@ -267,7 +267,7 @@ func orderBeginBlockers() []string {
paramstypes.ModuleName,
vestingtypes.ModuleName,

//self module
// self module
btclightclienttypes.ModuleName,
btcstakingtypes.ModuleName,
feetypes.ModuleName,
Expand Down Expand Up @@ -307,7 +307,7 @@ func orderEndBlockers() []string {
upgradetypes.ModuleName,
vestingtypes.ModuleName,

//self module
// self module
btclightclienttypes.ModuleName,
btcstakingtypes.ModuleName,
feetypes.ModuleName,
Expand Down Expand Up @@ -350,7 +350,7 @@ func orderInitBlockers() []string {
genutiltypes.ModuleName,
evidencetypes.ModuleName,

//self module
// self module

btclightclienttypes.ModuleName,
btcstakingtypes.ModuleName,
Expand Down
1 change: 0 additions & 1 deletion app/params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func RegisterDenoms() {
}

func SetAddressPrefixes() {

// Set config
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub)
Expand Down
4 changes: 1 addition & 3 deletions app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

var (
plans = []upgrades.Upgrade{}
)
var plans = []upgrades.Upgrade{}

// RegisterUpgradePlans register a handler of upgrade plan
func (app *LorenzoApp) RegisterUpgradePlans() {
Expand Down
1 change: 0 additions & 1 deletion cmd/lorenzod/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig appparams.EncodingConfig
txCommand(),
ethermintclient.KeyCommands(app.DefaultNodeHome),
)

}

// queryCommand returns the sub-command to send queries to the app
Expand Down
7 changes: 4 additions & 3 deletions cmd/lorenzod/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"os"

"github.com/Lorenzo-Protocol/lorenzo/app"
Expand All @@ -12,10 +13,10 @@ import (
func main() {
rootCmd, _ := cmd.NewRootCmd()
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
switch e := err.(type) {
case server.ErrorCode:
var e server.ErrorCode
switch {
case errors.As(err, &e):
os.Exit(e.Code)

default:
os.Exit(1)
}
Expand Down
1 change: 0 additions & 1 deletion contracts/yieldaccruingtoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ var (
)

func init() {

// contract code
// https://github.com/Lorenzo-Protocol/builtin-contracts/blob/main/contracts/YieldAccruingToken.sol
err := json.Unmarshal(YieldAccruingTokenJSON, &YieldAccruingTokenContract)
Expand Down
Loading

0 comments on commit c8314e4

Please sign in to comment.