Skip to content

Commit 3eb6f16

Browse files
repo: setup basic CI
Closes TNTP-5618
1 parent 7b63c31 commit 3eb6f16

File tree

8 files changed

+274
-0
lines changed

8 files changed

+274
-0
lines changed

.codespellrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[codespell]
2+
3+
skip = ./vendor,./.git
4+
check-filenames = true
5+

.github/pull_request_template.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
What has been done? Why? What problem is being solved?
2+
3+
I didn't forget about (remove if it is not applicable):
4+
5+
- [ ] Well-written commit messages (see [documentation][how-to-write-commit] how to write a commit message)
6+
- [ ] Don't forget about TarantoolBot in a commit message (see [example][tarantoolbot-example])
7+
- [ ] Tests (see [documentation][go-testing] for a testing package)
8+
- [ ] Changelog (see [documentation][keepachangelog] for changelog format)
9+
- [ ] Documentation (see [documentation][go-doc] for documentation style guide)
10+
11+
Related issues:
12+
13+
Related to #XXX
14+
15+
Part of #XXX
16+
17+
Closes #XXX
18+
19+
[go-doc]: https://go.dev/blog/godoc
20+
[go-testing]: https://pkg.go.dev/testing
21+
[how-to-write-commit]: https://www.tarantool.io/en/doc/latest/contributing/developer_guidelines/#how-to-write-a-commit-message
22+
[keepachangelog]: https://keepachangelog.com/en/1.0.0/
23+
[tarantoolbot-example]: https://github.com/tarantool/tt/pull/1030/commits
24+

.github/workflows/check.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Run checks
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
env:
8+
GO_VERSION: 1.25
9+
CODESPELL_VERSION: v2.4.1
10+
11+
12+
jobs:
13+
golangci-lint:
14+
runs-on: ubuntu-latest
15+
if: |
16+
github.event_name == 'push' ||
17+
github.event_name == 'pull_request' &&
18+
github.event.pull_request.head.repo.full_name != github.repository
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-go@v5
22+
with:
23+
go-version: ${{ env.GO_VERSION }}
24+
25+
- uses: golangci/golangci-lint-action@v8
26+
name: run golangci-lint with gha format
27+
continue-on-error: true
28+
29+
- uses: golangci/golangci-lint-action@v8
30+
name: run golangci-lint with human-readable format
31+
32+
codespell:
33+
runs-on: ubuntu-latest
34+
if: |
35+
github.event_name == 'push' ||
36+
github.event_name == 'pull_request' &&
37+
github.event.pull_request.head.repo.full_name != github.repository
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: install codespell
42+
run: pip3 install codespell==${CODESPELL_VERSION}
43+
44+
- name: run codespell
45+
run: make codespell
46+
47+
verify-generation:
48+
runs-on: ubuntu-latest
49+
if: |
50+
github.event_name == 'push' ||
51+
github.event_name == 'pull_request' &&
52+
github.event.pull_request.head.repo.full_name != github.repository
53+
steps:
54+
- uses: actions/checkout@v4
55+
- uses: actions/setup-go@v5
56+
with:
57+
go-version: ${{ env.GO_VERSION }}
58+
59+
- name: genrate code
60+
run: go generate ./...
61+
62+
- name: check for changes
63+
run: |
64+
if [ -n "$(git status --porcelain)" ]; then
65+
echo "new files were generated"
66+
git status --porcelain
67+
git diff
68+
exit 1
69+
fi
70+

.github/workflows/testing.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: testing
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
run-tests:
10+
if: (github.event_name == 'push') ||
11+
(github.event_name == 'pull_request' &&
12+
github.event.pull_request.head.repo.full_name != github.repository) ||
13+
(github.event_name == 'workflow_dispatch')
14+
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
golang: ['1.24', 'stable']
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-go@v5
25+
with:
26+
go-version: ${{ matrix.golang }}
27+
28+
- name: run tests
29+
run: make test
30+
31+
- name: run tests with race
32+
run: make testrace
33+
34+
run-tests-with-coverage:
35+
if: (github.event_name == 'push') ||
36+
(github.event_name == 'pull_request' &&
37+
github.event.pull_request.head.repo.full_name != github.repository) ||
38+
(github.event_name == 'workflow_dispatch')
39+
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: actions/setup-go@v5
45+
with:
46+
go-version: ${{ matrix.golang }}
47+
48+
- name: run tests, collect code coverage data and send to Coveralls
49+
env:
50+
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
run: make coverage coveralls-deps coveralls
52+
53+
run-benchmarks:
54+
if: false
55+
56+
runs-on: ubuntu-latest
57+
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: actions/setup-go@v5
61+
with:
62+
go-version: ${{ matrix.golang }}
63+
- name: run benchmarks
64+
run: make bench
65+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
coverage.out
2+

.golangci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
version: '2'
2+
3+
run:
4+
timeout: 3m
5+
6+
formatters:
7+
enable:
8+
- goimports
9+
10+
issues:
11+
# Disable limits on the number of printed issues
12+
max-issues-per-linter: 0 # 0 = no limit
13+
max-same-issues: 0 # 0 = no limit
14+
15+
linters:
16+
default: all
17+
18+
disable:
19+
- dupl # Dupl is disabled, since we're generating a lot of boilerplate code.
20+
- cyclop # Cyclop is disabled, since cyclomatic complexities is very abstract metric,
21+
# that sometimes lead to strange linter behaviour.
22+
- wsl # WSL is disabled, since it's obsolete. Using WSL_v5.
23+
- nlreturn # nlreturn is disabled, since it's duplicated by wsl_v5.return check.
24+
- ireturn # ireturn is disabled, since it's not needed.
25+
26+
exclusions:
27+
generated: lax
28+
rules:
29+
- path: _test.go
30+
linters:
31+
- wrapcheck
32+
33+
settings:
34+
godot:
35+
scope: all
36+
lll:
37+
line-length: 120
38+
tab-width: 4
39+
wsl_v5:
40+
allow-first-in-block: true
41+
allow-whole-block: false
42+
branch-max-lines: 2
43+
case-max-lines: 0
44+
default: all
45+
depguard:
46+
rules:
47+
main:
48+
files:
49+
- "$all"
50+
- "!$test"
51+
allow:
52+
- $gostd
53+
test:
54+
files:
55+
- "$test"
56+
allow:
57+
- $gostd
58+
- "github.com/stretchr/testify"

Makefile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
GOTEST := go test
2+
TAGS :=
3+
COVERAGE_FILE := coverage.out
4+
5+
.PHONY: codespell
6+
codespell:
7+
@echo "Running codespell"
8+
@codespell
9+
10+
.PHONY: test
11+
test:
12+
@echo "Running tests"
13+
@go test ./... -count=1
14+
15+
.PHONY: testrace
16+
testrace:
17+
@echo "Running tests with race flag"
18+
@go test ./... -count=100 -race
19+
20+
.PHONY: coverage
21+
coverage:
22+
@echo "Running tests with coveralls"
23+
go test -tags "$(TAGS)" $(go list ./... | grep -v test_helpers) -v -p 1 -covermode=atomic -coverprofile=$(COVERAGE_FILE) -count=1
24+
go tool cover -func=$(COVERAGE_FILE)
25+
26+
.PHONY: coveralls
27+
coveralls:
28+
@echo "uploading coverage to coveralls"
29+
@goveralls -coverprofile=$(COVERAGE_FILE) -service=github
30+
31+
.PHONY: coveralls-deps
32+
coveralls-deps:
33+
@echo "Installing coveralls"
34+
@go get github.com/mattn/goveralls
35+
@go install github.com/mattn/goveralls
36+
37+
.PHONY: lint-deps
38+
lint-deps:
39+
@echo "Installing lint deps"
40+
@go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.0
41+
42+
.PHONY: lint
43+
lint: lint-deps
44+
@echo "Running go-linter"
45+
@go mod tidy
46+
@go mod vendor
47+
@golangci-lint run --config=./.golangci.yml --modules-download-mode vendor --verbose
48+

doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package config provides a uniform way to handle various configurations.
2+
package config

0 commit comments

Comments
 (0)