-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding linter and github workflows (#5)
- Loading branch information
1 parent
7fec0f0
commit a4209ae
Showing
9 changed files
with
267 additions
and
3 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,25 @@ | ||
name: playground-mono-test-suite | ||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.23.x" | ||
- name: Install dependencies | ||
run: go get . | ||
- name: Build | ||
run: make build | ||
- name: Run Unit tests | ||
run: make unittest | ||
# - name: Run Integration tests | ||
# run: make test |
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,24 @@ | ||
name: linter | ||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: read | ||
|
||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.60.1 |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea/ | ||
.vscode/ | ||
.env | ||
./playground-mono |
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,142 @@ | ||
run: | ||
concurrency: 8 | ||
|
||
timeout: 5m | ||
|
||
issues-exit-code: 1 | ||
|
||
tests: false | ||
|
||
modules-download-mode: readonly | ||
|
||
allow-parallel-runners: false | ||
|
||
go: "" # keep this empty to use the Go version from the go.mod file. | ||
|
||
linters: | ||
fast: false # set to true runs only fast linters. | ||
|
||
disable-all: true | ||
|
||
enable: | ||
- bodyclose | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- exportloopref | ||
- funlen | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- gofmt | ||
- goimports | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- revive | ||
- govet | ||
- ineffassign | ||
- lll | ||
- misspell | ||
- nakedret | ||
- noctx | ||
- nolintlint | ||
- staticcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- whitespace | ||
|
||
linters-settings: | ||
dupl: | ||
threshold: 200 | ||
|
||
funlen: | ||
lines: 200 | ||
statements: 200 | ||
|
||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
|
||
gocognit: | ||
# minimal code complexity to report, 30 by default (but we recommend 10-20) | ||
min-complexity: 10 | ||
|
||
gocyclo: | ||
min-complexity: 30 | ||
|
||
lll: | ||
tab-width: 2 | ||
line-length: 200 | ||
|
||
misspell: | ||
locale: US | ||
|
||
nolintlint: | ||
allow-unused: false # report any unused nolint directives | ||
require-explanation: false # don't require an explanation for nolint directives | ||
require-specific: false # don't require nolint directives to be specific about which linter is being skipped | ||
|
||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
disabled-checks: | ||
- dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
- ifElseChain | ||
- octalLiteral | ||
- whyNoLint | ||
- wrapperFunc | ||
- nestingReduce | ||
|
||
revive: | ||
# see https://github.com/mgechev/revive#available-rules for details. | ||
ignore-generated-header: true | ||
severity: error | ||
confidence: 0.8 | ||
rules: | ||
- name: indent-error-flow | ||
- name: errorf | ||
- name: unexported-return | ||
- name: error-naming | ||
- name: error-return | ||
- name: empty-lines | ||
- name: empty-block | ||
- name: context-as-argument | ||
- name: if-return | ||
- name: superfluous-else | ||
|
||
staticcheck: | ||
checks: ["all"] | ||
|
||
output: | ||
print-issued-lines: false | ||
|
||
print-linter-name: true | ||
|
||
uniq-by-line: false | ||
|
||
sort-results: true | ||
|
||
issues: | ||
max-issues-per-linter: 0 | ||
|
||
max-same-issues: 0 | ||
|
||
new: false | ||
|
||
fix: true | ||
|
||
exclude-dirs: | ||
- .github | ||
- .hooks | ||
- .vscode | ||
|
||
exclude-files: | ||
- README.md |
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,14 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-added-large-files | ||
|
||
- repo: https://github.com/dnephin/pre-commit-golang | ||
rev: v0.5.1 | ||
hooks: | ||
- id: go-fmt | ||
- id: golangci-lint | ||
- id: go-mod-tidy |
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,36 @@ | ||
.PHONY: build test build-docker run test-one | ||
|
||
build: | ||
CGO_ENABLED=0 GOOS=linux go build -o ./playground-mono | ||
|
||
format: | ||
go fmt ./... | ||
|
||
run: | ||
go run main.go | ||
|
||
# TODO: Uncomment once integration-tests are added | ||
#test: | ||
# go test -v -count=1 -p=1 ./integration_tests/... | ||
# | ||
#test-one: | ||
# go test -v -race -count=1 --run $(TEST_FUNC) ./integration_tests/... | ||
|
||
unittest: | ||
go test -race -count=1 ./internal/... | ||
|
||
unittest-one: | ||
go test -v -race -count=1 --run $(TEST_FUNC) ./internal/... | ||
|
||
GOLANGCI_LINT_VERSION := 1.60.1 | ||
|
||
lint: check-golangci-lint | ||
golangci-lint run ./... | ||
|
||
check-golangci-lint: | ||
@if ! command -v golangci-lint > /dev/null || ! golangci-lint version | grep -q "$(GOLANGCI_LINT_VERSION)"; then \ | ||
echo "Required golangci-lint version $(GOLANGCI_LINT_VERSION) not found."; \ | ||
echo "Please install golangci-lint version $(GOLANGCI_LINT_VERSION) with the following command:"; \ | ||
echo "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.1"; \ | ||
exit 1; \ | ||
fi |
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
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
Binary file not shown.