nginx-proxy-manager/scripts/ci/test-backend
Jamie Curnow 5e5f0de0e2 - Added upstream objects
- Renamed host templates to nginx templates
- Generate upstream templates
- Better nginx error reporting when reloading
- Use tparse for golang test reporting
2023-01-04 15:53:52 +10:00

70 lines
1.9 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
IMAGE=jc21/gotools:latest
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$DIR/../.common.sh"
BUILD_DATE=$(date '+%Y-%m-%d %T %Z')
NOW=$(date --rfc-3339=s)
cd $DIR/../..
if [ "$BUILD_COMMIT" = "" ]; then
BUILD_COMMIT=$(git log -n 1 --format=%h)
fi
if [ "$BUILD_VERSION" = "" ]; then
BUILD_VERSION=$(cat .version)
fi
echo -e "${BLUE} ${GREEN}test-backend: ${YELLOW}${1:-}${RESET}"
echo " BUILD_COMMIT: ${BUILD_COMMIT:-notset}"
echo " BUILD_DATE: $BUILD_DATE"
echo " BUILD_VERSION: $BUILD_VERSION"
echo " CGO_ENABLED: ${CGO_ENABLED:-not set}"
echo " GO111MODULE: ${GO111MODULE:-}"
echo " GOPRIVATE: ${GOPRIVATE:-}"
echo " GOPROXY: ${GOPROXY:-}"
echo " NOW: $NOW"
if [ "${1:-}" = "--inside-docker" ]; then
mkdir -p /workspace
echo -e "${BLUE} ${CYAN}Nancy setup${RESET}"
cd /workspace
# go get github.com/sonatype-nexus-community/nancy
cp /app/backend/go.mod /app/backend/go.sum /app/backend/.nancy-ignore .
go mod download
echo -e "${BLUE} ${CYAN}Nancy testing${RESET}"
go list -json -m all | nancy sleuth --quiet --username "${NANCY_USER}" --token "${NANCY_TOKEN:-}"
rm -rf /workspace
echo -e "${BLUE} ${CYAN}Testing backend code${RESET}"
cd /app/backend
[ -z "$(go tool fix -diff ./internal)" ]
go test -json -cover ./internal/... | tparse
golangci-lint -v run ./...
else
# run this script from within docker
docker pull "${IMAGE}"
docker run --rm \
-e BUILD_COMMIT="${BUILD_COMMIT:-notset}" \
-e BUILD_DATE="$BUILD_DATE" \
-e BUILD_VERSION="$BUILD_VERSION" \
-e GOARCH="${2}" \
-e GOOS="${1}" \
-e GOPRIVATE="${GOPRIVATE:-}" \
-e GOPROXY="${GOPROXY:-}" \
-e NOW="$NOW" \
-e SENTRY_DSN="${SENTRY_DSN:-}" \
-e TZ="${TZ:-Australia/Brisbane}" \
-v "$(pwd):/app" \
-w '/app/backend' \
"${IMAGE}" \
/app/scripts/ci/test-backend --inside-docker
fi
echo -e "${BLUE} ${GREEN}test-backend ${YELLOW}${1:-} ${GREEN}completed${RESET}"
exit 0