diff --git a/Makefile b/Makefile index 1749c3cbd..cbf8181c4 100644 --- a/Makefile +++ b/Makefile @@ -32,91 +32,91 @@ LDFLAGS += -X $(PROJECT_PKG)/internal/version.GitCommit=${GIT_COMMIT} LDFLAGS += -X $(PROJECT_PKG)/internal/version.GitTreeState=${GIT_DIRTY} .PHONY: test -test: tidy vendor check-encoding +test: tidy vendor check-encoding ## tidy and run tests $(GO_EXE) test -race -v -coverprofile=coverage.txt -covermode=atomic ./... .PHONY: teste2e -teste2e: +teste2e: ## run end to end tests ./test/e2e/scripts/e2e.sh $(shell git rev-parse --show-toplevel) --clean .PHONY: covhtml -covhtml: +covhtml: ## look at code coverage open .cover/coverage.html .PHONY: clean -clean: +clean: ## clean up build git status --ignored --short | grep '^!! ' | sed 's/!! //' | xargs rm -rf .PHONY: build -build: build-linux build-mac build-windows +build: build-linux build-mac build-windows ## build for all targets .PHONY: build-linux -build-linux: build-linux-amd64 build-linux-arm64 build-linux-arm-v7 build-linux-s390x +build-linux: build-linux-amd64 build-linux-arm64 build-linux-arm-v7 build-linux-s390x ## build all linux architectures .PHONY: build-linux-amd64 -build-linux-amd64: +build-linux-amd64: ## build for linux amd64 GOARCH=amd64 CGO_ENABLED=0 GOOS=linux $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/linux/amd64/$(CLI_EXE) $(CLI_PKG) .PHONY: build-linux-arm64 -build-linux-arm64: +build-linux-arm64: ## build for linux arm64 GOARCH=arm64 CGO_ENABLED=0 GOOS=linux $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/linux/arm64/$(CLI_EXE) $(CLI_PKG) .PHONY: build-linux-arm-v7 -build-linux-arm-v7: +build-linux-arm-v7: ## build for linux arm v7 GOARCH=arm CGO_ENABLED=0 GOOS=linux $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/linux/arm/v7/$(CLI_EXE) $(CLI_PKG) .PHONY: build-linux-s390x -build-linux-s390x: +build-linux-s390x: ## build for linux s390x GOARCH=s390x CGO_ENABLED=0 GOOS=linux $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/linux/s390x/$(CLI_EXE) $(CLI_PKG) .PHONY: build-mac -build-mac: build-mac-arm64 build-mac-amd64 +build-mac: build-mac-arm64 build-mac-amd64 ## build all mac architectures .PHONY: build-mac-amd64 -build-mac-amd64: +build-mac-amd64: ## build for mac amd64 GOARCH=amd64 CGO_ENABLED=0 GOOS=darwin $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/darwin/amd64/$(CLI_EXE) $(CLI_PKG) .PHONY: build-mac-arm64 -build-mac-arm64: +build-mac-arm64: ## build for mac arm64 GOARCH=arm64 CGO_ENABLED=0 GOOS=darwin $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/darwin/arm64/$(CLI_EXE) $(CLI_PKG) .PHONY: build-windows -build-windows: build-windows-amd64 build-windows-arm64 +build-windows: build-windows-amd64 build-windows-arm64 ## build all windows architectures .PHONY: build-windows-amd64 -build-windows-amd64: +build-windows-amd64: ## build for windows amd64 GOARCH=amd64 CGO_ENABLED=0 GOOS=windows $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/windows/amd64/$(CLI_EXE).exe $(CLI_PKG) .PHONY: build-windows-arm64 -build-windows-arm64: +build-windows-arm64: ## build for windows arm64 GOARCH=arm64 CGO_ENABLED=0 GOOS=windows $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/windows/arm64/$(CLI_EXE).exe $(CLI_PKG) .PHONY: check-encoding -check-encoding: +check-encoding: ## check file CR/LF encoding ! find cmd internal -name "*.go" -type f -exec file "{}" ";" | grep CRLF .PHONY: fix-encoding -fix-encoding: +fix-encoding: ## fix file CR/LF encoding find cmd internal -type f -name "*.go" -exec sed -i -e "s/\r//g" {} + .PHONY: tidy -tidy: +tidy: ## go mod tidy GO111MODULE=on $(GO_EXE) mod tidy .PHONY: vendor -vendor: +vendor: ## go mod vendor GO111MODULE=on $(GO_EXE) mod vendor .PHONY: fetch-dist -fetch-dist: +fetch-dist: ## fetch distribution mkdir -p _dist cd _dist && \ for obj in ${TARGET_OBJS} ; do \ @@ -124,15 +124,19 @@ fetch-dist: done .PHONY: sign -sign: +sign: ## sign for f in $$(ls _dist/*.{gz,txt} 2>/dev/null) ; do \ gpg --armor --detach-sign $${f} ; \ done .PHONY: teste2e-covdata -teste2e-covdata: +teste2e-covdata: ## test e2e coverage export GOCOVERDIR=$(CURDIR)/test/e2e/.cover; \ rm -rf $$GOCOVERDIR; \ mkdir -p $$GOCOVERDIR; \ $(MAKE) teste2e; \ - $(GO_EXE) tool covdata textfmt -i=$$GOCOVERDIR -o "$(CURDIR)/test/e2e/coverage.txt" \ No newline at end of file + $(GO_EXE) tool covdata textfmt -i=$$GOCOVERDIR -o "$(CURDIR)/test/e2e/coverage.txt" + +.PHONY: help +help: ## Display this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[%\/0-9A-Za-z_-]+:.*?##/ { printf " \033[36m%-45s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) \ No newline at end of file diff --git a/go.mod b/go.mod index fabcdff52..d67fd365f 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 - golang.org/x/term v0.8.0 + golang.org/x/term v0.9.0 gopkg.in/yaml.v3 v3.0.1 oras.land/oras-go/v2 v2.2.1-0.20230531090906-7dd0378382c6 ) @@ -19,5 +19,5 @@ require ( github.com/docker/docker-credential-helpers v0.7.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect golang.org/x/sync v0.2.0 // indirect - golang.org/x/sys v0.8.0 // indirect + golang.org/x/sys v0.9.0 // indirect ) diff --git a/go.sum b/go.sum index 7814d36a9..af86dc08c 100644 --- a/go.sum +++ b/go.sum @@ -29,10 +29,10 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.9.0 h1:GRRCnKYhdQrD8kfRAdQ6Zcw1P0OcELxGLKJvtjVMZ28= +golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= 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/internal/version/version_test.go b/internal/version/version_test.go new file mode 100644 index 000000000..eaca323ab --- /dev/null +++ b/internal/version/version_test.go @@ -0,0 +1,28 @@ +/* +Copyright The ORAS Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package version + +import ( + "reflect" + "testing" +) + +func Test_GetVersion_when_BuildData_is_empty(t *testing.T) { + BuildMetadata = "" + expected := Version + actual := GetVersion() + if !reflect.DeepEqual(expected, actual) { + t.Errorf("Tested GetVersion expected was %v actually got %v", expected, actual) + } +} diff --git a/test/e2e/go.mod b/test/e2e/go.mod index be9affff7..e3505ea06 100644 --- a/test/e2e/go.mod +++ b/test/e2e/go.mod @@ -3,7 +3,7 @@ module oras.land/oras/test/e2e go 1.20 require ( - github.com/onsi/ginkgo/v2 v2.10.0 + github.com/onsi/ginkgo/v2 v2.11.0 github.com/onsi/gomega v1.27.8 github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/image-spec v1.1.0-rc.3 @@ -18,7 +18,7 @@ require ( github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect golang.org/x/net v0.10.0 // indirect golang.org/x/sync v0.2.0 // indirect - golang.org/x/sys v0.8.0 // indirect + golang.org/x/sys v0.9.0 // indirect golang.org/x/text v0.9.0 // indirect golang.org/x/tools v0.9.3 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/test/e2e/go.sum b/test/e2e/go.sum index 998bf62ad..a3cc76189 100644 --- a/test/e2e/go.sum +++ b/test/e2e/go.sum @@ -14,8 +14,8 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/onsi/ginkgo/v2 v2.10.0 h1:sfUl4qgLdvkChZrWCYndY2EAu9BRIw1YphNAzy1VNWs= -github.com/onsi/ginkgo/v2 v2.10.0/go.mod h1:UDQOh5wbQUlMnkLfVaIUMtQ1Vus92oM+P2JX1aulgcE= +github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= +github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc= github.com/onsi/gomega v1.27.8/go.mod h1:2J8vzI/s+2shY9XHRApDkdgPo1TKT7P2u6fXeJKFnNQ= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= @@ -33,8 +33,8 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM=