mirror of
https://github.com/ent/ent.git
synced 2026-04-28 05:30:56 +03:00
ent/circleci: adding linter tests
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/80 Reviewed By: a8m Differential Revision: D17837182 fbshipit-source-id: 9fb539fd6cebc064d2d2804bd52e0fbf413cfc93
This commit is contained in:
committed by
Facebook Github Bot
parent
fdf98f3b8d
commit
ce2bc07c1a
@@ -1,17 +1,41 @@
|
||||
version: 2.1
|
||||
|
||||
aliases:
|
||||
- &getmods
|
||||
run:
|
||||
name: Downloading go modules
|
||||
command: go mod download
|
||||
|
||||
- &mktestdir
|
||||
run:
|
||||
name: Create results directory
|
||||
command: mkdir -p ~/test-results
|
||||
|
||||
- &storetestdir
|
||||
store_test_results:
|
||||
path: ~/test-results
|
||||
|
||||
orbs:
|
||||
aws-cli: circleci/aws-cli@0.1.13
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
docker:
|
||||
- image: golangci/golangci-lint
|
||||
steps:
|
||||
- checkout
|
||||
- *mktestdir
|
||||
- run:
|
||||
name: Run linters
|
||||
command: golangci-lint run --out-format junit-xml > ~/test-results/lint.xml
|
||||
- *storetestdir
|
||||
unit:
|
||||
docker:
|
||||
- image: circleci/golang
|
||||
steps:
|
||||
- checkout
|
||||
- run: &mktestdir
|
||||
name: Create results directory
|
||||
command: mkdir -p ~/test-results
|
||||
- *mktestdir
|
||||
- *getmods
|
||||
- run:
|
||||
name: Dialect tests
|
||||
command: gotestsum --junitfile ~/test-results/dialect.xml
|
||||
@@ -28,8 +52,8 @@ jobs:
|
||||
name: Codegen tests
|
||||
command: gotestsum --junitfile ~/test-results/gen.xml
|
||||
working_directory: entc/gen
|
||||
- store_test_results:
|
||||
path: ~/test-results
|
||||
- *storetestdir
|
||||
|
||||
integration:
|
||||
docker:
|
||||
- image: circleci/golang
|
||||
@@ -58,13 +82,14 @@ jobs:
|
||||
-wait tcp://localhost:3307
|
||||
-wait tcp://localhost:3308
|
||||
-wait tcp://localhost:8182
|
||||
- run: *mktestdir
|
||||
- *mktestdir
|
||||
- *getmods
|
||||
- run:
|
||||
name: Run integration tests
|
||||
working_directory: entc/integration
|
||||
command: gotestsum --junitfile ~/test-results/integration.xml -- -race ./...
|
||||
- store_test_results:
|
||||
path: ~/test-results
|
||||
- *storetestdir
|
||||
|
||||
docs:
|
||||
docker:
|
||||
- image: circleci/node
|
||||
@@ -99,13 +124,10 @@ workflows:
|
||||
version: 2.1
|
||||
all:
|
||||
jobs:
|
||||
- lint
|
||||
- unit
|
||||
- integration:
|
||||
requires:
|
||||
- unit
|
||||
- integration
|
||||
- docs:
|
||||
requires:
|
||||
- integration
|
||||
filters:
|
||||
branches:
|
||||
only: master
|
||||
|
||||
57
.golangci.yml
Normal file
57
.golangci.yml
Normal file
@@ -0,0 +1,57 @@
|
||||
run:
|
||||
tests: true
|
||||
deadline: 2m
|
||||
|
||||
linters-settings:
|
||||
errcheck:
|
||||
ignore: fmt:.*,Read|Write|Close|Exec,io:Copy
|
||||
dupl:
|
||||
threshold: 100
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- bodyclose
|
||||
- deadcode
|
||||
- depguard
|
||||
- dupl
|
||||
- errcheck
|
||||
- gocritic
|
||||
- gofmt
|
||||
- gosec
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- interfacer
|
||||
- misspell
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- stylecheck
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unused
|
||||
- varcheck
|
||||
|
||||
issues:
|
||||
exclude-rules:
|
||||
- path: _test\.go
|
||||
linters:
|
||||
- dupl
|
||||
- gosec
|
||||
- linters:
|
||||
- unused
|
||||
source: ent.Schema
|
||||
- path: entc/integration/ent/schema/card.go
|
||||
text: "`internal` is unused"
|
||||
- path: dialect/sql/builder.go
|
||||
text: "can be `Querier`"
|
||||
linters:
|
||||
- interfacer
|
||||
- path: dialect/sql/builder.go
|
||||
text: "SQL string concatenation"
|
||||
linters:
|
||||
- gosec
|
||||
- path: dialect/sql/schema/migrate.go
|
||||
text: "weak cryptographic primitive"
|
||||
linters:
|
||||
- gosec
|
||||
@@ -104,10 +104,11 @@ func (d *Dialer) Dial(uri string) (*Conn, error) {
|
||||
|
||||
// DialContext creates a new Gremlin connection.
|
||||
func (d *Dialer) DialContext(ctx context.Context, uri string) (*Conn, error) {
|
||||
c, _, err := d.Dialer.DialContext(ctx, uri, nil)
|
||||
c, rsp, err := d.Dialer.DialContext(ctx, uri, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "gremlin: dialing uri %s", uri)
|
||||
}
|
||||
defer rsp.Body.Close()
|
||||
|
||||
conn := &Conn{
|
||||
conn: c,
|
||||
@@ -168,7 +169,7 @@ func (c *Conn) Execute(ctx context.Context, req *gremlin.Request) (*gremlin.Resp
|
||||
// Close connection with a Gremlin server.
|
||||
func (c *Conn) Close() error {
|
||||
c.grp.Go(func() error { return ErrConnClosed })
|
||||
c.grp.Wait()
|
||||
_ = c.grp.Wait()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -112,11 +112,12 @@ func TemplateGlob(pattern string) Option {
|
||||
// TemplateDir parses the template definitions from the files in the directory
|
||||
// and associates the resulting templates with codegen templates.
|
||||
func TemplateDir(path string) Option {
|
||||
return templateOption(func(cfg *gen.Config) (err error) {
|
||||
return filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
|
||||
return templateOption(func(cfg *gen.Config) error {
|
||||
return filepath.Walk(path, func(path string, info os.FileInfo, _ error) error {
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
var err error
|
||||
cfg.Template, err = cfg.Template.ParseFiles(path)
|
||||
return err
|
||||
})
|
||||
|
||||
@@ -90,7 +90,7 @@ func (g *Graph) Gen() (err error) {
|
||||
check(writeFile(target, b.Bytes()), "write file %s", target)
|
||||
}
|
||||
}
|
||||
for _, tmpl := range append(GraphTemplates[:], external...) {
|
||||
for _, tmpl := range append(GraphTemplates, external...) {
|
||||
if tmpl.Skip != nil && tmpl.Skip(g) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ var (
|
||||
}
|
||||
// operations per type.
|
||||
boolOps = []Op{EQ, NEQ}
|
||||
enumOps = append(boolOps[:], In, NotIn)
|
||||
numericOps = append(enumOps[:], GT, GTE, LT, LTE)
|
||||
stringOps = append(numericOps[:], Contains, HasPrefix, HasSuffix)
|
||||
enumOps = append(boolOps, In, NotIn)
|
||||
numericOps = append(enumOps, GT, GTE, LT, LTE)
|
||||
stringOps = append(numericOps, Contains, HasPrefix, HasSuffix)
|
||||
nillableOps = []Op{IsNil, NotNil}
|
||||
)
|
||||
|
||||
@@ -57,9 +57,7 @@ func (User) Indexes() []ent.Index {
|
||||
}
|
||||
}
|
||||
|
||||
type Group struct {
|
||||
ent.Schema
|
||||
}
|
||||
type Group struct{ ent.Schema }
|
||||
|
||||
func (Group) Fields() []ent.Field { return nil }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user