-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
5326bec
commit 24b21dc
Showing
8 changed files
with
296 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,129 +1,57 @@ | ||
# This contains common build steps | ||
|
||
steps: | ||
- script: | | ||
mkdir -p '$(GOBIN)' | ||
mkdir -p '$(GOPATH)/pkg' | ||
mkdir -p '$(modulePath)' | ||
shopt -s extglob | ||
shopt -s dotglob | ||
mv !(gopath) '$(modulePath)' | ||
echo '##vso[task.prependpath]$(GOBIN)' | ||
echo '##vso[task.prependpath]$(GOROOT)/bin' | ||
displayName: 'Set up the Go workspace' | ||
|
||
- script: | | ||
go get -u golang.org/x/lint/golint | ||
golint $(go list ./... | grep -v /vendor/) | tee /tmp/lint.out | ||
if [ -s /tmp/lint.out ]; then | ||
echo -e "\e[101;97m golint FAILED \e[0m"`` | ||
exit 1 | ||
else | ||
echo -e "\e[42;97m golint SUCCEEDED \e[0m" | ||
fi | ||
workingDirectory: '$(modulePath)' | ||
displayName: 'Go lint' | ||
|
||
- script: | | ||
if go vet ./...; then | ||
echo -e "\e[42;97m govet SUCCEEDED \e[0m" | ||
else | ||
echo -e "\e[101;97m govet FAILED \e[0m"`` | ||
exit 1 | ||
fi | ||
if go vet -tags=unittest ./...; then | ||
echo -e "\e[42;97m govet SUCCEEDED \e[0m" | ||
else | ||
echo -e "\e[101;97m govet FAILED \e[0m"`` | ||
exit 1 | ||
fi | ||
cd ./scripts/e2e | ||
if go vet -tags=e2e ./...; then | ||
echo -e "\e[42;97m govet SUCCEEDED \e[0m" | ||
else | ||
echo -e "\e[101;97m govet FAILED \e[0m"`` | ||
exit 1 | ||
fi | ||
cd ../.. | ||
workingDirectory: '$(modulePath)' | ||
displayName: 'Go vet' | ||
|
||
- script: | | ||
set -u | ||
go version | ||
echo -e "\e[44;97m Compiling ... \e[0m" | ||
# set version | ||
ORG_PATH="github.com/Azure" | ||
PROJECT_NAME="application-gateway-kubernetes-ingress" | ||
REPO_PATH="${ORG_PATH}/${PROJECT_NAME}" | ||
VERSION_VAR="${REPO_PATH}/pkg/version.Version" | ||
VERSION=$(git describe --abbrev=0 --tags) | ||
DATE_VAR="${REPO_PATH}/pkg/version.BuildDate" | ||
BUILD_DATE=$(date +%Y-%m-%d-%H:%MT%z) | ||
COMMIT_VAR="${REPO_PATH}/pkg/version.GitCommit" | ||
GIT_HASH=$(git rev-parse --short HEAD) | ||
echo "VERSION $VERSION_VAR:$VERSION, BUILD_DATE $DATE_VAR:$BUILD_DATE, GIT_HASH $COMMIT_VAR:$GIT_HASH" | ||
if go install -ldflags "-s -X ${VERSION_VAR}=${VERSION} -X ${DATE_VAR}=${BUILD_DATE} -X ${COMMIT_VAR}=${GIT_HASH}" -v ./cmd/appgw-ingress; then | ||
chmod -R 777 $(GOBIN) | ||
$(GOBIN)/appgw-ingress --version | ||
echo -e "\e[42;97m Build SUCCEEDED \e[0m" | ||
else | ||
echo -e "\e[101;97m Build FAILED \e[0m" | ||
exit 1 | ||
fi | ||
workingDirectory: '$(modulePath)' | ||
displayName: 'Get dependencies and build' | ||
|
||
- script: | | ||
go get github.com/jstemmer/go-junit-report | ||
go get github.com/axw/gocov/gocov | ||
go get github.com/AlekSi/gocov-xml | ||
go get github.com/matm/gocov-html | ||
go test -timeout 80s -v -coverprofile=coverage.txt -covermode count -tags unittest ./... > testoutput.txt || { echo "go test returned non-zero"; cat testoutput.txt; exit 1; } | ||
cat testoutput.txt | go-junit-report > report.xml | ||
gocov convert coverage.txt > coverage.json | ||
gocov-xml < coverage.json > coverage.xml | ||
mkdir coverage | ||
gocov-html < coverage.json > coverage/index.html | ||
workingDirectory: '$(modulePath)' | ||
displayName: 'Run unit tests with code coverage' | ||
|
||
- script: | | ||
helm lint ./helm/ingress-azure | ||
workingDirectory: '$(modulePath)' | ||
displayName: 'Helm lint' | ||
|
||
- task: PublishTestResults@2 | ||
continueOnError: true | ||
condition: succeededOrFailed() | ||
inputs: | ||
failTaskOnFailedTests: true | ||
testRunner: JUnit | ||
testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml | ||
|
||
|
||
- task: PublishCodeCoverageResults@1 | ||
continueOnError: true | ||
condition: succeededOrFailed() | ||
inputs: | ||
codeCoverageTool: Cobertura | ||
summaryFileLocation: $(modulePath)/coverage.xml | ||
reportDirectory: $(modulePath)/coverage | ||
|
||
- task: CopyFiles@2 | ||
inputs: | ||
contents: | | ||
$(GOBIN)/appgw-ingress | ||
$(modulePath)/dockerfiles/deploy.Dockerfile | ||
$(modulePath)/scripts/** | ||
$(modulePath)/helm/** | ||
targetFolder: $(Build.ArtifactStagingDirectory) | ||
|
||
- task: PublishBuildArtifacts@1 | ||
inputs: | ||
pathtoPublish: $(Build.ArtifactStagingDirectory) | ||
artifactName: drop | ||
- script: | | ||
mkdir -p '$(GOBIN)' | ||
mkdir -p '$(GOPATH)/pkg' | ||
mkdir -p '$(modulePath)' | ||
shopt -s extglob | ||
shopt -s dotglob | ||
mv !(gopath) '$(modulePath)' | ||
echo '##vso[task.prependpath]$(GOBIN)' | ||
echo '##vso[task.prependpath]$(GOROOT)/bin' | ||
displayName: "Set up the Go workspace" | ||
- script: make lint-all | ||
workingDirectory: "$(modulePath)" | ||
displayName: "Go and Helm lint check" | ||
|
||
- script: make vet-all | ||
workingDirectory: "$(modulePath)" | ||
displayName: "Go vet" | ||
|
||
- script: make build | ||
workingDirectory: "$(modulePath)" | ||
displayName: "Get dependencies and build" | ||
|
||
- script: make unittest | ||
workingDirectory: "$(modulePath)" | ||
displayName: "Run unit tests with code coverage" | ||
|
||
- task: PublishTestResults@2 | ||
continueOnError: true | ||
condition: succeededOrFailed() | ||
inputs: | ||
failTaskOnFailedTests: true | ||
testRunner: JUnit | ||
testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml | ||
|
||
- task: PublishCodeCoverageResults@1 | ||
continueOnError: true | ||
condition: succeededOrFailed() | ||
inputs: | ||
codeCoverageTool: Cobertura | ||
summaryFileLocation: $(modulePath)/coverage.xml | ||
reportDirectory: $(modulePath)/coverage | ||
|
||
- task: CopyFiles@2 | ||
inputs: | ||
contents: | | ||
$(modulePath)/scripts/** | ||
$(modulePath)/helm/** | ||
targetFolder: $(Build.ArtifactStagingDirectory) | ||
|
||
- task: PublishBuildArtifacts@1 | ||
inputs: | ||
pathtoPublish: $(Build.ArtifactStagingDirectory) | ||
artifactName: drop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
ARG BUILDPLATFORM=linux/amd64 | ||
ARG BUILD_BASE_IMAGE | ||
|
||
FROM --platform=$BUILDPLATFORM $BUILD_BASE_IMAGE AS build | ||
WORKDIR /azure | ||
|
||
COPY go.mod go.sum /azure/ | ||
RUN go mod download | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y ca-certificates openssl | ||
|
||
ARG TARGETOS | ||
ARG TARGETARCH | ||
ARG BUILD_TAG | ||
ARG BUILD_DATE | ||
ARG GIT_HASH | ||
|
||
COPY cmd cmd | ||
COPY pkg pkg | ||
COPY Makefile Makefile | ||
|
||
RUN make build \ | ||
GOOS=${TARGETOS} \ | ||
GOARCH=${TARGETARCH} \ | ||
BUILD_TAG=${BUILD_TAG} \ | ||
BUILD_DATE=${BUILD_DATE} \ | ||
GIT_HASH=${GIT_HASH} | ||
|
||
#RUN ldd ./bin/appgw-ingress 2>&1 | grep 'not a dynamic executable' | ||
|
||
FROM ubuntu:20.04 AS final | ||
COPY --from=build /azure/bin/appgw-ingress /appgw-ingress | ||
RUN apt-get update | ||
RUN apt-get install -y ca-certificates openssl | ||
RUN useradd appgw-ingress-user | ||
RUN chown appgw-ingress-user /appgw-ingress | ||
USER appgw-ingress-user | ||
RUN chmod +x /appgw-ingress | ||
CMD ["/appgw-ingress"] |
Oops, something went wrong.