Skip to content

Commit 720cc05

Browse files
committed
Add CI
1 parent e943e46 commit 720cc05

File tree

4 files changed

+218
-0
lines changed

4 files changed

+218
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Golangci-lint
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
golangci-lint:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
id-token: write
10+
contents: read
11+
actions: read
12+
steps:
13+
- name: golangci-lint
14+
uses: smartcontractkit/.github/actions/ci-lint-go@2ac9d97a83a5edded09af7fcf4ea5bce7a4473a4 # v0.2.6
15+
with:
16+
golangci-lint-version: v1.62.2

.github/workflows/test.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: PKG Build and Test
2+
3+
on: [push]
4+
5+
jobs:
6+
build-test:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
11+
12+
- name: Set up Go
13+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
14+
with:
15+
go-version-file: "go.mod"
16+
17+
- name: Build
18+
run: go build -v ./...
19+
20+
- name: Unit Tests
21+
run: GORACE="log_path=$PWD/race" go test -race ./... -coverpkg=./... -coverprofile=coverage.txt
22+
23+
- name: Print Races
24+
if: failure()
25+
id: print-races
26+
run: |
27+
find race.* | xargs cat > race.txt
28+
if [[ -s race.txt ]]; then
29+
cat race.txt
30+
fi
31+
32+
- name: Upload Go test results
33+
if: always()
34+
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
35+
with:
36+
name: go-test-results
37+
path: |
38+
./coverage.txt
39+
./race.*
40+
41+
check-tidy:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
46+
- name: Set up Go
47+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
48+
with:
49+
go-version-file: "go.mod"
50+
- name: Ensure "make gomodtidy" has been run
51+
run: |
52+
make gomodtidy
53+
git add --all
54+
git diff --minimal --cached --exit-code
55+
- name: Ensure "make generate" has been run
56+
run: |
57+
make rm-mocked
58+
make rm-builders
59+
make generate
60+
git add --all
61+
git diff --stat --cached --exit-code

.golangci.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
run:
2+
timeout: 15m0s
3+
linters:
4+
enable:
5+
- containedctx
6+
- depguard
7+
- errname
8+
- errorlint
9+
- exhaustive
10+
- exportloopref
11+
- fatcontext
12+
- ginkgolinter
13+
- gocritic
14+
- goimports
15+
- gosec
16+
- loggercheck
17+
- mirror
18+
- misspell
19+
- noctx
20+
- nolintlint
21+
- perfsprint
22+
- prealloc
23+
- revive
24+
- rowserrcheck
25+
- spancheck
26+
- sqlclosecheck
27+
- testifylint
28+
- unconvert
29+
- whitespace
30+
linters-settings:
31+
exhaustive:
32+
default-signifies-exhaustive: true
33+
goimports:
34+
local-prefixes: github.com/smartcontractkit/chainlink
35+
golint:
36+
min-confidence: 1.0
37+
gosec:
38+
excludes:
39+
- G101
40+
- G104
41+
# - G204
42+
# - G304
43+
# - G404
44+
govet:
45+
enable:
46+
- shadow
47+
revive:
48+
confidence: 0.8
49+
rules:
50+
- name: blank-imports
51+
- name: context-as-argument
52+
- name: context-keys-type
53+
- name: dot-imports
54+
- name: error-return
55+
- name: error-strings
56+
- name: error-naming
57+
- name: exported
58+
- name: if-return
59+
- name: increment-decrement
60+
- name: var-naming
61+
- name: var-declaration
62+
- name: package-comments
63+
- name: range
64+
- name: receiver-naming
65+
- name: time-naming
66+
# - name: unexported-return
67+
- name: indent-error-flow
68+
- name: errorf
69+
- name: empty-block
70+
- name: superfluous-else
71+
# - name: unused-parameter
72+
- name: unreachable-code
73+
- name: redefines-builtin-id
74+
- name: waitgroup-by-value
75+
- name: unconditional-recursion
76+
- name: struct-tag
77+
# - name: string-format
78+
- name: string-of-int
79+
- name: range-val-address
80+
- name: range-val-in-closure
81+
- name: modifies-value-receiver
82+
- name: modifies-parameter
83+
- name: identical-branches
84+
- name: get-return
85+
# - name: flag-parameter
86+
- name: early-return
87+
- name: defer
88+
- name: constant-logical-expr
89+
# - name: confusing-naming
90+
# - name: confusing-results
91+
- name: bool-literal-in-expr
92+
- name: atomic
93+
depguard:
94+
rules:
95+
main:
96+
list-mode: lax
97+
deny:
98+
- pkg: cosmossdk.io/errors
99+
desc: Use the standard library instead
100+
- pkg: github.com/gofrs/uuid
101+
desc: Use github.com/google/uuid instead
102+
- pkg: github.com/jackc/pgx3
103+
desc: Use github.com/jackc/pgx4 instead
104+
- pkg: github.com/jackc/pgx5
105+
desc: Use github.com/jackc/pgx4 instead
106+
- pkg: github.com/satori/go.uuid
107+
desc: Use github.com/google/uuid instead
108+
- pkg: github.com/test-go/testify/assert
109+
desc: Use github.com/stretchr/testify/assert instead
110+
- pkg: github.com/test-go/testify/mock
111+
desc: Use github.com/stretchr/testify/mock instead
112+
- pkg: github.com/test-go/testify/require
113+
desc: Use github.com/stretchr/testify/require instead
114+
# TODO https://smartcontract-it.atlassian.net/browse/BCI-2589
115+
# - pkg: go.uber.org/multierr
116+
# desc: Use the standard library instead, for example https://pkg.go.dev/errors#Join
117+
- pkg: gopkg.in/guregu/null.v1
118+
desc: Use gopkg.in/guregu/null.v4 instead
119+
- pkg: gopkg.in/guregu/null.v2
120+
desc: Use gopkg.in/guregu/null.v4 instead
121+
- pkg: gopkg.in/guregu/null.v3
122+
desc: Use gopkg.in/guregu/null.v4 instead
123+
- pkg: github.com/go-gorm/gorm
124+
desc: Use github.com/jmoiron/sqlx directly instead

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
.PHONY: gomods
2+
gomods: ## Install gomods
3+
go install github.com/jmank88/[email protected]
4+
5+
.PHONY: gomodtidy
6+
gomodtidy: gomods
7+
gomods tidy
18

29
.PHONY: mockery
310
mockery: $(mockery) ## Install mockery.
@@ -7,3 +14,13 @@ mockery: $(mockery) ## Install mockery.
714
rm-mocked:
815
grep -rl "^// Code generated by mockery" | grep .go$ | xargs -r rm
916

17+
.PHONY: lint-workspace lint
18+
GOLANGCI_LINT_VERSION := 1.62.2
19+
GOLANGCI_LINT_COMMON_OPTS := --max-issues-per-linter 0 --max-same-issues 0
20+
GOLANGCI_LINT_DIRECTORY := ./golangci-lint
21+
22+
lint-workspace:
23+
@./script/lint.sh $(GOLANGCI_LINT_VERSION) "$(GOLANGCI_LINT_COMMON_OPTS)" $(GOLANGCI_LINT_DIRECTORY)
24+
25+
lint:
26+
@./script/lint.sh $(GOLANGCI_LINT_VERSION) "$(GOLANGCI_LINT_COMMON_OPTS)" $(GOLANGCI_LINT_DIRECTORY) "--new-from-rev=origin/main"

0 commit comments

Comments
 (0)