Pre-commit and Makefile improvements #68
10 changed files with 49 additions and 50 deletions
10
.gitlint
10
.gitlint
|
@ -1,10 +0,0 @@
|
||||||
[general]
|
|
||||||
fail-without-commits=true
|
|
||||||
contrib=CC1
|
|
||||||
|
|
||||||
[title-match-regex]
|
|
||||||
regex=^\[\#[0-9Xx]+\]\s
|
|
||||||
|
|
||||||
[ignore-by-title]
|
|
||||||
regex=^Release(.*)
|
|
||||||
ignore=title-match-regex
|
|
|
@ -18,13 +18,25 @@ repos:
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
exclude: ".key$"
|
exclude: ".key$"
|
||||||
|
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: gofumpt
|
||||||
|
name: gofumpt
|
||||||
|
entry: make fumpt
|
||||||
|
pass_filenames: false
|
||||||
|
types: [go]
|
||||||
|
language: system
|
||||||
|
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: go-unit-tests
|
||||||
|
name: go unit tests
|
||||||
|
entry: make test GOFLAGS=''
|
||||||
|
pass_filenames: false
|
||||||
|
types: [go]
|
||||||
|
language: system
|
||||||
|
|
||||||
- repo: https://github.com/golangci/golangci-lint
|
- repo: https://github.com/golangci/golangci-lint
|
||||||
rev: v1.51.2
|
rev: v1.56.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: golangci-lint
|
- id: golangci-lint
|
||||||
|
|
||||||
- repo: https://github.com/jorisroovers/gitlint
|
|
||||||
rev: v0.18.0
|
|
||||||
hooks:
|
|
||||||
- id: gitlint
|
|
||||||
stages: [commit-msg]
|
|
||||||
|
|
24
Makefile
24
Makefile
|
@ -3,40 +3,35 @@ SHELL = bash
|
||||||
|
|
||||||
VERSION ?= $(shell git describe --tags --match "v*" --abbrev=8 --dirty --always)
|
VERSION ?= $(shell git describe --tags --match "v*" --abbrev=8 --dirty --always)
|
||||||
|
|
||||||
.PHONY: dep fmts fmt imports protoc test lint version help
|
.PHONY: dep fmts fumpt imports protoc test lint version help
|
||||||
|
|
||||||
# Pull go dependencies
|
# Pull go dependencies
|
||||||
dep:
|
dep:
|
||||||
@printf "⇒ Tidy requirements : "
|
@printf "⇒ Tidy requirements : "
|
||||||
CGO_ENABLED=0 \
|
CGO_ENABLED=0 \
|
||||||
GO111MODULE=on \
|
|
||||||
go mod tidy -v && echo OK
|
go mod tidy -v && echo OK
|
||||||
@printf "⇒ Download requirements: "
|
@printf "⇒ Download requirements: "
|
||||||
CGO_ENABLED=0 \
|
CGO_ENABLED=0 \
|
||||||
GO111MODULE=on \
|
|
||||||
go mod download && echo OK
|
go mod download && echo OK
|
||||||
@printf "⇒ Install test requirements: "
|
@printf "⇒ Install test requirements: "
|
||||||
CGO_ENABLED=0 \
|
CGO_ENABLED=0 \
|
||||||
GO111MODULE=on \
|
|
||||||
go test ./... && echo OK
|
go test ./... && echo OK
|
||||||
|
|
||||||
# Run all code formatters
|
# Run all code formatters
|
||||||
fmts: fmt imports
|
fmts: fumpt imports
|
||||||
|
|
||||||
# Reformat code
|
|
||||||
fmt:
|
|
||||||
@echo "⇒ Processing gofmt check"
|
|
||||||
@for f in `find . -type f -name '*.go' -not -path './vendor/*' -not -name '*.pb.go' -prune`; do \
|
|
||||||
GO111MODULE=on gofmt -s -w $$f; \
|
|
||||||
done
|
|
||||||
|
|
||||||
# Reformat imports
|
# Reformat imports
|
||||||
imports:
|
imports:
|
||||||
@echo "⇒ Processing goimports check"
|
@echo "⇒ Processing goimports check"
|
||||||
@for f in `find . -type f -name '*.go' -not -path './vendor/*' -not -name '*.pb.go' -prune`; do \
|
@for f in `find . -type f -name '*.go' -not -path './vendor/*' -not -name '*.pb.go' -prune`; do \
|
||||||
GO111MODULE=on goimports -w $$f; \
|
goimports -w $$f; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Run gofumpt
|
||||||
|
fumpt:
|
||||||
|
@echo "⇒ Processing gofumpt check"
|
||||||
|
@gofumpt -l -w .
|
||||||
|
|
||||||
# Regenerate code for proto files
|
# Regenerate code for proto files
|
||||||
protoc:
|
protoc:
|
||||||
@GOPRIVATE=github.com/TrueCloudLab go mod vendor
|
@GOPRIVATE=github.com/TrueCloudLab go mod vendor
|
||||||
|
@ -54,9 +49,10 @@ protoc:
|
||||||
rm -rf vendor
|
rm -rf vendor
|
||||||
|
|
||||||
# Run Unit Test with go test
|
# Run Unit Test with go test
|
||||||
|
test: GOFLAGS ?= "-count=1"
|
||||||
test:
|
test:
|
||||||
@echo "⇒ Running go test"
|
@echo "⇒ Running go test"
|
||||||
@GO111MODULE=on go test ./... -count=1
|
@GOFLAGS="$(GOFLAGS)" go test ./...
|
||||||
|
|
||||||
# Run linters
|
# Run linters
|
||||||
lint:
|
lint:
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
func TestSetNotification(t *testing.T) {
|
func TestSetNotification(t *testing.T) {
|
||||||
o := new(Object)
|
o := new(Object)
|
||||||
|
|
||||||
var ni = NotificationInfo{
|
ni := NotificationInfo{
|
||||||
epoch: 10,
|
epoch: 10,
|
||||||
topic: "test",
|
topic: "test",
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,8 +318,7 @@ type PutSingleRequest struct {
|
||||||
session.RequestHeaders
|
session.RequestHeaders
|
||||||
}
|
}
|
||||||
|
|
||||||
type PutSingleResponseBody struct {
|
type PutSingleResponseBody struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type PutSingleResponse struct {
|
type PutSingleResponse struct {
|
||||||
body *PutSingleResponseBody
|
body *PutSingleResponseBody
|
||||||
|
|
|
@ -632,7 +632,8 @@ func (r *ResponseMetaHeader) SetStatus(v *status.Status) {
|
||||||
func SetStatus(msg interface {
|
func SetStatus(msg interface {
|
||||||
GetMetaHeader() *ResponseMetaHeader
|
GetMetaHeader() *ResponseMetaHeader
|
||||||
SetMetaHeader(*ResponseMetaHeader)
|
SetMetaHeader(*ResponseMetaHeader)
|
||||||
}, st *status.Status) {
|
}, st *status.Status,
|
||||||
|
) {
|
||||||
meta := msg.GetMetaHeader()
|
meta := msg.GetMetaHeader()
|
||||||
if meta == nil {
|
if meta == nil {
|
||||||
meta = new(ResponseMetaHeader)
|
meta = new(ResponseMetaHeader)
|
||||||
|
|
|
@ -43,7 +43,8 @@ func (c *RequestHeaders) SetVerificationHeader(v *RequestVerificationHeader) {
|
||||||
func (c *RequestHeaders) ToMessage(m interface {
|
func (c *RequestHeaders) ToMessage(m interface {
|
||||||
SetMetaHeader(*session.RequestMetaHeader)
|
SetMetaHeader(*session.RequestMetaHeader)
|
||||||
SetVerifyHeader(*session.RequestVerificationHeader)
|
SetVerifyHeader(*session.RequestVerificationHeader)
|
||||||
}) {
|
},
|
||||||
|
) {
|
||||||
m.SetMetaHeader(c.metaHeader.ToGRPCMessage().(*session.RequestMetaHeader))
|
m.SetMetaHeader(c.metaHeader.ToGRPCMessage().(*session.RequestMetaHeader))
|
||||||
m.SetVerifyHeader(c.verifyHeader.ToGRPCMessage().(*session.RequestVerificationHeader))
|
m.SetVerifyHeader(c.verifyHeader.ToGRPCMessage().(*session.RequestVerificationHeader))
|
||||||
}
|
}
|
||||||
|
@ -51,7 +52,8 @@ func (c *RequestHeaders) ToMessage(m interface {
|
||||||
func (c *RequestHeaders) FromMessage(m interface {
|
func (c *RequestHeaders) FromMessage(m interface {
|
||||||
GetMetaHeader() *session.RequestMetaHeader
|
GetMetaHeader() *session.RequestMetaHeader
|
||||||
GetVerifyHeader() *session.RequestVerificationHeader
|
GetVerifyHeader() *session.RequestVerificationHeader
|
||||||
}) error {
|
},
|
||||||
|
) error {
|
||||||
metaHdr := m.GetMetaHeader()
|
metaHdr := m.GetMetaHeader()
|
||||||
if metaHdr == nil {
|
if metaHdr == nil {
|
||||||
c.metaHeader = nil
|
c.metaHeader = nil
|
||||||
|
@ -122,7 +124,8 @@ func (c *ResponseHeaders) SetVerificationHeader(v *ResponseVerificationHeader) {
|
||||||
func (c *ResponseHeaders) ToMessage(m interface {
|
func (c *ResponseHeaders) ToMessage(m interface {
|
||||||
SetMetaHeader(*session.ResponseMetaHeader)
|
SetMetaHeader(*session.ResponseMetaHeader)
|
||||||
SetVerifyHeader(*session.ResponseVerificationHeader)
|
SetVerifyHeader(*session.ResponseVerificationHeader)
|
||||||
}) {
|
},
|
||||||
|
) {
|
||||||
m.SetMetaHeader(c.metaHeader.ToGRPCMessage().(*session.ResponseMetaHeader))
|
m.SetMetaHeader(c.metaHeader.ToGRPCMessage().(*session.ResponseMetaHeader))
|
||||||
m.SetVerifyHeader(c.verifyHeader.ToGRPCMessage().(*session.ResponseVerificationHeader))
|
m.SetVerifyHeader(c.verifyHeader.ToGRPCMessage().(*session.ResponseVerificationHeader))
|
||||||
}
|
}
|
||||||
|
@ -130,7 +133,8 @@ func (c *ResponseHeaders) ToMessage(m interface {
|
||||||
func (c *ResponseHeaders) FromMessage(m interface {
|
func (c *ResponseHeaders) FromMessage(m interface {
|
||||||
GetMetaHeader() *session.ResponseMetaHeader
|
GetMetaHeader() *session.ResponseMetaHeader
|
||||||
GetVerifyHeader() *session.ResponseVerificationHeader
|
GetVerifyHeader() *session.ResponseVerificationHeader
|
||||||
}) error {
|
},
|
||||||
|
) error {
|
||||||
metaHdr := m.GetMetaHeader()
|
metaHdr := m.GetMetaHeader()
|
||||||
if metaHdr == nil {
|
if metaHdr == nil {
|
||||||
c.metaHeader = nil
|
c.metaHeader = nil
|
||||||
|
|
|
@ -50,9 +50,7 @@ func (s *stablePrimitives) stableMarshal(buf []byte, wrongField bool) ([]byte, e
|
||||||
buf = make([]byte, s.stableSize())
|
buf = make([]byte, s.stableSize())
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var i, offset, fieldNum int
|
||||||
i, offset, fieldNum int
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldNum = 1
|
fieldNum = 1
|
||||||
if wrongField {
|
if wrongField {
|
||||||
|
|
|
@ -109,5 +109,4 @@ func TestVerifyNeonWallet(t *testing.T) {
|
||||||
}
|
}
|
||||||
require.True(t, VerifyMessage(nil, sm))
|
require.True(t, VerifyMessage(nil, sm))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue