Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .codecov/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
codecov:
notify:
require_ci_to_pass: no
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ ipam-*.xml

# Environment
.vscode/*

# Coverage
*.out
102 changes: 102 additions & 0 deletions .pipelines/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
pr:
- master

trigger:
branches:
include:
- master

jobs:
- job: Test
pool:
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
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
go env
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
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'

- script: |
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)
gocov convert coverage.out > coverage.json
gocov-xml < coverage.json > coverage.xml
workingDirectory: '$(modulePath)'
displayName: 'RunTest'

- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml
condition: always()

- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.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'))
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
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