mirror of
https://github.com/anchore/syft
synced 2024-11-10 14:24:12 +00:00
f38b0b7256
* [wip] get assets based on gh api Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * put install.sh download_asset fn under test Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * put install.sh install_asset fn under test Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * use zip for darwin installs Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix install.sh negative test cases Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * allow errors to propagate in install.sh Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove exit on error from install.sh tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add more docs around install.sh helpers Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add integration tests for install.sh Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add install.sh testing to pipeline Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add install test cache to CI Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * make colors globally available Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * test download against github release Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * always test release-based install against latest release Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * use better install.sh test names Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
54 lines
1.4 KiB
Bash
Executable file
54 lines
1.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -eux
|
|
set -o pipefail
|
|
|
|
DISTDIR=$1
|
|
ACC_DIR=$2
|
|
TEST_IMAGE=$3
|
|
RESULTSDIR=$4
|
|
|
|
TEST_IMAGE_TAR=image.tar
|
|
TEST_TYPE=mac
|
|
WORK_DIR=`mktemp -d -t "syft-acceptance-test-${TEST_TYPE}-XXXXXX"`
|
|
NORMAL_TEST_IMAGE=$(echo ${TEST_IMAGE} | tr ':' '-' )
|
|
REPORT=${WORK_DIR}/acceptance-${TEST_TYPE}-${NORMAL_TEST_IMAGE}.json
|
|
GOLDEN_REPORT=${ACC_DIR}/test-fixtures/acceptance-${NORMAL_TEST_IMAGE}.json
|
|
|
|
# check if tmp dir was created
|
|
if [[ ! "${WORK_DIR}" || ! -d "${WORK_DIR}" ]]; then
|
|
echo "Could not create temp dir"
|
|
exit 1
|
|
fi
|
|
|
|
function cleanup {
|
|
# we should still preserve previous failures
|
|
exit_code=$?
|
|
rm -rf "${WORK_DIR}"
|
|
exit ${exit_code}
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
# fetch test image
|
|
if [[ -f ${TEST_IMAGE_TAR} ]]
|
|
then
|
|
echo "using existing image"
|
|
else
|
|
skopeo --version || brew install skopeo
|
|
skopeo --override-os linux copy "docker://docker.io/${TEST_IMAGE}" "docker-archive:${TEST_IMAGE_TAR}"
|
|
fi
|
|
|
|
# run syft
|
|
SYFT_PATH="${DISTDIR}/syft-macos_darwin_amd64/syft"
|
|
chmod 755 "${SYFT_PATH}"
|
|
"${SYFT_PATH}" version
|
|
SYFT_CHECK_FOR_APP_UPDATE=0 "${SYFT_PATH}" packages docker-archive:${TEST_IMAGE_TAR} -vv -o json > "${REPORT}"
|
|
|
|
# keep the generated report around
|
|
mkdir -p ${RESULTSDIR}
|
|
cp ${REPORT} ${RESULTSDIR}
|
|
|
|
# compare the results to a known good output
|
|
${ACC_DIR}/compare.py \
|
|
${GOLDEN_REPORT} \
|
|
${REPORT} | tee ${RESULTSDIR}/acceptance-${TEST_TYPE}.txt
|