2019-06-20 18:36:40 -05:00
export GO111MODULE = on
2019-07-20 19:30:58 -05:00
TOP_LEVEL = $( shell git rev-parse --show-toplevel)
2019-09-16 13:01:59 -05:00
COMMIT_HASH = $( shell git describe --always --tags --long)
2022-10-11 11:01:59 -05:00
RELEASE_TAG = $( shell git describe --tags --abbrev= 0)
2021-10-15 10:05:00 -05:00
GO_VERSION = $( shell go version | awk '{print $$3}' )
2021-12-15 17:47:53 -05:00
COMMIT ?= $( if $( shell git status --porcelain --untracked-files= no) ,$( COMMIT_HASH) -dirty,$( COMMIT_HASH) )
2019-08-14 14:35:51 -05:00
CONTAINER_RUNTIME := $( shell command -v podman 2> /dev/null || echo docker)
2020-07-09 02:10:11 -05:00
TMPDIR := $( shell mktemp -d)
2022-03-22 17:13:10 -05:00
TOOLSDIR := $( shell pwd ) /hack/tools
PATH := bin:$( TOOLSDIR) /bin:$( PATH)
2020-11-05 20:57:06 -05:00
STACKER := $( shell which stacker)
2021-12-13 14:23:31 -05:00
GOLINTER := $( TOOLSDIR) /bin/golangci-lint
2022-10-05 05:21:14 -05:00
GOLINTER_VERSION := v1.49.0
2021-12-07 08:07:22 -05:00
NOTATION := $( TOOLSDIR) /bin/notation
2023-02-28 10:38:49 -05:00
NOTATION_VERSION := 1.0.0-rc.2
2022-11-01 11:16:14 -05:00
COSIGN := $( TOOLSDIR) /bin/cosign
2022-07-22 06:34:12 -05:00
HELM := $( TOOLSDIR) /bin/helm
ORAS := $( TOOLSDIR) /bin/oras
2023-02-28 10:38:49 -05:00
ORAS_VERSION := 1.0.0-rc.1
2022-07-22 06:34:12 -05:00
REGCLIENT := $( TOOLSDIR) /bin/regctl
2022-11-08 03:38:16 -05:00
REGCLIENT_VERSION := v0.4.5
2023-01-13 03:49:42 -05:00
ACTION_VALIDATOR := $( TOOLSDIR) /bin/action-validator
ACTION_VALIDATOR_VERSION := v0.2.1
2023-03-22 12:16:35 -05:00
ZUI_VERSION := commit-2f94cc3
2022-10-18 22:47:41 -05:00
STACKER := $( TOOLSDIR) /bin/stacker
2022-03-22 17:13:10 -05:00
BATS := $( TOOLSDIR) /bin/bats
2022-03-15 09:34:39 -05:00
TESTDATA := $( TOP_LEVEL) /test/data
2021-12-03 12:42:03 -05:00
OS ?= linux
ARCH ?= amd64
2022-01-13 17:06:35 -05:00
BENCH_OUTPUT ?= stdout
2023-03-09 13:43:26 -05:00
EXTENSIONS ?= sync,search,scrub,metrics,lint,ui,mgmt
2022-04-27 01:00:20 -05:00
comma := ,
hyphen := -
extended-name :=
2019-06-20 18:36:40 -05:00
.PHONY : all
2023-02-23 15:28:08 -05:00
all : modcheck swagger binary binary -minimal binary -debug cli bench exporter -minimal verify -config test covhtml check check -gh -actions
2022-03-02 16:20:35 -05:00
2023-03-21 12:25:13 -05:00
.PHONY : modtidy
modtidy :
2022-03-02 16:20:35 -05:00
go mod tidy
2022-01-24 00:19:01 -05:00
2023-03-21 12:25:13 -05:00
.PHONY : modcheck
modcheck : modtidy
$( eval UNCOMMITED_FILES = $( shell git status --porcelain | grep -c 'go.mod\|go.sum' ) )
@if [ $( UNCOMMITED_FILES) != 0 ] ; then \
echo "Updated go.mod and/or go.sum have uncommitted changes, commit the changes accordingly " ; \
git status; \
exit 1; \
fi
2022-04-27 01:00:20 -05:00
.PHONY : create -name
create-name :
i f d e f E X T E N S I O N S
$( eval extended-name= -$( subst $( comma) ,$( hyphen) ,$( EXTENSIONS) ) )
e n d i f
2022-07-07 06:11:01 -05:00
.PHONY : build -metadata
2023-02-10 17:52:54 -05:00
build-metadata : $( if $ ( findstring ui ,$ ( EXTENSIONS ) ) , ui )
2022-07-07 06:11:01 -05:00
echo "Imports: \n"
go list -tags $( EXTENSIONS) -f '{{ join .Imports "\n" }}' ./... | sort -u
echo "\n Files: \n"
go list -tags $( EXTENSIONS) -f '{{ join .GoFiles "\n" }}' ./... | sort -u
2022-10-03 11:53:44 -05:00
.PHONY : binary -minimal
binary-minimal : EXTENSIONS =minimal # tag doesn't exist, but we need it to overwrite default value and indicate that we have no extension in build-metadata
binary-minimal : modcheck build -metadata
2022-10-11 11:01:59 -05:00
env CGO_ENABLED = 0 GOOS = $( OS) GOARCH = $( ARCH) go build -o bin/zot-$( OS) -$( ARCH) -minimal -buildmode= pie -tags containers_image_openpgp -v -trimpath -ldflags " -X zotregistry.io/zot/pkg/api/config.ReleaseTag= ${ RELEASE_TAG } -X zotregistry.io/zot/pkg/api/config.Commit= ${ COMMIT } -X zotregistry.io/zot/pkg/api/config.BinaryType=minimal -X zotregistry.io/zot/pkg/api/config.GoVersion= ${ GO_VERSION } -s -w " ./cmd/zot
2022-10-03 11:53:44 -05:00
2022-04-27 01:00:20 -05:00
.PHONY : binary
2023-02-10 17:52:54 -05:00
binary : $( if $ ( findstring ui ,$ ( EXTENSIONS ) ) , ui )
2022-10-03 11:53:44 -05:00
binary : modcheck create -name build -metadata
2022-10-11 11:01:59 -05:00
env CGO_ENABLED = 0 GOOS = $( OS) GOARCH = $( ARCH) go build -o bin/zot-$( OS) -$( ARCH) -buildmode= pie -tags $( EXTENSIONS) ,containers_image_openpgp -v -trimpath -ldflags " -X zotregistry.io/zot/pkg/api/config.ReleaseTag= ${ RELEASE_TAG } -X zotregistry.io/zot/pkg/api/config.Commit= ${ COMMIT } -X zotregistry.io/zot/pkg/api/config.BinaryType= $( extended-name) -X zotregistry.io/zot/pkg/api/config.GoVersion= ${ GO_VERSION } -s -w " ./cmd/zot
2022-04-27 01:00:20 -05:00
2022-01-24 00:19:01 -05:00
.PHONY : binary -debug
2023-02-10 17:52:54 -05:00
binary-debug : $( if $ ( findstring ui ,$ ( EXTENSIONS ) ) , ui )
2022-07-07 06:11:01 -05:00
binary-debug : modcheck swagger create -name build -metadata
2022-10-11 11:01:59 -05:00
env CGO_ENABLED = 0 GOOS = $( OS) GOARCH = $( ARCH) go build -o bin/zot-$( OS) -$( ARCH) -debug -buildmode= pie -tags $( EXTENSIONS) ,debug,containers_image_openpgp -v -gcflags all = '-N -l' -ldflags " -X zotregistry.io/zot/pkg/api/config.ReleaseTag= ${ RELEASE_TAG } -X zotregistry.io/zot/pkg/api/config.Commit= ${ COMMIT } -X zotregistry.io/zot/pkg/api/config.BinaryType= $( extended-name) -X zotregistry.io/zot/pkg/api/config.GoVersion= ${ GO_VERSION } " ./cmd/zot
2021-12-15 17:14:53 -05:00
2022-01-10 20:15:35 -05:00
.PHONY : cli
2022-07-07 06:11:01 -05:00
cli : modcheck create -name build -metadata
2022-10-10 07:05:55 -05:00
env CGO_ENABLED = 0 GOOS = $( OS) GOARCH = $( ARCH) go build -o bin/zli-$( OS) -$( ARCH) -buildmode= pie -tags $( EXTENSIONS) ,search,containers_image_openpgp -v -trimpath -ldflags " -X zotregistry.io/zot/pkg/api/config.Commit= ${ COMMIT } -X zotregistry.io/zot/pkg/api/config.BinaryType= $( extended-name) -X zotregistry.io/zot/pkg/api/config.GoVersion= ${ GO_VERSION } -s -w " ./cmd/zli
2022-01-10 20:15:35 -05:00
2021-12-10 17:27:40 -05:00
.PHONY : bench
2022-07-07 06:11:01 -05:00
bench : modcheck create -name build -metadata
2022-04-27 01:00:20 -05:00
env CGO_ENABLED = 0 GOOS = $( OS) GOARCH = $( ARCH) go build -o bin/zb-$( OS) -$( ARCH) -buildmode= pie -tags $( EXTENSIONS) ,containers_image_openpgp -v -trimpath -ldflags " -X zotregistry.io/zot/pkg/api/config.Commit= ${ COMMIT } -X zotregistry.io/zot/pkg/api/config.BinaryType= $( extended-name) -X zotregistry.io/zot/pkg/api/config.GoVersion= ${ GO_VERSION } -s -w " ./cmd/zb
2021-12-10 17:27:40 -05:00
2021-10-15 10:05:00 -05:00
.PHONY : exporter -minimal
2022-07-07 06:11:01 -05:00
exporter-minimal : EXTENSIONS =minimal # tag doesn't exist, but we need it to overwrite default value and indicate that we have no extension in build-metadata
exporter-minimal : modcheck build -metadata
2022-04-27 01:00:20 -05:00
env CGO_ENABLED = 0 GOOS = $( OS) GOARCH = $( ARCH) go build -o bin/zxp-$( OS) -$( ARCH) -buildmode= pie -tags containers_image_openpgp -v -trimpath ./cmd/zxp
2019-06-20 18:36:40 -05:00
.PHONY : test
2023-02-10 17:52:54 -05:00
test : $( if $ ( findstring ui ,$ ( EXTENSIONS ) ) , ui )
2023-02-13 13:43:52 -05:00
test : check -skopeo $( TESTDATA ) $( ORAS )
2023-02-09 07:28:01 -05:00
go test -failfast -tags $( EXTENSIONS) ,containers_image_openpgp -v -trimpath -race -timeout 15m -cover -coverpkg ./... -coverprofile= coverage-extended.txt -covermode= atomic ./...
go test -failfast -tags containers_image_openpgp -v -trimpath -race -cover -coverpkg ./... -coverprofile= coverage-minimal.txt -covermode= atomic ./...
2021-12-20 23:18:13 -05:00
# development-mode unit tests possibly using failure injection
2023-02-09 07:28:01 -05:00
go test -failfast -tags dev,$( EXTENSIONS) ,containers_image_openpgp -v -trimpath -race -timeout 15m -cover -coverpkg ./... -coverprofile= coverage-dev-extended.txt -covermode= atomic ./pkg/test/... ./pkg/api/... ./pkg/storage/... ./pkg/extensions/sync/... -run ^TestInject
go test -failfast -tags dev,containers_image_openpgp -v -trimpath -race -cover -coverpkg ./... -coverprofile= coverage-dev-minimal.txt -covermode= atomic ./pkg/test/... ./pkg/storage/... ./pkg/extensions/sync/... -run ^TestInject
go test -failfast -tags stress,$( EXTENSIONS) ,containers_image_openpgp -v -trimpath -race -timeout 15m ./pkg/cli/stress_test.go
2019-06-20 18:36:40 -05:00
2022-03-15 09:34:39 -05:00
.PHONY : privileged -test
2023-02-10 17:52:54 -05:00
privileged-test : $( if $ ( findstring ui ,$ ( EXTENSIONS ) ) , ui )
2023-02-13 13:43:52 -05:00
privileged-test : check -skopeo $( TESTDATA )
2022-04-27 01:00:20 -05:00
go test -failfast -tags needprivileges,$( EXTENSIONS) ,containers_image_openpgp -v -trimpath -race -timeout 15m -cover -coverpkg ./... -coverprofile= coverage-dev-needprivileges.txt -covermode= atomic ./pkg/storage/... ./pkg/cli/... -run ^TestElevatedPrivileges
2022-03-15 09:34:39 -05:00
$(TESTDATA) : check -skopeo
2022-08-12 07:18:41 -05:00
$( shell mkdir -p ${ TESTDATA } ; cd ${ TESTDATA } ; mkdir -p noidentity; ../scripts/gen_certs.sh; cd ${ TESTDATA } /noidentity; ../../scripts/gen_nameless_certs.sh; cd ${ TOP_LEVEL } ; skopeo --insecure-policy copy -q docker://public.ecr.aws/t0x7q1g8/centos:7 oci:${ TESTDATA } /zot-test:0.0.1; skopeo --insecure-policy copy -q docker://public.ecr.aws/t0x7q1g8/centos:8 oci:${ TESTDATA } /zot-cve-test:0.0.1)
2022-03-15 09:34:39 -05:00
$( shell chmod -R a = rwx ${ TESTDATA } )
2022-01-13 17:06:35 -05:00
.PHONY : run -bench
run-bench : binary bench
2022-03-24 12:52:39 -05:00
bin/zot-$( OS) -$( ARCH) serve examples/config-bench.json &
2022-01-13 17:06:35 -05:00
sleep 5
2022-01-24 00:19:01 -05:00
bin/zb-$( OS) -$( ARCH) -c 10 -n 100 -o $( BENCH_OUTPUT) http://localhost:8080
killall -r zot-*
2022-01-13 17:06:35 -05:00
2021-12-07 08:07:22 -05:00
.PHONY : check -skopeo
check-skopeo :
skopeo -v || ( echo "You need skopeo to be installed in order to run tests" ; exit 1)
$(NOTATION) :
mkdir -p $( TOOLSDIR) /bin
2023-02-13 13:43:52 -05:00
curl -Lo notation.tar.gz https://github.com/notaryproject/notation/releases/download/v$( NOTATION_VERSION) /notation_$( NOTATION_VERSION) _linux_amd64.tar.gz
2021-12-07 08:07:22 -05:00
tar xvzf notation.tar.gz -C $( TOOLSDIR) /bin notation
rm notation.tar.gz
2022-07-22 06:34:12 -05:00
$(ORAS) :
mkdir -p $( TOOLSDIR) /bin
2022-11-28 13:43:53 -05:00
curl -Lo oras.tar.gz https://github.com/oras-project/oras/releases/download/v$( ORAS_VERSION) /oras_$( ORAS_VERSION) _linux_amd64.tar.gz
2022-07-22 06:34:12 -05:00
tar xvzf oras.tar.gz -C $( TOOLSDIR) /bin oras
rm oras.tar.gz
$(HELM) :
mkdir -p $( TOOLSDIR) /bin
curl -Lo helm.tar.gz https://get.helm.sh/helm-v3.9.1-linux-amd64.tar.gz
tar xvzf helm.tar.gz -C $( TOOLSDIR) /bin linux-amd64/helm --strip-components= 1
rm helm.tar.gz
$(REGCLIENT) :
mkdir -p $( TOOLSDIR) /bin
2022-11-08 03:38:16 -05:00
curl -Lo regctl https://github.com/regclient/regclient/releases/download/$( REGCLIENT_VERSION) /regctl-linux-amd64
2022-07-22 06:34:12 -05:00
cp regctl $( TOOLSDIR) /bin/regctl
chmod +x $( TOOLSDIR) /bin/regctl
2023-01-13 03:49:42 -05:00
$(ACTION_VALIDATOR) :
mkdir -p $( TOOLSDIR) /bin
curl -Lo action-validator https://github.com/mpalmer/action-validator/releases/download/$( ACTION_VALIDATOR_VERSION) /action-validator_linux_amd64
cp action-validator $( TOOLSDIR) /bin/action-validator
chmod +x $( TOOLSDIR) /bin/action-validator
.PHONY : check -gh -actions
check-gh-actions : $( ACTION_VALIDATOR )
for i in $$ ( ls .github/workflows/*) ; do $( ACTION_VALIDATOR) $$ i; done
2020-01-24 16:32:38 -05:00
.PHONY : covhtml
covhtml :
2021-12-20 23:18:13 -05:00
go install github.com/wadey/gocovmerge@latest
2022-03-15 09:34:39 -05:00
gocovmerge coverage*.txt > coverage.txt
2020-01-24 16:32:38 -05:00
go tool cover -html= coverage.txt -o coverage.html
2021-12-13 14:23:31 -05:00
$(GOLINTER) :
mkdir -p $( TOOLSDIR) /bin
2022-03-21 12:37:23 -05:00
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $( TOOLSDIR) /bin $( GOLINTER_VERSION)
2021-12-13 14:23:31 -05:00
$( GOLINTER) version
2019-06-20 18:36:40 -05:00
.PHONY : check
2023-02-10 17:52:54 -05:00
check : $( if $ ( findstring ui ,$ ( EXTENSIONS ) ) , ui )
2021-12-13 14:23:31 -05:00
check : ./golangcilint .yaml $( GOLINTER )
2023-02-10 17:52:54 -05:00
mkdir -p pkg/extensions/build; touch pkg/extensions/build/.empty
2022-04-27 01:00:20 -05:00
$( GOLINTER) --config ./golangcilint.yaml run --enable-all --out-format= colored-line-number --build-tags containers_image_openpgp ./...
$( GOLINTER) --config ./golangcilint.yaml run --enable-all --out-format= colored-line-number --build-tags $( EXTENSIONS) ,containers_image_openpgp ./...
2023-02-23 15:28:08 -05:00
$( GOLINTER) --config ./golangcilint.yaml run --enable-all --out-format= colored-line-number --build-tags $( EXTENSIONS) ,containers_image_openpgp,debug ./...
2022-04-27 01:00:20 -05:00
$( GOLINTER) --config ./golangcilint.yaml run --enable-all --out-format= colored-line-number --build-tags dev,containers_image_openpgp ./...
$( GOLINTER) --config ./golangcilint.yaml run --enable-all --out-format= colored-line-number --build-tags dev,$( EXTENSIONS) ,containers_image_openpgp ./...
$( GOLINTER) --config ./golangcilint.yaml run --enable-all --out-format= colored-line-number --build-tags stress,$( EXTENSIONS) ,containers_image_openpgp ./...
2023-02-10 17:52:54 -05:00
rm pkg/extensions/build/.empty
2019-06-20 18:36:40 -05:00
2021-10-20 16:01:06 -05:00
swagger/docs.go :
2022-02-24 15:31:36 -05:00
swag -v || go install github.com/swaggo/swag/cmd/swag@1.6.3
2021-10-20 16:01:06 -05:00
swag init -o swagger -g pkg/api/routes.go
2019-06-20 18:36:40 -05:00
2021-10-20 16:01:06 -05:00
.PHONY : swagger
2022-02-24 15:31:36 -05:00
swagger : swagger /docs .go pkg /api /routes .go
2019-08-28 17:58:00 -05:00
2020-12-03 14:33:38 -05:00
.PHONY : update -licenses
update-licenses :
2022-01-24 12:31:39 -05:00
@echo "Detecting and updating licenses ... please be patient!"
go install github.com/google/go-licenses@latest
$( shell echo "Module | License URL | License" > THIRD-PARTY-LICENSES.md; echo "---|---|---" >> THIRD-PARTY-LICENSES.md; for i in $$ ( go list -m all | awk '{print $$1}' ) ; do l = $$ ( go-licenses csv $$ i 2>/dev/null) ; if [ $$ ? -ne 0 ] ; then continue ; fi ; echo $$ l | tr \, \| | tr ' ' '\n' ; done | sort -u >> THIRD-PARTY-LICENSES.md)
.PHONY : check -licenses
check-licenses :
go install github.com/google/go-licenses@latest
2022-04-27 01:00:20 -05:00
@for tag in " $( EXTENSIONS) ,containers_image_openpgp " " $( EXTENSIONS) ,containers_image_openpgp " ; do \
2022-01-24 12:31:39 -05:00
echo Evaluating tag: $$ tag; \
for mod in $$ ( go list -m -f '{{if not (or .Indirect .Main)}}{{.Path}}{{end}}' all) ; do \
while [ x$$ mod != x ] ; do \
echo -n " Checking $$ mod ... " ; \
result = $$ ( GOFLAGS = " -tags= $$ {tag} " go-licenses check $$ mod 2>& 1) ; \
if [ $$ ? -eq 0 ] ; then \
echo OK; \
break; \
fi ; \
echo " $$ {result} " | grep -q "Forbidden" ; \
if [ $$ ? -eq 0 ] ; then \
echo FAIL; \
exit 1; \
fi ; \
2022-10-04 15:36:19 -05:00
echo " $$ {result} " | egrep -q "missing go.sum entry|no required module provides package|build constraints exclude all|updates to go.mod needed|non-Go code" ; \
2022-01-24 12:31:39 -05:00
if [ $$ ? -eq 0 ] ; then \
echo UNKNOWN; \
break; \
fi ; \
done ; \
done ; \
done
2020-12-03 14:33:38 -05:00
2019-06-20 18:36:40 -05:00
.PHONY : clean
clean :
2021-12-10 17:27:40 -05:00
rm -f bin/z*
2021-12-13 14:23:31 -05:00
rm -rf hack
2022-05-10 03:28:26 -05:00
rm -rf test/data/zot-test
rm -rf test/data/zot-cve-test
2023-02-10 17:52:54 -05:00
rm -rf pkg/extensions/build
2019-06-20 18:36:40 -05:00
.PHONY : run
run : binary test
2022-01-24 00:19:01 -05:00
./bin/zot-$( OS) -$( ARCH) serve examples/config-test.json
2019-08-14 14:35:51 -05:00
2022-01-07 07:58:02 -05:00
.PHONY : verify -config
2022-03-30 08:02:03 -05:00
verify-config : _verify -config verify -config -warnings verify -config -commited
.PHONY : _verify -config
_verify-config : binary
rm -f output.txt
$( foreach file, $( wildcard examples/config-*) , ./bin/zot-$( OS) -$( ARCH) verify $( file) 2>& 1 | tee -a output.txt || exit 1; )
.PHONY : verify -config -warnings
verify-config-warnings : _verify -config
$( eval WARNINGS = $( shell cat output.txt | grep -c '"warn"' ) )
$( eval ERRORS = $( shell cat output.txt | grep -c '"error"' ) )
@if [ $( WARNINGS) != 0 ] || [ $( ERRORS) != 0 ] ; then \
echo "verify-config-warnings: warnings or errors found while verifying configs" ; \
rm output.txt; \
exit 1; \
fi
rm -f output.txt
.PHONY : verify -config -commited
verify-config-commited : _verify -config
$( eval UNCOMMITED_FILES = $( shell git status --porcelain | grep -c examples/config-) )
@if [ $( UNCOMMITED_FILES) != 0 ] ; then \
echo "Uncommited config files, make sure all config files are commited. Verify might have changed a config file." ; \
exit 1; \
fi ; \
2022-01-07 07:58:02 -05:00
2022-07-15 06:10:51 -05:00
.PHONY : gqlgen
gqlgen :
cd pkg/extensions/search; \
go run github.com/99designs/gqlgen version; \
go run github.com/99designs/gqlgen generate
.PHONY : verify -gql -committed
verify-gql-committed :
$( eval UNCOMMITED_FILES = $( shell git status --porcelain | grep -c extensions/search) )
@if [ $( UNCOMMITED_FILES) != 0 ] ; then \
echo "Updated gql files uncommitted, make sure all gql files are committed:" ; \
git status; \
exit 1; \
fi ; \
2019-08-14 14:35:51 -05:00
.PHONY : binary -container
binary-container :
2022-11-10 15:09:39 -05:00
${ CONTAINER_RUNTIME } build ${ BUILD_ARGS } -f build/Dockerfile -t zot-build:latest .
2020-11-05 20:39:14 -05:00
.PHONY : run -container
run-container :
2021-12-03 22:50:58 -05:00
${ CONTAINER_RUNTIME } run --rm --security-opt label = disable -v $$ ( pwd ) :/go/src/github.com/project-zot/zot \
2020-11-05 20:39:14 -05:00
zot-build:latest
2019-08-14 18:26:25 -05:00
.PHONY : binary -stacker
binary-stacker :
2023-02-10 17:52:54 -05:00
${ STACKER } --debug build \
2022-11-10 15:09:39 -05:00
-f build/stacker.yaml \
2023-02-10 17:52:54 -05:00
--substitute PWD = $$ PWD \
--substitute COMMIT = $$ COMMIT \
--substitute ARCH = $$ ARCH \
--substitute OS = $$ OS
2020-01-24 12:54:38 -05:00
.PHONY : image
image :
2022-11-10 15:09:39 -05:00
${ CONTAINER_RUNTIME } build ${ BUILD_ARGS } -f build/Dockerfile -t zot:latest .
2022-03-22 17:13:10 -05:00
$(BATS) :
rm -rf bats-core; \
git clone https://github.com/bats-core/bats-core.git; \
cd bats-core; ./install.sh $( TOOLSDIR) ; cd ..; \
rm -rf bats-core
2022-10-18 22:47:41 -05:00
.PHONY : test -push -pull
test-push-pull : binary check -skopeo $( BATS ) $( REGCLIENT ) $( ORAS ) $( HELM )
2022-04-27 01:00:20 -05:00
$( BATS) --trace --print-output-on-failure test/blackbox/pushpull.bats
2022-03-22 17:13:10 -05:00
2022-10-18 22:47:41 -05:00
.PHONY : test -push -pull -verbose
test-push-pull-verbose : binary check -skopeo $( BATS )
2022-04-27 01:00:20 -05:00
$( BATS) --trace --verbose-run --print-output-on-failure --show-output-of-passing-tests test/blackbox/pushpull.bats
2023-04-07 11:49:24 -05:00
.PHONY : test -push -pull -running -dedupe
test-push-pull-running-dedupe : binary check -skopeo $( BATS ) $( REGCLIENT ) $( ORAS ) $( HELM )
$( BATS) --trace --print-output-on-failure test/blackbox/pushpull_running_dedupe.bats
.PHONY : test -push -pull -running -dedupe -verbose
test-push-pull-running-dedupe-verbose : binary check -skopeo $( BATS ) $( REGCLIENT ) $( ORAS ) $( HELM )
$( BATS) --trace --verbose-run --print-output-on-failure --show-output-of-passing-tests test/blackbox/pushpull_running_dedupe.bats
.PHONY : test -restore -s 3-blobs
test-restore-s3-blobs : binary check -skopeo $( BATS ) $( REGCLIENT ) $( ORAS ) $( HELM )
$( BATS) --trace --print-output-on-failure test/blackbox/restore_s3_blobs.bats
.PHONY : test -restore -s 3-blobs -verbose
test-restore-s3-blobs-verbose : binary check -skopeo $( BATS ) $( REGCLIENT ) $( ORAS ) $( HELM )
$( BATS) --trace --verbose-run --print-output-on-failure --show-output-of-passing-tests test/blackbox/restore_s3_blobs.bats
2023-03-10 13:37:29 -05:00
.PHONY : test -bats -referrers
test-bats-referrers : EXTENSIONS =search
test-bats-referrers : binary check -skopeo $( BATS ) $( ORAS )
$( BATS) --trace --print-output-on-failure test/blackbox/referrers.bats
2022-11-22 13:29:57 -05:00
.PHONY : test -cloud -only
test-cloud-only : binary check -skopeo $( BATS )
$( BATS) --trace --print-output-on-failure test/blackbox/cloud-only.bats
.PHONY : test -cloud -only -verbose
test-cloud-only-verbose : binary check -skopeo $( BATS )
$( BATS) --trace --verbose-run --print-output-on-failure --show-output-of-passing-tests test/blackbox/cloud-only.bats
2022-10-18 22:47:41 -05:00
.PHONY : test -bats -sync
test-bats-sync : EXTENSIONS =sync
2022-11-22 13:10:32 -05:00
test-bats-sync : binary binary -minimal check -skopeo $( BATS ) $( NOTATION ) $( COSIGN )
2022-04-27 01:00:20 -05:00
$( BATS) --trace --print-output-on-failure test/blackbox/sync.bats
2022-12-16 12:33:46 -05:00
$( BATS) --trace --print-output-on-failure test/blackbox/sync_docker.bats
2022-04-27 01:00:20 -05:00
2022-10-18 22:47:41 -05:00
.PHONY : test -bats -sync -verbose
test-bats-sync-verbose : EXTENSIONS =sync
2022-11-22 13:10:32 -05:00
test-bats-sync-verbose : binary binary -minimal check -skopeo $( BATS ) $( NOTATION ) $( COSIGN )
2022-04-27 01:00:20 -05:00
$( BATS) --trace -t -x -p --verbose-run --print-output-on-failure --show-output-of-passing-tests test/blackbox/sync.bats
2022-12-16 12:33:46 -05:00
$( BATS) --trace -t -x -p --verbose-run --print-output-on-failure --show-output-of-passing-tests test/blackbox/sync_docker.bats
2022-04-27 01:00:20 -05:00
2022-10-18 22:47:41 -05:00
.PHONY : test -bats -cve
test-bats-cve : EXTENSIONS =search
test-bats-cve : binary cli check -skopeo $( BATS )
2022-04-27 01:00:20 -05:00
$( BATS) --trace --print-output-on-failure test/blackbox/cve.bats
2022-10-18 22:47:41 -05:00
.PHONY : test -bats -cve -verbose
test-bats-cve-verbose : EXTENSIONS =search
test-bats-cve-verbose : binary cli check -skopeo $( BATS )
2022-04-27 01:00:20 -05:00
$( BATS) --trace -t -x -p --verbose-run --print-output-on-failure --show-output-of-passing-tests test/blackbox/cve.bats
2022-10-18 22:47:41 -05:00
.PHONY : test -bats -scrub
test-bats-scrub : EXTENSIONS =scrub
test-bats-scrub : binary check -skopeo $( BATS )
2022-04-27 01:00:20 -05:00
$( BATS) --trace --print-output-on-failure test/blackbox/scrub.bats
2022-10-18 22:47:41 -05:00
.PHONY : test -bats -scrub -verbose
test-bats-scrub-verbose : EXTENSIONS =scrub
test-bats-scrub-verbose : binary check -skopeo $( BATS )
2022-04-27 01:00:20 -05:00
$( BATS) --trace -p --verbose-run --print-output-on-failure --show-output-of-passing-tests test/blackbox/scrub.bats
2022-10-18 22:47:41 -05:00
.PHONY : test -bats -metrics
test-bats-metrics : EXTENSIONS =metrics
test-bats-metrics : binary check -skopeo $( BATS )
2022-04-27 01:00:20 -05:00
$( BATS) --trace --print-output-on-failure test/blackbox/metrics.bats
2022-10-18 22:47:41 -05:00
.PHONY : test -bats -metrics -verbose
test-bats-metrics-verbose : EXTENSIONS =metrics
test-bats-metrics-verbose : binary check -skopeo $( BATS )
2022-04-27 01:00:20 -05:00
$( BATS) --trace -p --verbose-run --print-output-on-failure --show-output-of-passing-tests test/blackbox/metrics.bats
2022-07-27 12:37:55 -05:00
2022-11-18 12:35:28 -05:00
.PHONY : test -anonymous -push -pull
test-anonymous-push-pull : binary check -skopeo $( BATS )
$( BATS) --trace --print-output-on-failure test/blackbox/anonymous_policy.bats
.PHONY : test -annotations
test-annotations : binary check -skopeo $( BATS ) $( STACKER ) $( NOTATION ) $( COSIGN )
$( BATS) --trace --print-output-on-failure test/blackbox/annotations.bats
.PHONY : test -detect -manifest -collision
test-detect-manifest-collision : binary check -skopeo $( BATS )
$( BATS) --trace --print-output-on-failure test/blackbox/detect_manifest_collision.bats
2022-07-27 12:37:55 -05:00
.PHONY : fuzz -all
fuzz-all : fuzztime =${1}
fuzz-all :
rm -rf test-data; \
rm -rf pkg/storage/testdata; \
git clone https://github.com/project-zot/test-data.git; \
mv test-data/storage pkg/storage/testdata; \
rm -rf test-data; \
bash test/scripts/fuzzAll.sh ${ fuzztime } ; \
rm -rf pkg/storage/testdata; \
2022-07-14 10:13:46 -05:00
2022-10-18 22:47:41 -05:00
$(STACKER) :
mkdir -p $( TOOLSDIR) /bin; \
curl -fsSL https://github.com/project-stacker/stacker/releases/latest/download/stacker -o $@ ; \
chmod +x $@
2022-11-01 11:16:14 -05:00
$(COSIGN) :
mkdir -p $( TOOLSDIR) /bin
curl -fsSL https://github.com/sigstore/cosign/releases/download/v1.13.0/cosign-linux-amd64 -o $@ ; \
chmod +x $@
2023-02-10 17:52:54 -05:00
2023-02-13 15:55:05 -05:00
# set ZUI_VERSION to empty string in order to clone zui locally and build default branch
2023-02-10 17:52:54 -05:00
.PHONY : ui
ui :
2023-02-13 15:55:05 -05:00
if [ -z $( ZUI_VERSION) ] ; then \
pwd = $$ ( pwd ) ; \
tdir = $$ ( mktemp -d) ; \
cd $$ tdir; \
2023-02-10 17:52:54 -05:00
git clone https://github.com/project-zot/zui.git; \
2023-02-13 15:55:05 -05:00
cd zui; \
npm install; \
npm run build; \
cd $$ pwd; \
rm -rf ./pkg/extensions/build; \
cp -R $$ tdir/zui/build ./pkg/extensions/; \
2023-02-10 17:52:54 -05:00
else \
2023-03-30 05:15:48 -05:00
curl --fail --head https://github.com/project-zot/zui/releases/download/$( ZUI_VERSION) /zui.tgz; \
if [ $$ ? -ne 0 ] ; then \
pwd = $$ ( pwd ) ; \
tdir = $$ ( mktemp -d) ; \
cd $$ tdir; \
git clone --depth= 1 --branch $( ZUI_VERSION) https://github.com/project-zot/zui.git; \
cd zui; \
git checkout $( ZUI_VERSION) ; \
npm install; \
npm run build; \
cd $$ pwd; \
rm -rf ./pkg/extensions/build; \
cp -R $$ tdir/zui/build ./pkg/extensions/; \
else \
curl -fsSL https://github.com/project-zot/zui/releases/download/$( ZUI_VERSION) /zui.tgz -o zui.tgz; \
tar xvzf zui.tgz -C ./pkg/extensions/; \
rm zui.tgz; \
fi ; \
2023-02-10 17:52:54 -05:00
fi ; \
2023-02-13 15:55:05 -05:00