Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Buzlov Ilya committed Aug 7, 2020
0 parents commit af84cea
Show file tree
Hide file tree
Showing 168 changed files with 7,868 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.idea
.vscode
.tags*
lastupdate.tmp
.DS_Store
dump.rdb
*.out
*.log
bin/*
tests/log
log/*
public/assets
.sass-cache
tmp
*.coverprofile
coverage.*
routers/commentsRouter_____*

# node packages
/node_modules
/flow-typed

# static files by webpack
/views/ui/index.html
/assets/build

# yarn packages manager
yarn-error.log
.env
119 changes: 119 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
run:
timeout: 1m # default 1m

linters-settings:
errcheck:
check-type-assertions: true # default false
check-blank: true # default false
ignore: "fmt:.*" # default fmt:.*
exclude: "" # default ""
govet:
enable-all: true
settings:
shadow:
strict: false # default false # TODO: change to true
structcheck:
exported-fields: false # default false # TODO: change to true
unused:
check-exported: true # default false
varcheck:
exported-fields: true # default false
dupl:
threshold: 150 # default 150
funlen:
lines: 100 # default 60
statements: 40 # default 40
gocognit:
min-complexity: 20 # minimal code complexity to report, 30 by default (but we recommend 10-20)
goconst:
min-len: 3 # default 3
min-occurrences: 3 # default 3
gocritic:
settings:
captLocal:
paramsOnly: false # default true
elseif:
skipBalanced: false # default true
underef:
skipRecvDeref: false # default true
gocyclo:
min-complexity: 30 # default 30
golint:
min-confidence: 0.8 # default 0.8
lll:
line-length: 120 # default 120
maligned:
suggest-new: true # default false
misspell:
locale: us
ignore-words: "" # default: ""
nakedret:
max-func-lines: 0 # default 30
prealloc:
simple: false # default true
range-loops: true # default true
for-loops: false # default false
unparam:
check-exported: true # default false
wsl:
strict-append: true # default true
allow-assign-and-call: true # default true
allow-multiline-assign: true # default true
allow-case-trailing-whitespace: true # default true
allow-cuddle-declarations: false # default false

linters:
disable-all: true
enable:
## enabled by default
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
#- unused # TODO: find out why there are so many false positives
- varcheck
## disabled by default
- bodyclose
- dupl
- funlen
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- goimports
- golint
- gosec
#- lll
- maligned
- misspell
- nakedret
- prealloc
- scopelint
- unconvert
- unparam
- whitespace
#- wsl # TODO: decide do we need this linter
#- depguard # can be used to create a black list of dependencies

issues:
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
- path: storage/
linters: gosec
- path: _test\.go
linters:
- lll
- dupl
- funlen
- goconst
- path: \.gen\.go
linters:
- errcheck
- golint
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: go
dist: xenial
go:
- 1.13
env:
global:
- GO111MODULE=on
install:
- if ! [ -x "$(command -v golangci-lint)" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.21.0; fi
script:
- golangci-lint run
- go test -v -race -p 8 -parallel 8 -coverpkg ./... -coverprofile coverage.out ./...
- go mod tidy
- if [[ `git status --porcelain go.mod` ]]; then git diff -- go.mod ; echo "File 'go.mod' is outdated. Need to run 'go mod tidy' before commit." ; exit 1; fi
- if [[ `git status --porcelain go.sum` ]]; then git diff -- go.sum ; echo "File 'go.sum' is outdated. Need to run 'go mod tidy' before commit." ; exit 1; fi
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2020 Gett

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
lint:
golangci-lint run
.PHONY: lint

test:
go test -race -p 8 -parallel 8 ./...
.PHONY: test

build:
go build -o ${GOPATH}/bin/effe ./cmd/effe/...
.PHONY: build

generate:
go generate ./...
.PHONY: generate

test-cover:
go test -race -p 8 -parallel 8 -coverpkg ./... -coverprofile coverage.out ./...
.PHONY: test-cover

# TODO: update tools in Dockerfile.dev as well
update-deps:
go get -u ./...
go mod tidy
.PHONY: update-deps

check-tidy:
cp go.mod go.check.mod
cp go.sum go.check.sum
go mod tidy -modfile=go.check.mod
diff -u go.mod go.check.mod
diff -u go.sum go.check.sum
rm go.check.mod go.check.sum
.PHONY: check-tidy

66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Effe

[![Build Status](https://travis-ci.com/GettEngineering/effe.svg?branch=master)](https://travis-ci.com/GettEngineering/effe)
[![codecov](https://codecov.io/gh/GettEngineering/effe/branch/master/graph/badge.svg)](https://codecov.io/gh/GettEngineering/effe)
[![codebeat badge](https://codebeat.co/badges/9c74d700-ebf8-4b76-8405-1950874576c4)](https://codebeat.co/projects/github-com-maratori-testpackage-master)
[![Maintainability](https://api.codeclimate.com/v1/badges/bf753d7560c8e4aa5cf0/maintainability)](https://codeclimate.com/github/GettEngineering/effe/maintainability)
[![Go Report Card](https://goreportcard.com/badge/github.com/GettEngineering/effe)](https://goreportcard.com/report/github.com/GettEngineering/effe)
[![GitHub](https://img.shields.io/github/license/GettEngineering/effe.svg)](LICENSE)
[![GoDoc](https://godoc.org/github.com/GettEngineering/effe?status.svg)](http://pkg.go.dev/github.com/GettEngineering/effe)

**Effe** is an _orchestration_ engine for business-logic

## Installing

```go
go get github.com/GettEngineering/effe/cmd/effe
```

## Run

```bash
$ effe -h
Usage of effe:
-d draw diagrams for business flows
-out string
draw output directory (default "graphs")
-v show current version of effe
```

and ensuring that `$GOPATH/bin` is added to your `$PATH`.

## Documentation & Getting Started

http://gettengineering.github.io/effe

[Getting Started](https://gettengineering.github.io/effe/gettingstarted/basicconcepts/) guide.

## Issues/Problems/Ideas

https://github.com/GettEngineering/effe/issues

## Get support

Effe is maintained by Gett. Use github issue tracking for any support request.

## License

Copyright (c) 2020 Gett

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
85 changes: 85 additions & 0 deletions cmd/effe/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package main

import (
"context"
"flag"
"log"
"os"

"github.com/GettEngineering/effe/drawer"
"github.com/GettEngineering/effe/generator"
"github.com/GettEngineering/effe/loaders"
"github.com/GettEngineering/effe/strategies"
"github.com/GettEngineering/effe/types"
)

const (
version = "0.1.0"
)

func main() {
log.SetFlags(0)
log.SetPrefix("effe: ")
log.SetOutput(os.Stderr)

showVerstionPtr := flag.Bool("v", false, "show current version of effe")
drawPtr := flag.Bool("d", false, "draw diagrams for business flows")
drawOutPtr := flag.String("out", "graphs", "draw output directory")
flag.Parse()
if showVerstionPtr != nil && *showVerstionPtr {
showVersion()
return
}

d, err := os.Getwd()
if err != nil {
log.Printf("can't get path of current directory: %s", err)
os.Exit(2)
}

settings := generator.DefaultSettigs()
gen := generator.NewGenerator(
generator.WithSetttings(settings),
generator.WithLoader(loaders.NewLoader(loaders.WithPackages([]string{"effe"}))),
generator.WithDrawer(drawer.NewDrawer()),
generator.WithStrategy(
strategies.NewChain(strategies.WithServiceObjectName(settings.LocalInterfaceVarname())),
),
)

var (
errs []error
genResults []types.GenerateResult
)

if drawPtr != nil && *drawPtr {
if drawOutPtr == nil {
log.Println("directory for output is not set")
os.Exit(2)
}
genResults, errs = gen.GenerateDiagram(context.Background(), d, os.Environ(), []string{"."}, *drawOutPtr)
} else {
genResults, errs = gen.Generate(context.Background(), d, os.Environ(), []string{"."})
}

for index, err := range errs {
log.Printf("failed generate: %s\n", err)
if index == len(errs)-1 {
os.Exit(2)
}
}

for _, res := range genResults {
if len(res.Errs) > 0 {
for _, err := range res.Errs {
log.Printf("failed generate: %s\n", err)
}
} else {
log.Printf("wrote %s\n", res.OutputPath)
}
}
}

func showVersion() {
log.Println(version)
}
Loading

0 comments on commit af84cea

Please sign in to comment.