From ec26e9101efc98bc99d733d75a6f8cb3fbae5ec1 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Wed, 16 Mar 2022 06:08:33 -0400 Subject: [PATCH 1/2] :construction_worker: adding test and push coverage --- .github/workflows/unit-test.yml | 42 +++++++++++++-------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index a025a03..23ccce4 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -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 \ No newline at end of file + - 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) \ No newline at end of file From 36405aff84739d3823ae55e1e9d8bca5dc3d9143 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Wed, 16 Mar 2022 07:24:28 -0400 Subject: [PATCH 2/2] :arrow_up: use official Go 1.18 image --- Dockerfile | 2 +- chain/chain.go | 2 +- go.mod | 5 ++++- go.sum | 2 ++ max.go | 2 +- min.go | 2 +- sum.go | 2 +- 7 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 502712b..4974ba9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18beta1-alpine +FROM golang:1.18-alpine WORKDIR /lib diff --git a/chain/chain.go b/chain/chain.go index 3e81489..71be2c3 100644 --- a/chain/chain.go +++ b/chain/chain.go @@ -1,7 +1,7 @@ package chain import ( - "constraints" + "golang.org/x/exp/constraints" u "github.com/rjNemo/underscore" ) diff --git a/go.mod b/go.mod index 98452a0..371f6eb 100644 --- a/go.mod +++ b/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 diff --git a/go.sum b/go.sum index c221f64..99f8a6a 100644 --- a/go.sum +++ b/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= diff --git a/max.go b/max.go index b1e92ac..0799e0b 100644 --- a/max.go +++ b/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. diff --git a/min.go b/min.go index ce518fa..7789583 100644 --- a/min.go +++ b/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. diff --git a/sum.go b/sum.go index 278a14f..3d2b5db 100644 --- a/sum.go +++ b/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) {