Skip to content

Commit 5ff0ec0

Browse files
authored
Merge pull request #39 from btnguyen2k/dev
Prepare to release next version
2 parents 575b971 + c7d83c1 commit 5ff0ec0

File tree

4 files changed

+93
-1
lines changed

4 files changed

+93
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,39 @@ on:
99
workflow_call:
1010

1111
jobs:
12+
GoFmt:
13+
runs-on: ubuntu-latest
14+
name: Check format with go fmt
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v4
18+
- name: Set up Go env
19+
uses: actions/setup-go@v4
20+
with:
21+
# pick one Go version to check format
22+
go-version: '1.18'
23+
- name: Run go fmt
24+
run: |
25+
go version
26+
go fmt ./...
27+
28+
GoLint:
29+
name: GoLint
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Check out code
33+
uses: actions/checkout@v4
34+
- name: Set up Go env
35+
uses: actions/setup-go@v4
36+
with:
37+
# pick one Go version for linting
38+
go-version: '1.18'
39+
- name: golangci-lint
40+
uses: golangci/golangci-lint-action@v3
41+
with:
42+
version: latest
43+
only-new-issues: true
44+
1245
Test:
1346
runs-on: ubuntu-latest
1447
strategy:
@@ -25,7 +58,13 @@ jobs:
2558
- name: Run tests
2659
run: |
2760
go version
28-
go test -v -timeout 9999s -count 1 -p 1 -cover -coverprofile coverage.txt .
61+
go test -v -timeout 9999s -count 1 -p 1 -cover -coverprofile coverage.txt ./
62+
- name: Run tests (in different package)
63+
run: |
64+
go version
65+
cd module_test && \
66+
go test -v -timeout 9999s -count 1 -p 1 -cover -coverprofile ../coverage_test_package.txt -coverpkg=github.com/btnguyen2k/mymodule ./ && \
67+
cd ..
2968
- name: Codecov
3069
uses: codecov/codecov-action@v3
3170
with:

module_test/code_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package module_test
2+
3+
import (
4+
"github.com/btnguyen2k/mymodule"
5+
"reflect"
6+
"testing"
7+
)
8+
9+
// sample tests
10+
11+
func TestClone_int(t *testing.T) {
12+
testName := "TestClone_int"
13+
input := []int{1, 2, 3}
14+
output := mymodule.Clone(input)
15+
if !reflect.DeepEqual(input, output) {
16+
t.Fatalf("%s failed: expected %v but received %v", testName, input, output)
17+
}
18+
}
19+
20+
func TestClone_uint(t *testing.T) {
21+
testName := "TestClone_uint"
22+
input := []uint{4, 5, 6}
23+
output := mymodule.Clone(input)
24+
if !reflect.DeepEqual(input, output) {
25+
t.Fatalf("%s failed: expected %v but received %v", testName, input, output)
26+
}
27+
}
28+
29+
func TestClone_float(t *testing.T) {
30+
testName := "TestClone_float"
31+
input := []float64{7.8, 8.9, 9.0}
32+
output := mymodule.Clone(input)
33+
if !reflect.DeepEqual(input, output) {
34+
t.Fatalf("%s failed: expected %v but received %v", testName, input, output)
35+
}
36+
}
37+
38+
func TestClone_string(t *testing.T) {
39+
testName := "TestClone_string"
40+
input := []string{"string 1", "string 2", "string 3"}
41+
output := mymodule.Clone(input)
42+
if !reflect.DeepEqual(input, output) {
43+
t.Fatalf("%s failed: expected %v but received %v", testName, input, output)
44+
}
45+
}

module_test/go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module module_test
2+
3+
go 1.18
4+
5+
require github.com/btnguyen2k/mymodule v0.0.0-00010101000000-000000000000
6+
7+
replace github.com/btnguyen2k/mymodule => ../

module_test/go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github.com/btnguyen2k/consu/semver v0.2.1 h1:le0FzrM7u0IOR4MnOyBySHpZ/p3vV4JjofAhPB7edWE=

0 commit comments

Comments
 (0)