Skip to content

Commit

Permalink
add initial pkgs (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
23doors authored May 25, 2020
1 parent b963f97 commit 33ce082
Show file tree
Hide file tree
Showing 58 changed files with 5,401 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2.1
jobs:
test:
docker:
- image: golang:1.14
steps:
- checkout

- run:
name: Lint
command: |
make lint
- run:
name: Test
command: |
make test
workflows:
test:
jobs:
- test

18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/---bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: "\U0001F41B Bug report"
about: Create a report to help us improve

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/---feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: "\U0001F680 Feature request"
about: Suggest an idea for this project

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Additional context**
Add any other context or screenshots about the feature request here.
Empty file added .gitignore
Empty file.
86 changes: 86 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
run:
timeout: 2m
tests: false
skip-dirs:
- assets
- dev
- proto
- mocks

issues:
exclude-rules:
- text: declaration of "err" shadows declaration
linters:
- govet

linters-settings:
govet:
check-shadowing: true
golint:
min-confidence: 0
gocyclo:
min-complexity: 20
maligned:
suggest-new: true
dupl:
threshold: 150
goconst:
min-len: 3
min-occurrences: 3
misspell:
locale: US
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- whyNoLint
- commentedOutCode

linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- golint
- gosec
- gosimple
- govet
- ineffassign
- interfacer
- misspell
- nakedret
- prealloc
- scopelint
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
- wsl

# don't enable:
# - funlen
# - gochecknoglobals
# - gochecknoinits
# - godox
# - gocognit
# - gomnd
# - lll
# - maligned
11 changes: 11 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"github": {
"release": true
},
"npm": {
"publish": false
},
"git": {
"tagName": "v${version}"
}
}
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM golang:1.14

COPY go.mod go.sum ./
RUN go mod download
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
CURRENTPACKAGE := github.com/Syncano/pkg-go
EXECNAME := orion

PATH := $(PATH):$(GOPATH)/bin
GOFILES=$(shell find . -mindepth 2 -type f -name '*.go' ! -path "./.*" ! -path "./dev/*" ! -path "*/proto/*")
GOTESTPACKAGES = $(shell find . -mindepth 2 -type f -name '*.go' ! -path "./.*" ! -path "./internal/*" ! -path "./dev/*" ! -path "*/mocks/*" ! -path "*/proto/*" | xargs -n1 dirname | sort | uniq)

.PHONY: help clean lint fmt test stest cov goconvey lint-in-docker test-in-docker generate
.DEFAULT_GOAL := help
$(VERBOSE).SILENT:

help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

require-%:
if ! hash ${*} 2>/dev/null; then \
echo "! ${*} not installed"; \
exit 1; \
fi

clean: ## Cleanup repository
go clean ./...
rm -f build/$(EXECNAME)
find deploy -name "*.unenc" -delete
git clean -f

lint: ## Run lint checks
echo "=== lint ==="
if ! hash golangci-lint 2>/dev/null; then \
echo "Installing golangci-lint"; \
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $$(go env GOPATH)/bin v1.24.0; \
fi
golangci-lint run $(ARGS)

fmt: ## Format code through goimports
gofmt -s -w $(GOFILES)
go run golang.org/x/tools/cmd/goimports -local $(CURRENTPACKAGE) -w $(GOFILES)

test: ## Run unit with race check and create coverage profile
echo "=== unit test ==="
echo "mode: atomic" > coverage-all.out
$(foreach pkg,$(GOTESTPACKAGES),\
go test -timeout 5s -short -race -coverprofile=coverage.out -covermode=atomic $(ARGS) $(pkg) || exit;\
tail -n +2 coverage.out >> coverage-all.out 2>/dev/null;)

cov: ## Show per function coverage generated by test
echo "=== coverage ==="
go tool cover -func=coverage-all.out

goconvey: ## Run goconvey test server
go run github.com/smartystreets/goconvey -excludedDirs "dev,internal,mocks,proto,assets,deploy,build" -timeout 5s -depth 2

lint-in-docker: require-docker-compose ## Run lint in docker environment
docker-compose run --no-deps --rm server make lint

test-in-docker: require-docker-compose ## Run full test suite in docker environment
docker-compose run --rm server make build test

generate: ## Run go generate
go generate ./...
Loading

0 comments on commit 33ce082

Please sign in to comment.