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
|
name: Build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Install gotip
|
- uses: actions/checkout@master
|
||||||
run: |
|
with:
|
||||||
git clone --depth=1 https://go.googlesource.com/go $HOME/gotip
|
fetch-depth: 2
|
||||||
cd $HOME/gotip/src
|
- uses: actions/setup-go@v2
|
||||||
./make.bash
|
with:
|
||||||
echo "GOROOT=$HOME/gotip" >> $GITHUB_ENV
|
go-version: '1.18'
|
||||||
echo "$HOME/gotip/bin:$PATH" >> $GITHUB_PATH
|
- name: Run tests with coverage
|
||||||
- name: Check out code into the Go module directory
|
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
|
||||||
uses: actions/checkout@v2
|
- uses: codecov/codecov-action@v2
|
||||||
|
with:
|
||||||
- name: Get dependencies
|
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
|
||||||
run: |
|
files: ./coverage.out # optional
|
||||||
go get -v -t -d ./...
|
flags: unittests # optional
|
||||||
if [ -f Gopkg.toml ]; then
|
name: codecov-umbrella # optional
|
||||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
fail_ci_if_error: true # optional (default = false)
|
||||||
dep ensure
|
verbose: true # optional (default = false)
|
||||||
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
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
FROM golang:1.18beta1-alpine
|
FROM golang:1.18-alpine
|
||||||
|
|
||||||
ENV CGO_ENABLED 0
|
ENV CGO_ENABLED 0
|
||||||
RUN apk update --no-cache
|
RUN apk update --no-cache
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package chain
|
package chain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"constraints"
|
"golang.org/x/exp/constraints"
|
||||||
|
|
||||||
u "github.com/rjNemo/underscore"
|
u "github.com/rjNemo/underscore"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
5
go.mod
5
go.mod
|
|
@ -2,7 +2,10 @@ module github.com/rjNemo/underscore
|
||||||
|
|
||||||
go 1.18
|
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 (
|
require (
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
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/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 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
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 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
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=
|
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
|
package underscore
|
||||||
|
|
||||||
import "constraints"
|
import "golang.org/x/exp/constraints"
|
||||||
|
|
||||||
// Max returns the maximum value in the slice.
|
// Max returns the maximum value in the slice.
|
||||||
// This function can currently only compare numbers reliably.
|
// This function can currently only compare numbers reliably.
|
||||||
|
|
|
||||||
2
min.go
2
min.go
|
|
@ -1,6 +1,6 @@
|
||||||
package underscore
|
package underscore
|
||||||
|
|
||||||
import "constraints"
|
import "golang.org/x/exp/constraints"
|
||||||
|
|
||||||
// Min returns the minimum value in the slice.
|
// Min returns the minimum value in the slice.
|
||||||
// This function can currently only compare numbers reliably.
|
// This function can currently only compare numbers reliably.
|
||||||
|
|
|
||||||
2
sum.go
2
sum.go
|
|
@ -1,6 +1,6 @@
|
||||||
package underscore
|
package underscore
|
||||||
|
|
||||||
import "constraints"
|
import "golang.org/x/exp/constraints"
|
||||||
|
|
||||||
// Sum adds elements of the slice.
|
// Sum adds elements of the slice.
|
||||||
func Sum[T constraints.Ordered](values []T) (sum T) {
|
func Sum[T constraints.Ordered](values []T) (sum T) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue