diff --git a/.artifactignore b/.artifactignore new file mode 100644 index 0000000000..5ccfaaba30 --- /dev/null +++ b/.artifactignore @@ -0,0 +1,2 @@ +**/* +!dist/*.whl diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000000..9850900d18 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,29 @@ +[run] +branch = True +source = + acl_loader + clear + config + connect + consutil + counterpoll + crm + debug + fdbutil + fwutil + pcieutil + pddf_fanutil + pddf_ledutil + pddf_psuutil + pddf_thermalutil + pfc + pfcwd + psuutil + scripts + sfputil + show + sonic_installer + ssdutil + undebug + utilities_common + watchdogutil diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ccfebe05f4..ff2a4bd8ab 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,11 +9,71 @@ trigger: pool: vmImage: ubuntu-20.04 +container: + image: sonicdev-microsoft.azurecr.io:443/sonic-slave-buster:latest + options: --privileged + steps: -- script: echo Hello, world! - displayName: 'Run a one-line script' +- task: DownloadPipelineArtifact@2 + inputs: + source: specific + project: build + pipeline: 1 + artifact: sonic-buildimage.kvm + runVersion: 'latestFromBranch' + runBranch: 'refs/heads/master' + displayName: "Download artifacts from latest sonic-buildimage build" + +- script: | + set -xe + sudo dpkg -i libnl-3-200_*.deb + sudo dpkg -i libnl-genl-3-200_*.deb + sudo dpkg -i libnl-route-3-200_*.deb + sudo dpkg -i libnl-nf-3-200_*.deb + sudo dpkg -i libhiredis0.14_*.deb + sudo dpkg -i libswsscommon_1.0.0_amd64.deb + sudo dpkg -i python3-swsscommon_1.0.0_amd64.deb + sudo dpkg -i libyang_1.0.73_amd64.deb + sudo dpkg -i libyang-cpp_1.0.73_amd64.deb + sudo dpkg -i python3-yang_1.0.73_amd64.deb + workingDirectory: $(Pipeline.Workspace)/target/debs/buster/ + displayName: 'Install Debian dependencies' + +- script: | + set -xe + sudo pip3 install swsssdk-2.0.1-py3-none-any.whl + sudo pip3 install sonic_py_common-1.0-py3-none-any.whl + sudo pip3 install sonic_config_engine-1.0-py3-none-any.whl + sudo pip3 install sonic_platform_common-1.0-py3-none-any.whl + sudo pip3 install sonic_yang_mgmt-1.0-py3-none-any.whl + sudo pip3 install sonic_yang_models-1.0-py3-none-any.whl + workingDirectory: $(Pipeline.Workspace)/target/python-wheels/ + displayName: 'Install Python dependencies' - script: | - echo Add other tasks to build, test, and deploy your project. - echo See https://aka.ms/yaml - displayName: 'Run a multi-line script' + python3 setup.py test + displayName: 'Test Python 3' + +- task: PublishTestResults@2 + inputs: + testResultsFiles: '$(System.DefaultWorkingDirectory)/test-results.xml' + testRunTitle: Python 3 + failTaskOnFailedTests: true + condition: succeededOrFailed() + displayName: 'Publish Python 3 test results' + +- task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml' + reportDirectory: '$(System.DefaultWorkingDirectory)/htmlcov/' + displayName: 'Publish Python 3 test coverage' + +- script: | + set -e + python3 setup.py bdist_wheel + displayName: 'Build Python 3 wheel' + +- publish: '$(System.DefaultWorkingDirectory)/dist/' + artifact: wheels + displayName: "Publish Python wheels" diff --git a/pytest.ini b/pytest.ini index 40d110e3b0..836f5437df 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,2 @@ [pytest] -filterwarnings = - ignore::DeprecationWarning -addopts = --cov=acl_loader --cov=clear --cov=config --cov=connect --cov=consutil --cov=counterpoll --cov=crm --cov=debug --cov=fdbutil --cov=fwutil --cov=pcieutil --cov=pfcwd --cov=psuutil --cov=pddf_fanutil --cov=pddf_ledutil --cov=pddf_psuutil --cov=pddf_thermalutil --cov=scripts --cov=sfputil --cov=show --cov=sonic_installer --cov=ssdutil --cov=utilities_common --cov=watchdogutil --cov-report html --cov-report term --cov-report xml +addopts = --cov-config=.coveragerc --cov --cov-report html --cov-report term --cov-report xml --junitxml=test-results.xml -v