Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Description

<!-- Describe the purpose of the issue, why a change has to be done, and how if possible -->

## Tasks

<!-- List the tasks that must be done -->

## Suggestions

<!-- Add here any relevant suggestion, such as an implementation detail or a library to use -->

## Notes

<!--
Add here some additionnal information that could be relevant for the assignee.
It can be a related issue, some context, or anything else.
-->
16 changes: 16 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- IMPORTANT: Don't forget to link the issue(s) once the PR created! -->

## Description

<!--
Describe briefly what this PR does, if the issue description is not enough.
Add any information that could be relevant for the reviewers.
-->

## Changes

<!-- Optional: mention here indirect changes impacted by the PR -->

## Notes

<!-- Optional: additional notes than can help understanding the implementation -->
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Lint & Test & Build

on:
pull_request:
push:
branches:
- main

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17

- name: Install coverage tool
run: go get github.com/ory/go-acc

# Check #1: Lint
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.47.2

# Check #2: Test & generate coverage report
- name: Test & coverage
run: make test-cov

# Check #3: Build binaries
- name: Build
run: make build

- name: Upload coverage report
uses: codecov/codecov-action@v1.0.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
flags: unittests
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Binary files
/bin

# IDE files
/.vscode
/.idea

# Benchttp configs
/.benchttp.yml
/.benchttp.yaml
/.benchttp.json
161 changes: 161 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
run:
timeout: 1m
uniq-by-line: false

linters-settings:
dupl:
threshold: 100

errcheck:
exclude-functions:
- (net/http.ResponseWriter).Write
- (io.StringWriter).WriteString
- (io.Writer).Write

gocognit:
min-complexity: 15

gocritic:
enabled-checks:
- appendAssign
- appendCombine
- argOrder
- assignOp
- badCall
- badCond
- badLock
- badRegexp
- boolExprSimplify
- builtinShadow
- builtinShadowDecl
- captLocal
- caseOrder
- codegenComment
- commentedOutCode
- commentedOutImport
- commentFormatting
- defaultCaseOrder
- deferUnlambda
- deprecatedComment
- docStub
- dupArg
- dupBranchBody
- dupCase
- dupImport
- dupSubExpr
- elseif
- emptyFallthrough
- emptyStringTest
- equalFold
- evalOrder
- exitAfterDefer
- filepathJoin
- flagDeref
- flagName
- hexLiteral
- hugeParam
- ifElseChain
- importShadow
- indexAlloc
- initClause
- mapKey
- methodExprCall
- nestingReduce
- newDeref
- nilValReturn
- octalLiteral
- offBy1
- paramTypeCombine
- ptrToRefParam
- rangeExprCopy
- rangeValCopy
- regexpMust
- regexpPattern
- regexpSimplify
- ruleguard
- singleCaseSwitch
- sloppyLen
- sloppyReassign
- sloppyTypeAssert
- sortSlice
- sqlQuery
- stringXbytes
- switchTrue
- tooManyResultsChecker
- truncateCmp
- typeAssertChain
- typeDefFirst
- typeSwitchVar
- typeUnparen
- underef
# - unamedResult
- unlabelStmt
- unlambda
- unnecessaryBlock
- unnecessaryDefer
- unslice
- valSwap
- weakCond
# - whynolint
- wrapperFunc
- yodaStyleExpr

settings:
hugeParam:
sizeThreshold: 256
rangeValCopy:
sizeThreshold: 256

gofumpt:
lang-version: "1.17"
extra-rules: true

goimports:
local-prefixes: github.com/benchttp/cli

misspell:
locale: US

revive:
enableAllRules: true

staticcheck:
go: "1.17"
checks: [all]

stylecheck:
go: "1.17"
checks: [all]

linters:
disable-all: true
enable:
- bodyclose # enforce resp.Body.Close()
- deadcode
- dupl # duplicate code
- errcheck
- exportloopref
- gocognit # smart complexity analyzer
- gocritic # opinionated linter
- gofumpt # stricter gofmt
- goimports # imports order
- gosec # security checks
- govet
- misspell # typos in strings, comments
- prealloc # enforce capacity allocation when possible
- revive # golint enhancement
- staticcheck # go vet enhancement
- structcheck # unused struct fields
- testpackage # checks on tests (*_test)
- thelper # enforce t.Helper()
- varcheck # unused global var and const
- wastedassign
fast: false

issues:
exclude-rules:
- path: _test\.go
linters:
- dupl
- gocognit
- gocyclo
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
MIT License

Copyright (c) 2021
Gregory Albouy, Clara Gonnon, Damien Mathieu
Alex Mongeot, Thomas Moreira, Kerian Pelat

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.
55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Default command

.PHONY: default
default:
@make check

# Check code

.PHONY: check
check:
@make lint
@make tests

.PHONY: lint
lint:
@golangci-lint run

.PHONY: tests
tests:
@go test -race -timeout 10s ./...

TEST_FUNC=^.*$$
ifdef t
TEST_FUNC=$(t)
endif
TEST_PKG=./...
ifdef p
TEST_PKG=./$(p)
endif

.PHONY: test
test:
@go test -race -timeout 10s -run $(TEST_FUNC) $(TEST_PKG)


.PHONY: test-cov
test-cov:
@go-acc ./...

# Build
.PHONY: build
build:
@./script/build
@./script/build-healthcheck

.PHONY: clear
clear:
@rm -rf ./bin/*

# Docs

.PHONY: docs
docs:
@echo "\033[4mhttp://localhost:9995/pkg/github.com/benchttp/cli/\033[0m"
@godoc -http=localhost:9995
Loading