| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
set -eux |
| 4 |
|
| 5 |
set -o pipefail |
| 6 |
|
| 7 |
if ! groups | grep -q docker; then |
| 8 |
echo "User $(whoami) is not in 'docker' group. Fixing permissions..." |
| 9 |
# make docker work as user |
| 10 |
sudo adduser $(whoami) docker |
| 11 |
exec newgrp -c "$0" docker |
| 12 |
fi |
| 13 |
|
| 14 |
dh_auto_configure -O--buildsystem=golang -O--builddirectory=_build |
| 15 |
|
| 16 |
|
| 17 |
# avoid accessing internet but use debian sources for gomodules |
| 18 |
export GO111MODULE=off |
| 19 |
export GOPATH="${PWD}/_build:/usr/share/gocode:${PWD}/test/e2e/plugin:${PWD}/test/e2e" |
| 20 |
export GOCACHE="${PWD}/_build/go-build" |
| 21 |
export GOPROXY="off" |
| 22 |
export BUILDTAGS="" |
| 23 |
|
| 24 |
|
| 25 |
# github.com/notaryproject/notation/test/e2e |
| 26 |
|
| 27 |
# NB: taken from tests/e2e/run.sh |
| 28 |
|
| 29 |
# these are being picked up by the e2e test suite |
| 30 |
# setting to the same value defeats backward-compatibility testing |
| 31 |
export NOTATION_E2E_BINARY_PATH=/usr/bin/notation |
| 32 |
export NOTATION_E2E_OLD_BINARY_PATH=$NOTATION_E2E_BINARY_PATH |
| 33 |
|
| 34 |
|
| 35 |
# build e2e plugin and tar.gz |
| 36 |
PLUGIN_NAME=notation-e2e-plugin |
| 37 |
#( cd ${PWD}/plugin && go build -o ./bin/$PLUGIN_NAME . && echo "e2e plugin built." && tar -czvf ./bin/$PLUGIN_NAME.tar.gz -C ./bin/ $PLUGIN_NAME ) |
| 38 |
|
| 39 |
DH_GOPKG=github.com/notaryproject/notation/test/e2e/plugin \ |
| 40 |
dh_auto_build -O--buildsystem=golang -O--builddirectory=_build |
| 41 |
|
| 42 |
|
| 43 |
mkdir -p _build/${PLUGIN_NAME}/bin |
| 44 |
mv -v _build/bin/plugin _build/bin/${PLUGIN_NAME} |
| 45 |
tar -czvf _build/${PLUGIN_NAME}.tar.gz -C _build/bin/ $PLUGIN_NAME |
| 46 |
|
| 47 |
# setup registry |
| 48 |
cd test/e2e |
| 49 |
set +u |
| 50 |
source ./scripts/zot.sh |
| 51 |
|
| 52 |
setup_registry |
| 53 |
|
| 54 |
# defer cleanup registry |
| 55 |
function cleanup { |
| 56 |
set +u |
| 57 |
cleanup_registry |
| 58 |
} |
| 59 |
trap cleanup EXIT |
| 60 |
|
| 61 |
cd $OLDPWD |
| 62 |
|
| 63 |
set -u |
| 64 |
# set environment variable for E2E testing |
| 65 |
export NOTATION_E2E_CONFIG_PATH=${PWD}/test/e2e/testdata/config |
| 66 |
export NOTATION_E2E_OCI_LAYOUT_PATH=${PWD}/test/e2e/testdata/registry/oci_layout |
| 67 |
export NOTATION_E2E_TEST_REPO=e2e |
| 68 |
export NOTATION_E2E_TEST_TAG=v1 |
| 69 |
export NOTATION_E2E_PLUGIN_PATH=${PWD}/_build/bin/${PLUGIN_NAME} |
| 70 |
export NOTATION_E2E_PLUGIN_TAR_GZ_PATH=${PWD}/_build/${PLUGIN_NAME}.tar.gz |
| 71 |
export NOTATION_E2E_MALICIOUS_PLUGIN_ARCHIVE_PATH=${PWD}/test/e2e/testdata/malicious-plugin |
| 72 |
|
| 73 |
DH_GOPKG=github.com/notaryproject/notation/test/e2e \ |
| 74 |
dh_auto_build -O--buildsystem=golang -O--builddirectory=_build |
| 75 |
|
| 76 |
# run tests |
| 77 |
DH_GOPKG=github.com/notaryproject/notation/test/e2e \ |
| 78 |
dh_auto_test -O--buildsystem=golang -O--builddirectory=_build --no-parallel |