From 78b390f9991b83c597f341a71e2ecbf1f4e13def Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Tue, 12 Mar 2019 10:40:13 -0700 Subject: [PATCH 1/4] initial azure-pipeline config --- .codecov/codecov.yml | 3 ++ .gitignore | 3 ++ .pipelines/pipeline.yml | 90 +++++++++++++++++++++++++++++++++++++++++ Makefile | 18 ++++++++- 4 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 .codecov/codecov.yml create mode 100644 .pipelines/pipeline.yml diff --git a/.codecov/codecov.yml b/.codecov/codecov.yml new file mode 100644 index 0000000000..e2a23c23d8 --- /dev/null +++ b/.codecov/codecov.yml @@ -0,0 +1,3 @@ +codecov: + notify: + require_ci_to_pass: no diff --git a/.gitignore b/.gitignore index 331501803f..c9274d2f13 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ ipam-*.xml # Environment .vscode/* + +# Coverage +*.out \ No newline at end of file diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml new file mode 100644 index 0000000000..0ba7f64175 --- /dev/null +++ b/.pipelines/pipeline.yml @@ -0,0 +1,90 @@ +pr: +- master + +trigger: + branches: + include: + - master + +jobs: +- job: Test + pool: + vmImage: 'Ubuntu-16.04' + + variables: + GOBIN: '$(GOPATH)/bin' # Go binaries path + GOROOT: '/usr/local/go1.11' # Go installation path + GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path + modulePath: '$(GOPATH)/src/github.com/Azure/azure-container-networking' # $(build.repository.name)' # Path to the module's code + + steps: + - script: | + echo $UID + sudo apt-get update + sudo apt-get install -y ebtables ipset python3-dev gcc zip + sudo pip install coverage + displayName: 'Install OS dependencies' + + - script: | + go version + 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 -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + go get github.com/docker/libnetwork/driverapi + go get github.com/gorilla/mux + go get github.com/jstemmer/go-junit-report + workingDirectory: '$(modulePath)' + displayName: 'Install Go dependencies' + + - script: | + # sudo -E env "PATH=$PATH" go test -v ./cns/restserver/ -coverprofile coverage-restserver.out + set -o pipefail + set -e + sudo -E env "PATH=$PATH" make test-all 2>&1 | tee >(go-junit-report > report.xml) + bash <(curl -s https://codecov.io/bash) + workingDirectory: '$(modulePath)' + displayName: 'RunTest' + + - task: PublishTestResults@2 + inputs: + testRunner: JUnit + testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml + condition: always() + + - script: | + export GOOS=linux + sudo -E env "PATH=$PATH" make all-binaries + export GOOS=windows + sudo -E env "PATH=$PATH" make all-binaries + cd output + sudo find . -mindepth 2 -type f -print -exec mv {} . \; + sudo rm -R -- */ + sudo find . -type f -regextype posix-extended ! -iregex '.*\.(zip|tgz)$' -delete + workingDirectory: '$(modulePath)' + displayName: 'Build' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) + + - task: CopyFiles@2 + inputs: + sourceFolder: '$(modulePath)/output' + targetFolder: $(Build.ArtifactStagingDirectory) + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) + + - task: PublishBuildArtifacts@1 + inputs: + artifactName: 'output' + pathtoPublish: '$(Build.ArtifactStagingDirectory)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) diff --git a/Makefile b/Makefile index 0e1e284670..fb6fb3d616 100644 --- a/Makefile +++ b/Makefile @@ -275,4 +275,20 @@ ifeq ($(GOOS),linux) chmod 0755 $(NPM_BUILD_DIR)/azure-npm$(EXE_EXT) cd $(NPM_BUILD_DIR) && $(ARCHIVE_CMD) $(NPM_ARCHIVE_NAME) azure-npm$(EXE_EXT) chown $(BUILD_USER):$(BUILD_USER) $(NPM_BUILD_DIR)/$(NPM_ARCHIVE_NAME) -endif \ No newline at end of file +endif + +# run all tests +.PHONY: test-all +test-all: + go test -v -covermode count -coverprofile=coverage.out \ + ./ipam/ \ + ./log/ \ + ./netlink/ \ + ./store/ \ + ./telemetry/ \ + ./cnm/network/ \ + ./cni/ipam/ \ + ./cns/ipamclient/ \ + ./npm/iptm/ \ + ./npm/ipsm/ \ + ./npm \ No newline at end of file From fd5241fb3e76f964f02e89240b103b827768fcb0 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Fri, 15 Mar 2019 10:02:26 -0700 Subject: [PATCH 2/4] remove cns restserver from ci --- .pipelines/pipeline.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index 0ba7f64175..949192a4fe 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -50,7 +50,6 @@ jobs: displayName: 'Install Go dependencies' - script: | - # sudo -E env "PATH=$PATH" go test -v ./cns/restserver/ -coverprofile coverage-restserver.out set -o pipefail set -e sudo -E env "PATH=$PATH" make test-all 2>&1 | tee >(go-junit-report > report.xml) From d21d189d44d526cd6de7773dd8d2c64e3d01d22f Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Fri, 15 Mar 2019 14:36:30 -0700 Subject: [PATCH 3/4] publish coverage report to pipelines --- .pipelines/pipeline.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index 949192a4fe..d2c0c766b7 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -46,6 +46,9 @@ jobs: go get github.com/docker/libnetwork/driverapi go get github.com/gorilla/mux go get github.com/jstemmer/go-junit-report + go get github.com/axw/gocov/gocov + go get github.com/AlekSi/gocov-xml + go get -u gopkg.in/matm/v1/gocov-html workingDirectory: '$(modulePath)' displayName: 'Install Go dependencies' @@ -54,6 +57,10 @@ jobs: set -e sudo -E env "PATH=$PATH" make test-all 2>&1 | tee >(go-junit-report > report.xml) bash <(curl -s https://codecov.io/bash) + gocov convert coverage.out > coverage.json + gocov-xml < coverage.json > coverage.xml + mkdir coverage + gocov-html < coverage.json > coverage/index.html workingDirectory: '$(modulePath)' displayName: 'RunTest' @@ -63,6 +70,13 @@ jobs: testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml condition: always() + - task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml + reportDirectory: $(System.DefaultWorkingDirectory)/**/coverage + condition: always() + - script: | export GOOS=linux sudo -E env "PATH=$PATH" make all-binaries From cd133459d8771eb001ae7594d49cda0ecdd7b520 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Fri, 3 May 2019 16:42:00 -0700 Subject: [PATCH 4/4] use default go version on runner --- .pipelines/pipeline.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index d2c0c766b7..2820f83d00 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -9,12 +9,13 @@ trigger: jobs: - job: Test pool: - vmImage: 'Ubuntu-16.04' + vmImage: 'Ubuntu-16.04' + # Go setup for the vmImage: + # https://github.com/Microsoft/azure-pipelines-image-generation/blob/master/images/linux/scripts/installers/go.sh variables: GOBIN: '$(GOPATH)/bin' # Go binaries path - GOROOT: '/usr/local/go1.11' # Go installation path - GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path + GOPATH: '$(System.DefaultWorkingDirectory)/gopath' # Go workspace path modulePath: '$(GOPATH)/src/github.com/Azure/azure-container-networking' # $(build.repository.name)' # Path to the module's code steps: @@ -27,6 +28,7 @@ jobs: - script: | go version + go env mkdir -p '$(GOBIN)' mkdir -p '$(GOPATH)/pkg' mkdir -p '$(modulePath)' @@ -59,8 +61,6 @@ jobs: bash <(curl -s https://codecov.io/bash) gocov convert coverage.out > coverage.json gocov-xml < coverage.json > coverage.xml - mkdir coverage - gocov-html < coverage.json > coverage/index.html workingDirectory: '$(modulePath)' displayName: 'RunTest' @@ -74,7 +74,6 @@ jobs: inputs: codeCoverageTool: Cobertura summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml - reportDirectory: $(System.DefaultWorkingDirectory)/**/coverage condition: always() - script: |