diff --git a/.travis.yml b/.travis.yml index 3c55dc88..9ced535a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,6 +44,7 @@ script: - export DELIVERABLE="n3dr-${TRAVIS_OS_NAME}" - if [ "$TRAVIS_OS_NAME" == "linux" ] && [ "$ARTIFACT_PUBLICATION" ]; then go test -short -cover -v -coverprofile=coverage.txt -covermode=atomic ./...; fi - if [ "$TRAVIS_OS_NAME" = "windows" ]; then choco install zip -y; fi + - ./build.sh - if [ $TRAVIS_OS_NAME == linux ]; then ./integration-tests.sh $NEXUS_VERSION $NEXUS_API_VERSION ./${DELIVERABLE}; fi - if [ "$TRAVIS_OS_NAME" == "linux" ] && [ "$ARTIFACT_PUBLICATION" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then sonar-scanner -Dsonar.projectKey=030_n3dr -Dsonar.sources=. -Dsonar.host.url=https://sonarcloud.io -Dsonar.coverage.exclusions=cmd/**,**/*_test.go -Dsonar.go.coverage.reportPaths="coverage.txt"; fi - if [ "$TRAVIS_OS_NAME" == "linux" ] && [ "$ARTIFACT_PUBLICATION" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then bash <(curl -s https://codecov.io/bash); fi diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..86c5df9f --- /dev/null +++ b/build.sh @@ -0,0 +1,9 @@ +#!/bin/bash -e +TRAVIS_TAG="${TRAVIS_TAG:-local}" +SHA512_CMD="${SHA512_CMD:-sha512sum}" +DELIVERABLE="${DELIVERABLE:-n3dr}" + +echo "TRAVIS_TAG: '$TRAVIS_TAG' DELIVERABLE: '$DELIVERABLE'" +go build -ldflags "-X n3dr/cmd.Version=${TRAVIS_TAG}" -o "${DELIVERABLE}" +$SHA512_CMD "${DELIVERABLE}" > "${DELIVERABLE}.sha512.txt" +chmod +x "${DELIVERABLE}" diff --git a/integration-tests.sh b/integration-tests.sh index b3199a6b..c94895de 100755 --- a/integration-tests.sh +++ b/integration-tests.sh @@ -3,9 +3,6 @@ NEXUS_VERSION="${1:-3.21.1}" NEXUS_API_VERSION="${2:-v1}" TOOL="${3:-./n3dr}" -TRAVIS_TAG="${TRAVIS_TAG:-local}" -SHA512_CMD="${SHA512_CMD:-sha512sum}" -DELIVERABLE="${DELIVERABLE:-n3dr}" validate(){ if [ -z "${TOOL}" ]; then @@ -21,10 +18,7 @@ should be run." } build(){ - echo "TRAVIS_TAG: '$TRAVIS_TAG' DELIVERABLE: '$DELIVERABLE'" - go build -ldflags "-X n3dr/cmd.Version=${TRAVIS_TAG}" -o "${DELIVERABLE}" - $SHA512_CMD "${TOOL}" > "${DELIVERABLE}.sha512.txt" - chmod +x "${DELIVERABLE}" + source ./build.sh } nexus(){