Skip to content

Commit 9f66f2f

Browse files
committed
gha: adding initial files for github actions
Closes TNTP-3728
1 parent 8eef70c commit 9f66f2f

File tree

9 files changed

+224
-0
lines changed

9 files changed

+224
-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+
# ignore-words-list =
5+
check-filenames = true

.github/pull_request_template.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
- [ ] Tests (see [documentation](https://pkg.go.dev/testing) for a testing package)
6+
- [ ] Changelog (see [documentation](https://keepachangelog.com/en/1.0.0/) for changelog format)
7+
- [ ] Documentation (see [documentation](https://go.dev/blog/godoc) for documentation style guide)
8+
9+
Related issues:

.github/workflows/check.yaml

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

.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.23', '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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
coverage.out

.golangci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: '2'
2+
3+
run:
4+
timeout: 3m
5+
6+
formatters:
7+
enable:
8+
- goimports
9+
10+
linters:
11+
enable:
12+
- forbidigo
13+
- gocritic
14+
- lll
15+
- reassign
16+
- unconvert
17+
- gosec
18+
- errorlint
19+
- godot
20+
- revive
21+
- testpackage
22+
- unused
23+
24+
settings:
25+
godot:
26+
scope: all
27+
lll:
28+
line-length: 120
29+
tab-width: 4

Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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

doc.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Package option provides a type-safe way to represent optional values in Go.
2+
// An Optional[T] can either contain a value of type T (Some) or be empty (None).
3+
//
4+
// This is useful for:
5+
// - Clearly representing nullable fields in structs.
6+
// - Avoiding nil pointer dereferences.
7+
// - Providing explicit intent about optional values.
8+
package option

go.sum

Whitespace-only changes.

0 commit comments

Comments
 (0)