-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,893 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: '^1.16' | ||
- name: Run tests | ||
run: make test | ||
|
||
coverage: | ||
name: Code Coverage | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: '^1.16' | ||
- name: Generate Code Coverage | ||
run: make coverage | ||
- name: Send coverage | ||
uses: shogo82148/actions-goveralls@v1 | ||
with: | ||
path-to-profile: coverage.cov | ||
|
||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-go@v2 | ||
- name: GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
args: release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/bin | ||
|
||
/coverage.cov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
run: | ||
modules-download-mode: readonly | ||
|
||
linters: | ||
enable: | ||
- asciicheck | ||
- bodyclose | ||
- cyclop | ||
- dupl | ||
- durationcheck | ||
- errorlint | ||
- exhaustive | ||
- exportloopref | ||
- gci | ||
- gochecknoglobals | ||
- gochecknoinits | ||
- gocognit # probably tune | ||
- goconst | ||
- gocritic # probably tune | ||
- godot | ||
- goerr113 | ||
- gofumpt | ||
- gosec | ||
- ifshort | ||
- lll | ||
- makezero | ||
- misspell | ||
- nakedret | ||
- nilerr | ||
- nlreturn | ||
- nolintlint | ||
# - paralleltest # @todo check later, maybe enable | ||
- prealloc | ||
- predeclared | ||
- revive | ||
- sqlclosecheck | ||
- testpackage | ||
- thelper | ||
- unconvert | ||
- wastedassign | ||
- whitespace | ||
- wsl | ||
|
||
linters-settings: | ||
goimports: | ||
local-prefixes: gitlab.cdn77.eu | ||
|
||
govet: | ||
check-shadowing: false | ||
enable-all: true | ||
disable: | ||
- fieldalignment # @todo fix later | ||
|
||
revive: | ||
ignore-generated-header: true | ||
confidence: 0.8 | ||
error-code: 0 | ||
severity: error | ||
rules: | ||
# - name: exported | ||
# disabled: true | ||
# - name: package-comments | ||
# disabled: true | ||
# - name: var-naming | ||
# disabled: true | ||
|
||
- name: atomic | ||
- name: bare-return | ||
- name: blank-imports | ||
- name: bool-literal-in-expr | ||
- name: confusing-naming | ||
- name: confusing-results | ||
- name: constant-logical-expr | ||
- name: context-as-argument | ||
- name: context-keys-type | ||
- name: defer | ||
- name: dot-imports | ||
- name: duplicated-imports | ||
- name: early-return | ||
- name: empty-block | ||
- name: empty-lines | ||
- name: error-naming | ||
- name: error-return | ||
- name: error-strings | ||
- name: flag-parameter | ||
- name: get-return | ||
- name: identical-branches | ||
- name: if-return | ||
- name: import-shadowing | ||
- name: increment-decrement | ||
- name: indent-error-flow | ||
- name: modifies-parameter | ||
- name: modifies-value-receiver | ||
- name: nested-structs | ||
- name: range | ||
- name: range-val-address | ||
- name: range-val-in-closure | ||
- name: receiver-naming | ||
- name: redefines-builtin-id | ||
- name: string-of-int | ||
- name: struct-tag | ||
- name: superfluous-else | ||
- name: time-naming | ||
- name: unconditional-recursion | ||
- name: unexported-naming | ||
- name: unexported-naming | ||
- name: unexported-return | ||
- name: unnecessary-stmt | ||
- name: unused-parameter | ||
- name: unused-receiver | ||
- name: useless-break | ||
- name: var-declaration | ||
- name: waitgroup-by-value | ||
|
||
lll: | ||
tab-width: 4 | ||
|
||
wsl: | ||
allow-cuddle-declarations: true | ||
|
||
issues: | ||
max-issues-per-linter: 0 | ||
max-same-issues: 0 | ||
exclude-rules: | ||
# ignore unchecked errors, missing Close(), code complexity, global variables, line lengths and code duplicity in tests | ||
- path: _test\.go | ||
linters: [ errcheck, bodyclose, cyclop, gocognit, gochecknoglobals, lll, dupl ] | ||
# ignore control flags in tests | ||
- path: _test\.go | ||
text: "seems to be a control flag, avoid control coupling" | ||
linters: [ revive ] | ||
# ignore unchecked errors in defer statements | ||
- source: "^\t+defer " | ||
linters: [ errcheck ] | ||
# ignore defer cuddle in tests | ||
- path: _test\.go | ||
text: only one cuddle assignment allowed before defer statement | ||
linters: [ wsl ] | ||
# ignore expressions after assignment in tests | ||
- path: _test\.go | ||
text: only cuddled expressions if assigning variable or using from line above | ||
linters: [ wsl ] | ||
# ignore goerr113 dynamic errors definition error...not sure how to approach this correctly now | ||
- text: do not define dynamic errors, use wrapped static errors instead | ||
linters: [ goerr113 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
changelog: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
export BIN = ${PWD}/bin | ||
export GOBIN = $(BIN) | ||
|
||
.PHONY: check | ||
check: lint test | ||
|
||
.PHONY: lint | ||
lint: $(BIN)/golangci-lint mocks | ||
$(BIN)/golangci-lint run | ||
|
||
.PHONY: fix | ||
fix: $(BIN)/golangci-lint mocks | ||
$(BIN)/golangci-lint run --fix | ||
|
||
.PHONY: test | ||
test: mocks | ||
go test --timeout 5m $(GO_TEST_FLAGS) ./... | ||
go test --timeout 5m $(GO_TEST_FLAGS) --race ./... | ||
go test --timeout 5m $(GO_TEST_FLAGS) --count 100 ./... | ||
|
||
mocks: $(BIN)/mockery $(shell find . -type f -name '*.go' -not -name '*_test.go') | ||
$(BIN)/mockery --all --outpkg cmd_mocks | ||
@touch mocks | ||
|
||
.PHONY: coverage | ||
coverage: $(BIN)/go-acc mocks | ||
$(BIN)/go-acc --covermode set --output coverage.cov ./... | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf bin mocks coverage.cov | ||
|
||
$(BIN)/golangci-lint: | ||
curl --retry 5 -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh | ||
|
||
$(BIN)/mockery: | ||
mkdir -p $(BIN) | ||
curl -sSfL https://api.github.com/repos/vektra/mockery/releases | jq -r 'first(.[] | select(.tag_name | test("^v2\\.8[.0-9]+$$"))) | .assets[] | select(.name | test("Linux_x86_64.tar.gz")) | .browser_download_url' \ | ||
| xargs curl -sSfL \ | ||
| tar -xz -C $(BIN) mockery | ||
#curl -sSfL https://api.github.com/repos/vektra/mockery/releases | jq -r 'first(.[] | select(.tag_name | test("^v2[.0-9]+$$"))) | .assets[] | select(.name | test("Linux_x86_64.tar.gz")) | .browser_download_url' \ | ||
# | xargs curl -sSfL \ | ||
# | tar -xz -C $(BIN) mockery | ||
|
||
$(BIN)/go-acc: | ||
go install github.com/ory/go-acc@latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# cmd | ||
|
||
![CI](https://github.com/grongor/cmd/workflows/CI/badge.svg) | ||
[![Coverage Status](https://coveralls.io/repos/github/grongor/cmd/badge.svg)](https://coveralls.io/github/grongor/cmd) | ||
|
||
todo |
Oops, something went wrong.