Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman 2022-02-01 09:03:31 -05:00
Родитель 37c573f550
Коммит 9f93e9917f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 5CB45AE22BAB7EA7
5 изменённых файлов: 70 добавлений и 8 удалений

Просмотреть файл

@ -99,6 +99,27 @@ unit: ## Run unit tests
$(call title,Running unit tests)
go test $(shell go list ./... | grep -v anchore/$(REPO)/test)
# note: this is used by CI to determine if the install test fixture cache (docker image tars) should be busted
install-fingerprint:
cd test/install && \
make cache.fingerprint
install-test: $(SNAPSHOT_DIR)
cd test/install && \
make
install-test-cache-save: $(SNAPSHOT_DIR)
cd test/install && \
make save
install-test-cache-load: $(SNAPSHOT_DIR)
cd test/install && \
make load
install-test-ci-mac: $(SNAPSHOT_DIR)
cd test/install && \
make ci-test-mac
$(SNAPSHOT_DIR): $(TEMP_DIR) ## Build snapshot release binaries and packages
$(call title,Building snapshot artifacts)
# create a config with the dist dir overridden
@ -114,7 +135,6 @@ release: clean-dist ## Build and publish final binaries and packages
.PHONY: clean
clean: clean-dist clean-snapshot clean-changelog ## Remove previous builds, result reports, and caches
rm -rf $(RESULT_DIR)/*
.PHONY: clean-snapshot
clean-snapshot:

Просмотреть файл

@ -715,7 +715,7 @@ main() (
log_info "using release tag='${tag}' version='${version}' os='${os}' arch='${arch}'"
log_debug "downloading files into ${download_dir}"
download_and_install_asset "${download_url}" "${download_dir}" "${install_dir}" "${BINARY}" "${os}" "${arch}" "${version}" "${format}" "${binary}"
download_and_install_asset "${download_url}" "${download_dir}" "${install_dir}" "${PROJECT_NAME}" "${os}" "${arch}" "${version}" "${format}" "${binary}"
# don't continue if we couldn't install the asset
if [ "$?" != "0" ]; then

Просмотреть файл

@ -6,13 +6,15 @@ ALPINE_IMAGE=$(IMAGE_NAME):alpine-3.6
BUSYBOX_IMAGE=busybox:1.35
ENVS=./environments
DOCKER_RUN=docker run --rm -t -w /project/test/install -v $(shell pwd)/../../:/project
DOCKER_RUN=docker run --rm -t -w /project/test/install -v /var/run/docker.sock:/var/run/docker.sock -v $(shell pwd)/../../:/project
UNIT=make unit-local
# acceptance testing is running the current install.sh against the latest release. Note: this could be a problem down
# the line if there are breaking changes made that don't align with the latest release (but will be OK with the next
# release)
acceptance=sh -c 'curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin && ../../install.sh && docker sbom version'
CURL_INSTALL_SYFT=curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
WGET_INSTALL_SYFT=wget -O - https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
ACCEPTANCE_CMD=../../install.sh && docker sbom version
# CI cache busting values; change these if you want CI to not use previous stored cache
INSTALL_TEST_CACHE_BUSTER=894d8ca
@ -55,7 +57,7 @@ load:
acceptance-ubuntu-20.04: ubuntu-20.04
$(call title,ubuntu:20.04 - acceptance)
$(DOCKER_RUN) $(UBUNTU_IMAGE) \
$(acceptance)
sh -c '$(CURL_INSTALL_SYFT) && $(ACCEPTANCE_CMD)'
unit-ubuntu-20.04: ubuntu-20.04
$(call title,ubuntu:20.04 - unit)
@ -73,7 +75,7 @@ ubuntu-20.04:
acceptance-alpine-3.6: alpine-3.6
$(call title,alpine:3.6 - acceptance)
$(DOCKER_RUN) $(ALPINE_IMAGE) \
$(acceptance)
sh -c '$(WGET_INSTALL_SYFT) && $(ACCEPTANCE_CMD)'
alpine-3.6:
$(call title,alpine:3.6 - build environment)
@ -88,7 +90,7 @@ alpine-3.6:
acceptance-busybox-1.35: busybox-1.35
$(call title,busybox-1.35 - acceptance)
$(DOCKER_RUN) $(BUSYBOX_IMAGE) \
$(acceptance)
sh -c '$(WGET_INSTALL_SYFT) && $(ACCEPTANCE_CMD)'
busybox-1.35:
$(call title,busybox-1.35 - build environment)

Просмотреть файл

@ -0,0 +1,40 @@
. test_harness.sh
test_download_release_asset() {
release="$1"
os="$2"
arch="$3"
format="$4"
expected_mime_type="$5"
# for troubleshooting
# log_set_priority 10
name=${PROJECT_NAME}
version=$(tag_to_version ${release})
github_download="https://github.com/${OWNER}/${REPO}/releases/download/${release}"
tmpdir=$(mktemp -d)
actual_filepath=$(download_asset "${github_download}" "${tmpdir}" "${name}" "${os}" "${arch}" "${version}" "${format}" )
assertFileExists "${actual_filepath}" "download_asset os=${os} arch=${arch} format=${format}"
actual_mime_type=$(file -b --mime-type ${actual_filepath})
assertEquals "${expected_mime_type}" "${actual_mime_type}" "unexpected mimetype for os=${os} arch=${arch} format=${format}"
rm -rf -- "$tmpdir"
}
# always test against the latest release
release=$(get_release_tag "${OWNER}" "${REPO}" "latest" )
# exercise all possible assets against a real github release (based on asset listing from https://github.com/anchore/docker-sbom-cli-plugin/releases/tag/v0.1.0)
run_test_case test_download_release_asset "${release}" "darwin" "amd64" "tar.gz" "application/gzip"
run_test_case test_download_release_asset "${release}" "darwin" "arm64" "tar.gz" "application/gzip"
run_test_case test_download_release_asset "${release}" "linux" "amd64" "tar.gz" "application/gzip"
run_test_case test_download_release_asset "${release}" "linux" "arm64" "tar.gz" "application/gzip"
run_test_case test_download_release_asset "${release}" "windows" "amd64" "zip" "application/zip"
run_test_case test_download_release_asset "${release}" "windows" "arm64" "zip" "application/zip"

Просмотреть файл

@ -1,3 +1,3 @@
FROM alpine:3.6
FROM alpine:3.15
RUN apk update && apk add python3 wget unzip make ca-certificates docker-cli
RUN mkdir ~/.docker