diff --git a/Makefile b/Makefile index 98d5c71c..946e0870 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ COMMIT_HASH=$(shell git describe --always --tags --long) COMMIT=$(if $(shell git status --porcelain --untracked-files=no),$(COMMIT_HASH)-dirty,$(COMMIT_HASH)) CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null || echo docker) PATH := bin:$(PATH) +TMPDIR := $(shell mktemp -d) .PHONY: all all: doc binary debug test check @@ -53,7 +54,7 @@ binary-container: .PHONY: binary-stacker binary-stacker: - stacker build --substitute PWD=$$PWD --no-cache + stacker build --roots ${TMPDIR} --substitute PWD=$$PWD .PHONY: image image: diff --git a/pkg/storage/storage_test.go b/pkg/storage/storage_test.go index 5254e955..8c360fa4 100644 --- a/pkg/storage/storage_test.go +++ b/pkg/storage/storage_test.go @@ -503,7 +503,9 @@ func TestNegativeCases(t *testing.T) { os.RemoveAll(dir) So(storage.NewImageStore(dir, true, true, log.Logger{Logger: zerolog.New(os.Stdout)}), ShouldNotBeNil) - So(storage.NewImageStore("/deadBEEF", true, true, log.Logger{Logger: zerolog.New(os.Stdout)}), ShouldBeNil) + if os.Geteuid() != 0 { + So(storage.NewImageStore("/deadBEEF", true, true, log.Logger{Logger: zerolog.New(os.Stdout)}), ShouldBeNil) + } }) Convey("Invalid init repo", t, func(c C) { @@ -515,7 +517,9 @@ func TestNegativeCases(t *testing.T) { il := storage.NewImageStore(dir, true, true, log.Logger{Logger: zerolog.New(os.Stdout)}) err = os.Chmod(dir, 0000) // remove all perms So(err, ShouldBeNil) - So(func() { _ = il.InitRepo("test") }, ShouldPanic) + if os.Geteuid() != 0 { + So(func() { _ = il.InitRepo("test") }, ShouldPanic) + } }) Convey("Invalid validate repo", t, func(c C) { @@ -539,7 +543,9 @@ func TestNegativeCases(t *testing.T) { So(err, ShouldNotBeNil) err = os.Chmod(dir, 0000) // remove all perms So(err, ShouldBeNil) - So(func() { _, _ = il.ValidateRepo("test") }, ShouldPanic) + if os.Geteuid() != 0 { + So(func() { _, _ = il.ValidateRepo("test") }, ShouldPanic) + } os.RemoveAll(dir) _, err = il.GetRepositories() So(err, ShouldNotBeNil) diff --git a/stacker.yaml b/stacker.yaml index af627cb7..c53e874f 100644 --- a/stacker.yaml +++ b/stacker.yaml @@ -1,7 +1,7 @@ build: from: type: docker - url: docker://golang:1.12.8 + url: docker://golang:1.14.4 binds: - ${{PWD}} -> /go/src/github.com/anuvu/zot run: | @@ -11,6 +11,16 @@ build: export PATH='/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' go get -u github.com/swaggo/swag/cmd/swag cd /go/src/github.com/anuvu/zot - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.17.1 + go get -u -v -d ./... + curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.26.0 make build_only: true + +zot: + from: + type: docker + url: docker://centos:latest + import: + - ${{PWD}}/bin/zot + run: | + cp /stacker/zot /usr/bin/zot