Skip to content
Open
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
5 changes: 5 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[codespell]

skip = ./vendor,./.git
check-filenames = true

24 changes: 24 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
What has been done? Why? What problem is being solved?

I didn't forget about (remove if it is not applicable):

- [ ] Well-written commit messages (see [documentation][how-to-write-commit] how to write a commit message)
- [ ] Don't forget about TarantoolBot in a commit message (see [example][tarantoolbot-example])
- [ ] Tests (see [documentation][go-testing] for a testing package)
- [ ] Changelog (see [documentation][keepachangelog] for changelog format)
- [ ] Documentation (see [documentation][go-doc] for documentation style guide)

Related issues:

Related to #XXX

Part of #XXX

Closes #XXX

[go-doc]: https://go.dev/blog/godoc
[go-testing]: https://pkg.go.dev/testing
[how-to-write-commit]: https://www.tarantool.io/en/doc/latest/contributing/developer_guidelines/#how-to-write-a-commit-message
[keepachangelog]: https://keepachangelog.com/en/1.0.0/
[tarantoolbot-example]: https://github.com/tarantool/tt/pull/1030/commits

70 changes: 70 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Run checks

on:
push:
pull_request:

env:
GO_VERSION: 1.25
CODESPELL_VERSION: v2.4.1


jobs:
golangci-lint:
runs-on: ubuntu-latest
if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- uses: golangci/golangci-lint-action@v8
name: run golangci-lint with gha format
continue-on-error: true

- uses: golangci/golangci-lint-action@v8
name: run golangci-lint with human-readable format

codespell:
runs-on: ubuntu-latest
if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository
steps:
- uses: actions/checkout@v4

- name: install codespell
run: pip3 install codespell==${CODESPELL_VERSION}

- name: run codespell
run: make codespell

verify-generation:
runs-on: ubuntu-latest
if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: genrate code
run: go generate ./...

- name: check for changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "new files were generated"
git status --porcelain
git diff
exit 1
fi

65 changes: 65 additions & 0 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: testing

on:
push:
pull_request:
workflow_dispatch:

jobs:
run-tests:
if: (github.event_name == 'push') ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository) ||
(github.event_name == 'workflow_dispatch')

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
golang: ['1.24', 'stable']

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.golang }}

- name: run tests
run: make test

- name: run tests with race
run: make testrace

run-tests-with-coverage:
if: (github.event_name == 'push') ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository) ||
(github.event_name == 'workflow_dispatch')

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.golang }}

- name: run tests, collect code coverage data and send to Coveralls
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make coverage coveralls-deps coveralls

run-benchmarks:
if: false

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.golang }}
- name: run benchmarks
run: make bench

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage.out

58 changes: 58 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: '2'

run:
timeout: 3m

formatters:
enable:
- goimports

issues:
# Disable limits on the number of printed issues
max-issues-per-linter: 0 # 0 = no limit
max-same-issues: 0 # 0 = no limit

linters:
default: all

disable:
- dupl # Dupl is disabled, since we're generating a lot of boilerplate code.
- cyclop # Cyclop is disabled, since cyclomatic complexities is very abstract metric,
# that sometimes lead to strange linter behaviour.
- wsl # WSL is disabled, since it's obsolete. Using WSL_v5.
- nlreturn # nlreturn is disabled, since it's duplicated by wsl_v5.return check.
- ireturn # ireturn is disabled, since it's not needed.

exclusions:
generated: lax
rules:
- path: _test.go
linters:
- wrapcheck

settings:
godot:
scope: all
lll:
line-length: 120
tab-width: 4
wsl_v5:
allow-first-in-block: true
allow-whole-block: false
branch-max-lines: 2
case-max-lines: 0
default: all
depguard:
rules:
main:
files:
- "$all"
- "!$test"
allow:
- $gostd
test:
files:
- "$test"
allow:
- $gostd
- "github.com/stretchr/testify"
48 changes: 48 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
GOTEST := go test
TAGS :=
COVERAGE_FILE := coverage.out

.PHONY: codespell
codespell:
@echo "Running codespell"
@codespell

.PHONY: test
test:
@echo "Running tests"
@go test ./... -count=1

.PHONY: testrace
testrace:
@echo "Running tests with race flag"
@go test ./... -count=100 -race

.PHONY: coverage
coverage:
@echo "Running tests with coveralls"
go test -tags "$(TAGS)" $(go list ./... | grep -v test_helpers) -v -p 1 -covermode=atomic -coverprofile=$(COVERAGE_FILE) -count=1
go tool cover -func=$(COVERAGE_FILE)

.PHONY: coveralls
coveralls:
@echo "uploading coverage to coveralls"
@goveralls -coverprofile=$(COVERAGE_FILE) -service=github

.PHONY: coveralls-deps
coveralls-deps:
@echo "Installing coveralls"
@go get github.com/mattn/goveralls
@go install github.com/mattn/goveralls

.PHONY: lint-deps
lint-deps:
@echo "Installing lint deps"
@go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.0

.PHONY: lint
lint: lint-deps
@echo "Running go-linter"
@go mod tidy
@go mod vendor
@golangci-lint run --config=./.golangci.yml --modules-download-mode vendor --verbose

2 changes: 2 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package config provides a uniform way to handle various configurations.
package config
Loading