Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] Improve azure pipeline framework #2124

Draft
wants to merge 7 commits into
base: 202106
Choose a base branch
from
Draft
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
91 changes: 66 additions & 25 deletions .azure-pipelines/build-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ parameters:
- name: sonic_slave
type: string

- name: buildimage_artifact_name
type: string

- name: buildimage_pipeline
type: number

- name: sairedis_artifact_name
type: string

Expand All @@ -36,6 +42,10 @@ parameters:
type: boolean
default: false

- name: archive_gcov
type: boolean
default: false

jobs:
- job:
displayName: ${{ parameters.arch }}
Expand All @@ -51,34 +61,41 @@ jobs:
image: sonicdev-microsoft.azurecr.io:443/${{ parameters.sonic_slave }}:latest

steps:
- checkout: self
clean: true
submodules: true
- script: |
sourceBranch=$(Build.SourceBranchName)
if [[ "$(Build.Reason)" == "PullRequest" ]];then
sourceBranch=$(System.PullRequest.TargetBranch)
fi
echo "Download artifact branch: $sourceBranch"
echo "##vso[task.setvariable variable=sourceBranch]$sourceBranch"
displayName: "Get correct artifact downloading branch"
- script: |
sudo apt-get install -y libhiredis0.14 libhiredis-dev
sudo apt-get install -y libzmq5 libzmq3-dev
sudo apt-get install -qq -y \
libhiredis-dev \
libnl-3-dev \
libnl-genl-3-dev \
libnl-route-3-dev \
libnl-nf-3-dev \
swig3.0
sudo apt-get install -y libdbus-1-3
sudo apt-get install -y libteam-dev \
libteam5 \
libteamdctl0
displayName: "Install dependencies"
- script: |
ls -al $(Pipeline.Workspace)
rm -rf $(Pipeline.Workspace)/*.deb
ls -al $(Pipeline.Workspace)
displayName: "Clean workspace"
- task: DownloadPipelineArtifact@2
inputs:
source: specific
project: build
pipeline: 9
artifact: ${{ parameters.swss_common_artifact_name }}
runVersion: 'latestFromBranch'
runBranch: 'refs/heads/master'
runBranch: 'refs/heads/$(sourceBranch)'
path: '$(Build.SourcesDirectory)/${{ parameters.swss_common_artifact_name }}'
allowFailedBuilds: true
patterns: |
**/libswsscommon_1.0.0_${{ parameters.arch }}.deb
**/libswsscommon-dev_1.0.0_${{ parameters.arch }}.deb
displayName: "Download sonic swss common deb packages"
- task: DownloadPipelineArtifact@2
inputs:
Expand All @@ -87,26 +104,50 @@ jobs:
pipeline: 12
artifact: ${{ parameters.sairedis_artifact_name }}
runVersion: 'latestFromBranch'
runBranch: 'refs/heads/master'
runBranch: 'refs/heads/$(sourceBranch)'
path: '$(Build.SourcesDirectory)/${{ parameters.sairedis_artifact_name }}'
allowFailedBuilds: true
patterns: |
**/libsaivs_*.deb
**/libsaivs-dev_*.deb
**/libsairedis_*.deb
**/libsairedis-dev_*.deb
**/libsaimetadata_*.deb
**/libsaimetadata-dev_*.deb
**/syncd-vs_*.deb
displayName: "Download sonic sairedis deb packages"
- task: DownloadPipelineArtifact@2
inputs:
source: specific
project: build
pipeline: ${{ parameters.buildimage_pipeline }}
runVersion: 'latestFromBranch'
runBranch: 'refs/heads/$(sourceBranch)'
path: '$(Build.SourcesDirectory)/${{ parameters.buildimage_artifact_name }}'
allowFailedBuilds: true
patterns: |
**/target/debs/**/libnl-3-200_*.deb
**/target/debs/**/libnl-3-dev_*.deb
**/target/debs/**/libnl-genl-3-200_*.deb
**/target/debs/**/libnl-genl-3-dev_*.deb
**/target/debs/**/libnl-route-3-200_*.deb
**/target/debs/**/libnl-route-3-dev_*.deb
**/target/debs/**/libnl-nf-3-200_*.deb
**/target/debs/**/libnl-nf-3-dev_*.deb
displayName: "Download sonic buildimage deb packages"
- script: |
sudo dpkg -i libswsscommon_1.0.0_${{ parameters.arch }}.deb
sudo dpkg -i libswsscommon-dev_1.0.0_${{ parameters.arch }}.deb
sudo dpkg -i libsaivs_*.deb
sudo dpkg -i libsaivs-dev_*.deb
sudo dpkg -i libsairedis_*.deb
sudo dpkg -i libsairedis-dev_*.deb
sudo dpkg -i libsaimetadata_*.deb
sudo dpkg -i libsaimetadata-dev_*.deb
sudo dpkg -i syncd-vs_*.deb
workingDirectory: $(Pipeline.Workspace)
displayName: "Install sonic swss common and sairedis"
- checkout: self
submodules: true
set -ex
sudo dpkg -i $(find ${{ parameters.buildimage_artifact_name }} -name "*.deb")
sudo dpkg -i $(find ${{ parameters.swss_common_artifact_name }} -name "*.deb")
sudo dpkg -i $(find ${{ parameters.sairedis_artifact_name }} -name "*.deb")
displayName: "Install libnl3, sonic swss common and sairedis"
- script: |
set -x
set -ex
tar czf pytest.tgz tests
cp -r pytest.tgz $(Build.ArtifactStagingDirectory)/
if [ '${{ parameters.archive_gcov }}' == True ]; then
export ENABLE_GCOV=y
fi
./autogen.sh
dpkg-buildpackage -us -uc -b -j$(nproc) && cp ../*.deb .
displayName: "Compile sonic swss"
Expand Down
13 changes: 13 additions & 0 deletions .azure-pipelines/docker-sonic-vs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ ARG docker_container_name

ADD ["debs", "/debs"]

RUN dpkg --purge python-swsscommon
RUN dpkg --purge python3-swsscommon
RUN dpkg --purge swss
RUN dpkg --purge libsairedis
RUN dpkg --purge libswsscommon
RUN dpkg --purge libsaimetadata
RUN dpkg --purge libsaivs
RUN dpkg --purge syncd-vs

RUN dpkg -i /debs/libswsscommon_1.0.0_amd64.deb
RUN dpkg -i /debs/python-swsscommon_1.0.0_amd64.deb
RUN dpkg -i /debs/python3-swsscommon_1.0.0_amd64.deb
Expand All @@ -15,3 +24,7 @@ RUN dpkg -i /debs/syncd-vs_1.0.0_amd64.deb

RUN dpkg --purge swss
RUN dpkg -i /debs/swss_1.0.0_amd64.deb

RUN apt-get update

RUN apt-get -y install lcov
129 changes: 129 additions & 0 deletions .azure-pipelines/gcov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
parameters:
- name: arch
type: string
values:
- amd64
default: amd64

- name: pool
type: string
values:
- sonicbld
- default
default: default

- name: timeout
type: number
default: 180

- name: sonic_slave
type: string

- name: sairedis_artifact_name
type: string

- name: swss_common_artifact_name
type: string

- name: swss_artifact_name
type: string

- name: artifact_name
type: string

- name: archive_gcov
type: boolean
default: false

jobs:
- job:
displayName: ${{ parameters.arch }}
timeoutInMinutes: ${{ parameters.timeout }}

pool:
${{ if ne(parameters.pool, 'default') }}:
name: ${{ parameters.pool }}
${{ if eq(parameters.pool, 'default') }}:
vmImage: 'ubuntu-20.04'

variables:
DIFF_COVER_CHECK_THRESHOLD: 0
DIFF_COVER_ENABLE: 'true'
DIFF_COVER_WORKING_DIRECTORY: $(System.DefaultWorkingDirectory)/gcov/

container:
image: sonicdev-microsoft.azurecr.io:443/${{ parameters.sonic_slave }}:latest


steps:
- script: |
set -ex
# Install .NET CORE
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo apt-add-repository https://packages.microsoft.com/debian/10/prod
sudo apt-get update
sudo apt-get install -y dotnet-sdk-5.0
displayName: "Install .NET CORE"
- script: |
sudo apt-get install -y lcov
displayName: "Install dependencies"
condition: eq('${{ parameters.archive_gcov }}', true)
- task: DownloadPipelineArtifact@2
inputs:
artifact: ${{ parameters.artifact_name }}
displayName: "Download gcov artifact"
condition: eq('${{ parameters.archive_gcov }}', true)
- script: |
set -x
ls -lh
sudo tar -zxvf sonic-gcov.tar.gz
sudo cp -rf sonic-gcov $(Build.ArtifactStagingDirectory)
sudo rm sonic-gcov.tar.gz
ls -lh
workingDirectory: $(Pipeline.Workspace)
displayName: "store sonic-gcov"
condition: eq('${{ parameters.archive_gcov }}', true)
- checkout: self
submodules: true
condition: eq('${{ parameters.archive_gcov }}', true)
- script: |
set -x
wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y dotnet-sdk-5.0
pushd ./s/
sudo tar -zcvf swss.tar.gz ./*
ls -lh ./*
cp ./gcovpreload/lcov_cobertura.py $(Build.ArtifactStagingDirectory)/
cp ./tests/gcov_support.sh $(Build.ArtifactStagingDirectory)/sonic-gcov
sudo cp -rf swss.tar.gz $(Build.ArtifactStagingDirectory)/sonic-gcov
popd
sudo cp -rf $(Build.ArtifactStagingDirectory)/sonic-gcov ./
pushd sonic-gcov
ls -lh ./*
sudo chmod +x ./gcov_support.sh
sudo ./gcov_support.sh generate
sudo ./gcov_support.sh merge_container_info $(Build.ArtifactStagingDirectory)
sudo cp -rf gcov_output $(Build.ArtifactStagingDirectory)
mkdir -p $(System.DefaultWorkingDirectory)/gcov
sudo cp -rf $(Build.ArtifactStagingDirectory)/gcov_output/AllMergeReport/* $(System.DefaultWorkingDirectory)/gcov/
ls -lh $(Build.ArtifactStagingDirectory)
popd
workingDirectory: $(Pipeline.Workspace)
displayName: "generate gcov reports"
condition: eq('${{ parameters.archive_gcov }}', true)

- publish: $(Build.ArtifactStagingDirectory)/gcov_output
artifact: gcov_info
displayName: "Archive gcov info"
condition: eq('${{ parameters.archive_gcov }}', true)

- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.ArtifactStagingDirectory)/gcov_output/AllMergeReport/coverage.xml'
reportDirectory: '$(Build.ArtifactStagingDirectory)/gcov_output/AllMergeReport/'
displayName: 'Publish c c++ test coverage'
condition: eq('${{ parameters.archive_gcov }}', true)

31 changes: 29 additions & 2 deletions .azure-pipelines/test-docker-sonic-vs-template.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
parameters:
- name: timeout
type: number
default: 180
default: 240

- name: log_artifact_name
type: string

- name: gcov_artifact_name
type: string

- name: sonic_slave
type: string

- name: archive_gcov
type: boolean
default: false

jobs:
- job:
displayName: vstest
Expand Down Expand Up @@ -53,7 +63,12 @@ jobs:
sudo /sbin/ip link add Vrf1 type vrf table 1001 || { echo 'vrf command failed' ; exit 1; }
sudo /sbin/ip link del Vrf1 type vrf table 1001
pushd tests
sudo py.test -v --force-flaky --junitxml=tr.xml --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber)

if [ '${{ parameters.archive_gcov }}' == True ]; then
sudo py.test -v --force-flaky --junitxml=tr.xml --keeptb --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber)
else
sudo py.test -v --force-flaky --junitxml=tr.xml --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber)
fi
displayName: "Run vs tests"

- task: PublishTestResults@2
Expand All @@ -64,9 +79,21 @@ jobs:

- script: |
cp -r tests/log $(Build.ArtifactStagingDirectory)/

if [ '${{ parameters.archive_gcov }}' == True ]; then
sudo apt-get install -y lcov
./tests/gcov_support.sh set_environment $(Build.ArtifactStagingDirectory)
docker stop $(docker ps -q -a)
docker rm $(docker ps -q -a)
fi
displayName: "Collect logs"
condition: always()

- publish: $(Build.ArtifactStagingDirectory)/gcov_tmp
artifact: ${{ parameters.gcov_artifact_name }}
displayName: "Publish gcov output"
condition: eq('${{ parameters.archive_gcov }}', true)

- publish: $(Build.ArtifactStagingDirectory)/
artifact: ${{ parameters.log_artifact_name }}@$(System.JobAttempt)
displayName: "Publish logs"
Expand Down
Loading