Skip to content

Commit ff4330b

Browse files
committed
add ci, makefile, linter, etc.
1 parent 58dbde3 commit ff4330b

8 files changed

Lines changed: 244 additions & 2 deletions

File tree

.github/workflows/golangci.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Lint codebase
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
golangci:
13+
name: lint
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repo
17+
uses: actions/checkout@v4
18+
19+
20+
- name: Setup Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version-file: go.mod
24+
25+
- name: golangci-lint
26+
uses: golangci/golangci-lint-action@v8
27+
with:
28+
version: v2.2.2
29+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Markdown Link Check
2+
on:
3+
pull_request:
4+
jobs:
5+
link-check:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
- uses: gaurav-nelson/github-action-markdown-link-check@1.0.15

.github/workflows/spell-check.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Spell Check
2+
on:
3+
pull_request:
4+
paths:
5+
- '**/*.md'
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
spellcheck:
12+
name: Run codespell
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.x'
21+
- name: Install codespell
22+
run: pip install codespell
23+
- name: Run codespell for codebase
24+
run: codespell --skip="*/go.mod,*/go.sum"
25+
- name: Run codespell for doc
26+
run: |
27+
codespell README.md

.github/workflows/vuln_nancy.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Scan Vulnerabilities
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'go.mod'
7+
- 'go.sum'
8+
9+
jobs:
10+
nancy-scan:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version-file: go.mod
21+
22+
- name: Run Nancy vulnerability scanner
23+
run: make nancy
24+
25+
vulncheck:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Go
33+
uses: actions/setup-go@v5
34+
with:
35+
go-version-file: go.mod
36+
37+
- name: Run vulncheck
38+
run: go tool govulncheck ./...

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,8 @@ go.work.sum
2828
.env
2929

3030
# Editor/IDE
31-
# .idea/
32-
# .vscode/
31+
.idea/
32+
.vscode/
33+
34+
# Build
35+
build/

.golangci.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
version: '2'
2+
run:
3+
allow-parallel-runners: true
4+
linters:
5+
default: standard
6+
enable:
7+
- containedctx
8+
- contextcheck
9+
- dupword
10+
- embeddedstructfieldcheck
11+
- errchkjson
12+
- errname
13+
- errorlint
14+
- exhaustive
15+
- forcetypeassert
16+
- funcorder
17+
- goconst
18+
- gocritic
19+
- godot
20+
- godox
21+
- gosec
22+
- misspell
23+
- intrange
24+
- musttag
25+
- makezero
26+
- nilerr
27+
- nilnesserr
28+
- nilnil
29+
- nlreturn
30+
- noctx
31+
- nolintlint
32+
# - paralleltest
33+
- prealloc
34+
- protogetter
35+
- predeclared
36+
- recvcheck
37+
- thelper
38+
# - tparallel
39+
- unconvert
40+
- unparam
41+
- whitespace
42+
# - wrapcheck
43+
settings:
44+
goconst:
45+
min-occurrences: 2
46+
numbers: true
47+
govet:
48+
disable:
49+
- fieldalignment
50+
- shadow
51+
enable-all: true
52+
exclusions:
53+
paths:
54+
- .*\.pb\.go
55+
- .*\.pulsar\.go
56+
- api/
57+
formatters:
58+
enable:
59+
- gci
60+
- gofmt
61+
- gofumpt
62+
- golines
63+
settings:
64+
gci:
65+
sections:
66+
- standard
67+
- default
68+
- prefix(github.com/cosmos/,cosmossdk.io/,github.com/cometbft/)
69+
- blank
70+
- dot
71+
- localmodule
72+
custom-order: true
73+
no-inline-comments: true
74+
no-prefix-comments: true
75+
gofmt:
76+
rewrite-rules:
77+
- pattern: 'interface{}'
78+
replacement: 'any'
79+
golines:
80+
shorten-comments: true

.nancy-ignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# CVE-2023-42319 - go-ethereum vulnerability - inherent to protocol, low risk
2+
CVE-2023-42319
3+
4+
# CVE-2015-20112 - go-ethereum old vulnerability - low severity, affects private networks only
5+
CVE-2015-20112
6+
7+
# CVE-2021-43668 - goleveldb vulnerability - affects go-ethereum nodes
8+
CVE-2021-43668

Makefile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.PHONY: build
2+
3+
build:
4+
go build -o ./build/orbgen .
5+
6+
install:
7+
go install -o ./build/orbgen .
8+
9+
#=============================================================================#
10+
# Tooling #
11+
#=============================================================================#
12+
.PHONY: tool-all license format lint vulncheck nancy
13+
14+
# This runs all the common tools like linting, etc.
15+
tool-all : license format lint vulncheck nancy
16+
17+
FILES := $(shell find . -name "*.go" -not -path "./simapp/*" -not -name "*.pb.go" -not -name "*.pb.gw.go" -not -name "*.pulsar.go")
18+
license:
19+
@echo "Adding license to files..."
20+
@go-license --config .github/license.yaml $(FILES)
21+
@echo "Completed license addition!"
22+
23+
check-license:
24+
@echo "Checking files for license..."
25+
@go-license --config .github/license.yaml $(FILES) --verify
26+
27+
GOLANGCI_LINT_VERSION="v2.2.2"
28+
GOLANGCI_LINT_IMAGE=golangci/golangci-lint:$(GOLANGCI_LINT_VERSION)
29+
GOLANGCI_LINT_CMD=docker run --rm -v $(PWD):/app -w /app $(GOLANGCI_LINT_IMAGE) golangci-lint
30+
format:
31+
@echo "Running formatters..."
32+
@$(GOLANGCI_LINT_CMD) fmt -c ./.golangci.yaml
33+
@echo "Completed formatting!"
34+
35+
lint:
36+
@echo "Running linter..."
37+
@$(GOLANGCI_LINT_CMD) run -c ./.golangci.yaml
38+
@$(MAKE) check-license
39+
@echo "Completed linting!"
40+
41+
NANCY_VERSION=v1.0
42+
NANCY_IMAGE=sonatypecommunity/nancy:$(NANCY_VERSION)
43+
NANCY_CMD=docker run --rm -i --volume "$(PWD)":/app --workdir /app $(NANCY_IMAGE)
44+
nancy:
45+
@echo "Running Nancy vulnerability scanner..."
46+
@go list -json -deps ./... | $(NANCY_CMD) sleuth --exclude-vulnerability-file .nancy-ignore
47+
@echo "Completed Nancy vulnerability scan!"
48+

0 commit comments

Comments
 (0)