mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 02:26:42 +00:00
Code coverage (#15)
* 👷 adding test and push coverage * ⬆️ use official Go 1.18 image Co-authored-by: Ruidy <rnemausat@newstore.com>
This commit is contained in:
parent
bbb199ce62
commit
3bfe1aca18
8 changed files with 27 additions and 32 deletions
42
.github/workflows/unit-test.yml
vendored
42
.github/workflows/unit-test.yml
vendored
|
|
@ -5,29 +5,19 @@ jobs:
|
|||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install gotip
|
||||
run: |
|
||||
git clone --depth=1 https://go.googlesource.com/go $HOME/gotip
|
||||
cd $HOME/gotip/src
|
||||
./make.bash
|
||||
echo "GOROOT=$HOME/gotip" >> $GITHUB_ENV
|
||||
echo "$HOME/gotip/bin:$PATH" >> $GITHUB_PATH
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Get dependencies
|
||||
run: |
|
||||
go get -v -t -d ./...
|
||||
if [ -f Gopkg.toml ]; then
|
||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
||||
dep ensure
|
||||
fi
|
||||
- name: Test
|
||||
run: go test -v ./...
|
||||
# - name: Upload coverage report
|
||||
# uses: codecov/codecov-action@v2.1.0
|
||||
# with:
|
||||
# token: 7106da3d-7479-471f-ae37-e3680b62063d
|
||||
# files: ./coverage.txt
|
||||
# flags: unittests
|
||||
# name: codecov-umbrella
|
||||
- uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: 2
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: '1.18'
|
||||
- name: Run tests with coverage
|
||||
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
|
||||
- uses: codecov/codecov-action@v2
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
|
||||
files: ./coverage.out # optional
|
||||
flags: unittests # optional
|
||||
name: codecov-umbrella # optional
|
||||
fail_ci_if_error: true # optional (default = false)
|
||||
verbose: true # optional (default = false)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
FROM golang:1.18beta1-alpine
|
||||
FROM golang:1.18-alpine
|
||||
|
||||
ENV CGO_ENABLED 0
|
||||
RUN apk update --no-cache
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package chain
|
||||
|
||||
import (
|
||||
"constraints"
|
||||
"golang.org/x/exp/constraints"
|
||||
|
||||
u "github.com/rjNemo/underscore"
|
||||
)
|
||||
|
|
|
|||
5
go.mod
5
go.mod
|
|
@ -2,7 +2,10 @@ module github.com/rjNemo/underscore
|
|||
|
||||
go 1.18
|
||||
|
||||
require github.com/stretchr/testify v1.7.0
|
||||
require (
|
||||
github.com/stretchr/testify v1.7.0
|
||||
golang.org/x/exp v0.0.0-20220314205449-43aec2f8a4e7
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -6,6 +6,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
|||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
golang.org/x/exp v0.0.0-20220314205449-43aec2f8a4e7 h1:jynE66seADJbyWMUdeOyVTvPtBZt7L6LJHupGwxPZRM=
|
||||
golang.org/x/exp v0.0.0-20220314205449-43aec2f8a4e7/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
|
|
|||
2
max.go
2
max.go
|
|
@ -1,6 +1,6 @@
|
|||
package underscore
|
||||
|
||||
import "constraints"
|
||||
import "golang.org/x/exp/constraints"
|
||||
|
||||
// Max returns the maximum value in the slice.
|
||||
// This function can currently only compare numbers reliably.
|
||||
|
|
|
|||
2
min.go
2
min.go
|
|
@ -1,6 +1,6 @@
|
|||
package underscore
|
||||
|
||||
import "constraints"
|
||||
import "golang.org/x/exp/constraints"
|
||||
|
||||
// Min returns the minimum value in the slice.
|
||||
// This function can currently only compare numbers reliably.
|
||||
|
|
|
|||
2
sum.go
2
sum.go
|
|
@ -1,6 +1,6 @@
|
|||
package underscore
|
||||
|
||||
import "constraints"
|
||||
import "golang.org/x/exp/constraints"
|
||||
|
||||
// Sum adds elements of the slice.
|
||||
func Sum[T constraints.Ordered](values []T) (sum T) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue