Skip to content

Commit dc67db5

Browse files
committed
add workflows
1 parent 99d8033 commit dc67db5

File tree

6 files changed

+120
-5
lines changed

6 files changed

+120
-5
lines changed

.github/workflows/build.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Go Test & Coverage
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- master
7+
pull_request:
8+
branches:
9+
- main
10+
- master
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-go@v5
17+
with:
18+
go-version: stable
19+
- name: Install dependencies
20+
run: go mod tidy
21+
- name: Run tests with coverage
22+
run: go test ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./...
23+
- name: Check coverage
24+
uses: vladopajic/go-test-coverage@v2
25+
with:
26+
config: ./.testcoverage.yml

.github/workflows/golangci-lint.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- master
7+
pull_request:
8+
branches:
9+
- main
10+
- master
11+
12+
permissions:
13+
contents: read
14+
pull-requests: read
15+
16+
jobs:
17+
golangci:
18+
name: lint
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-go@v5
23+
with:
24+
go-version: stable
25+
- name: golangci-lint
26+
uses: golangci/golangci-lint-action@v7
27+
with:
28+
version: v2.0

.testcoverage.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# (mandatory)
2+
# Path to coverage profile file (output of `go test -coverprofile` command).
3+
#
4+
# For cases where there are many coverage profiles, such as when running
5+
# unit tests and integration tests separately, you can combine all those
6+
# profiles into one. In this case, the profile should have a comma-separated list
7+
# of profile files, e.g., 'cover_unit.out,cover_integration.out'.
8+
profile: cover.out
9+
10+
# Holds coverage thresholds percentages, values should be in range [0-100].
11+
threshold:
12+
# (optional; default 0)
13+
# Minimum coverage percentage required for individual files.
14+
file: 70
15+
16+
# (optional; default 0)
17+
# Minimum coverage percentage required for each package.
18+
package: 80
19+
20+
# (optional; default 0)
21+
# Minimum overall project coverage percentage required.
22+
total: 95
23+
24+
# Holds regexp rules which will override thresholds for matched files or packages
25+
# using their paths.
26+
#
27+
# First rule from this list that matches file or package is going to apply
28+
# new threshold to it. If project has multiple rules that match same path,
29+
# override rules should be listed in order from specific to more general rules.
30+
override:
31+
# Increase coverage threshold to 100% for `foo` package
32+
# (default is 80, as configured above in this example).
33+
- path: ^pkg/lib/foo$
34+
threshold: 100
35+
36+
# Holds regexp rules which will exclude matched files or packages
37+
# from coverage statistics.
38+
exclude:
39+
# Exclude files or packages matching their paths
40+
paths:
41+
- \.pb\.go$ # excludes all protobuf generated files
42+
- ^pkg/bar # exclude package `pkg/bar`
43+
44+
# File name of go-test-coverage breakdown file, which can be used to
45+
# analyze coverage difference.
46+
breakdown-file-name: ''
47+
48+
diff:
49+
# File name of go-test-coverage breakdown file which will be used to
50+
# report coverage difference.
51+
base-breakdown-file-name: ''

go.mod

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
module github.com/redis-developer/go-redis-entraid
22

33
go 1.18
4-
5-

version.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
package redis-entraid
1+
package redis
2+
3+
const version = "0.0.1"
24

35
// Version is the current release version.
46
func Version() string {
5-
return "0.0.1"
7+
return version
68
}
7-

version_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package redis
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestVersion(t *testing.T) {
8+
if Version() != version {
9+
t.Errorf("Version() = %s; want %s", Version(), version)
10+
}
11+
}

0 commit comments

Comments
 (0)