Skip to content
Open
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
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -422,3 +422,14 @@ endif
rm $(DESTDIR)/usr/sbin/gnmi_dump


TARGET_BRANCH ?= origin/master
DIFF_COVER_THRESHOLD ?= 80

.PHONY: diff-cover
diff-cover: coverage.xml test-results/coverage-pure.xml
diff-cover coverage.xml test-results/coverage-pure.xml \
--compare-branch $(TARGET_BRANCH) \
--src-roots . \
--fail-under $(DIFF_COVER_THRESHOLD)


53 changes: 45 additions & 8 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ variables:
value: $(Build.SourceBranchName)
- name: UNIT_TEST_FLAG
value: 'ENABLE_TRANSLIB_WRITE=y'
- name: DIFF_COVER_THRESHOLD
value: 80

resources:
repositories:
Expand Down Expand Up @@ -87,13 +89,17 @@ stages:
publishRunAttachments: true
testRunTitle: 'Pure Package Tests'

- task: PublishCodeCoverageResults@1
- task: PublishCodeCoverageResults@2
displayName: 'Publish Pure Package Coverage'
condition: always()
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/sonic-gnmi/test-results/coverage-pure.xml'

- publish: $(System.DefaultWorkingDirectory)/sonic-gnmi/test-results/coverage-pure.xml
artifact: coverage-pure
displayName: 'Publish pure coverage artifact'
condition: always()

# Memory leak testing with address sanitizer
- job: MemoryLeakJob
displayName: "Memory Leak Tests"
Expand All @@ -104,9 +110,6 @@ stages:
vmImage: ubuntu-22.04

variables:
DIFF_COVER_CHECK_THRESHOLD: 80
DIFF_COVER_ENABLE: 'true'
DIFF_COVER_WORKING_DIRECTORY: $(System.DefaultWorkingDirectory)/sonic-gnmi
UNIT_TEST_FLAG: 'ENABLE_TRANSLIB_WRITE=y'

container:
Expand Down Expand Up @@ -134,7 +137,7 @@ stages:
buildBranch: $(BUILD_BRANCH)

# Memory leak tests with JUnit XML generation

- bash: |
set -euo pipefail
pushd sonic-gnmi
Expand Down Expand Up @@ -173,6 +176,7 @@ stages:
- checkout: self
clean: true
submodules: recursive
fetchDepth: 0
displayName: 'Checkout code'

- checkout: sonic-mgmt-common
Expand Down Expand Up @@ -240,8 +244,41 @@ stages:
artifact: sonic-gnmi
displayName: "Archive artifacts"

- task: PublishCodeCoverageResults@1
- task: PublishCodeCoverageResults@2
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/sonic-gnmi/coverage.xml'
displayName: 'Publish coverage'

- publish: $(System.DefaultWorkingDirectory)/sonic-gnmi/coverage.xml
artifact: coverage-integration
displayName: 'Publish integration coverage artifact'
condition: always()

- job: DiffCoverageCheck
displayName: "Diff Coverage Check"
dependsOn: [PureCIJob, build]
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
timeoutInMinutes: 10
pool:
vmImage: ubuntu-22.04
steps:
- checkout: self
clean: true
fetchDepth: 0

- download: current
artifact: coverage-pure

- download: current
artifact: coverage-integration

- bash: |
set -euo pipefail
pip3 install --quiet diff-cover
diff-cover \
$(Pipeline.Workspace)/coverage-integration/coverage.xml \
$(Pipeline.Workspace)/coverage-pure/coverage-pure.xml \
--compare-branch origin/$(BUILD_BRANCH) \
--src-roots . \
--fail-under $(DIFF_COVER_THRESHOLD)
displayName: 'Run diff-cover'