From 18c79ffa1db3194ca2cb7eeaee6a30322db577ff Mon Sep 17 00:00:00 2001 From: lguohan Date: Wed, 10 Feb 2021 08:37:30 -0800 Subject: [PATCH] [ci]: use build template (#1633) Signed-off-by: Guohan Lu --- .azure-pipelines/build-template.yml | 100 +++++++++++++ azure-pipelines.yml | 223 ++++------------------------ 2 files changed, 131 insertions(+), 192 deletions(-) create mode 100644 .azure-pipelines/build-template.yml diff --git a/.azure-pipelines/build-template.yml b/.azure-pipelines/build-template.yml new file mode 100644 index 0000000000..7d8e12c3ab --- /dev/null +++ b/.azure-pipelines/build-template.yml @@ -0,0 +1,100 @@ +parameters: +- name: arch + type: string + values: + - amd64 + - armhf + - arm64 + +- name: pool + type: string + values: + - sonicbld + - default + default: default + +- name: timeout + type: number + default: 60 + +- name: sonic_slave + type: string + +- name: sairedis_artifact_name + type: string + +- name: swss_common_artifact_name + type: string + +- name: artifact_name + type: string + +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' + + container: + image: sonicdev-microsoft.azurecr.io:443/${{ parameters.sonic_slave }}:latest + + steps: + - 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" + - task: DownloadPipelineArtifact@2 + inputs: + source: specific + project: build + pipeline: 9 + artifacts: ${{ parameters.swss_common_artifact_name }} + runVersion: 'latestFromBranch' + runBranch: 'refs/heads/master' + displayName: "Download sonic swss common deb packages" + - task: DownloadPipelineArtifact@2 + inputs: + source: specific + project: build + pipeline: 12 + artifacts: ${{ parameters.sairedis_artifact_name }} + runVersion: 'latestFromBranch' + runBranch: 'refs/heads/master' + displayName: "Download sonic sairedis deb packages" + - script: | + sudo dpkg -i ${{ parameters.swss_common_artifact_name }}/libswsscommon_1.0.0_${{ parameters.arch }}.deb + sudo dpkg -i ${{ parameters.swss_common_artifact_name }}/libswsscommon-dev_1.0.0_${{ parameters.arch }}.deb + sudo dpkg -i ${{ parameters.sairedis_artifact_name }}/libsaivs_*.deb + sudo dpkg -i ${{ parameters.sairedis_artifact_name }}/libsaivs-dev_*.deb + sudo dpkg -i ${{ parameters.sairedis_artifact_name }}/libsairedis_*.deb + sudo dpkg -i ${{ parameters.sairedis_artifact_name }}/libsairedis-dev_*.deb + sudo dpkg -i ${{ parameters.sairedis_artifact_name }}/libsaimetadata_*.deb + sudo dpkg -i ${{ parameters.sairedis_artifact_name }}/libsaimetadata-dev_*.deb + sudo dpkg -i ${{ parameters.sairedis_artifact_name }}/syncd-vs_*.deb + workingDirectory: $(Pipeline.Workspace) + displayName: "Install sonic swss common and sairedis" + - checkout: self + submodules: true + - script: | + ./autogen.sh + dpkg-buildpackage -us -uc -b -j$(nproc) && cp ../*.deb . + displayName: "Compile sonic swss" + - publish: $(System.DefaultWorkingDirectory)/ + artifact: ${{ parameters.artifact_name }} + displayName: "Archive swss debian packages" diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 852253aa49..af3222caec 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -8,195 +8,34 @@ trigger: include: - "*" -jobs: -- job: - displayName: "amd64" - pool: - vmImage: 'ubuntu-20.04' - - container: - image: sonicdev-microsoft.azurecr.io:443/sonic-slave-buster:latest - - steps: - - 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" - - task: DownloadPipelineArtifact@2 - inputs: - source: specific - project: build - pipeline: 9 - artifacts: sonic-swss-common - runVersion: 'latestFromBranch' - runBranch: 'refs/heads/master' - displayName: "Download sonic swss common deb packages" - - task: DownloadPipelineArtifact@2 - inputs: - source: specific - project: build - pipeline: 12 - artifacts: sonic-sairedis - runVersion: 'latestFromBranch' - runBranch: 'refs/heads/master' - displayName: "Download sonic sairedis deb packages" - - script: | - sudo dpkg -i sonic-swss-common/libswsscommon_1.0.0_amd64.deb - sudo dpkg -i sonic-swss-common/libswsscommon-dev_1.0.0_amd64.deb - sudo dpkg -i sonic-sairedis/libsaivs_*.deb - sudo dpkg -i sonic-sairedis/libsaivs-dev_*.deb - sudo dpkg -i sonic-sairedis/libsairedis_*.deb - sudo dpkg -i sonic-sairedis/libsairedis-dev_*.deb - sudo dpkg -i sonic-sairedis/libsaimetadata_*.deb - sudo dpkg -i sonic-sairedis/libsaimetadata-dev_*.deb - sudo dpkg -i sonic-sairedis/syncd-vs_*.deb - workingDirectory: $(Pipeline.Workspace) - displayName: "Install sonic swss common and sairedis" - - checkout: self - submodules: true - - script: | - ./autogen.sh - dpkg-buildpackage -us -uc -b -j$(nproc) && cp ../*.deb . - displayName: "Compile sonic swss" - - publish: $(System.DefaultWorkingDirectory)/ - artifact: sonic-swss - displayName: "Archive swss debian packages" - -- job: - displayName: "arm64" - timeoutInMinutes: 180 - pool: sonicbld - - container: - image: sonicdev-microsoft.azurecr.io:443/sonic-slave-buster-arm64:latest - - steps: - - 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" - - task: DownloadPipelineArtifact@2 - inputs: - source: specific - project: build - pipeline: 9 - artifacts: sonic-swss-common.arm64 - runVersion: 'latestFromBranch' - runBranch: 'refs/heads/master' - displayName: "Download sonic swss common deb packages" - - task: DownloadPipelineArtifact@2 - inputs: - source: specific - project: build - pipeline: 12 - artifacts: sonic-sairedis.arm64 - runVersion: 'latestFromBranch' - runBranch: 'refs/heads/master' - displayName: "Download sonic sairedis deb packages" - - script: | - sudo dpkg -i sonic-swss-common.arm64/libswsscommon_1.0.0_arm64.deb - sudo dpkg -i sonic-swss-common.arm64/libswsscommon-dev_1.0.0_arm64.deb - sudo dpkg -i sonic-sairedis.arm64/libsaivs_*.deb - sudo dpkg -i sonic-sairedis.arm64/libsaivs-dev_*.deb - sudo dpkg -i sonic-sairedis.arm64/libsairedis_*.deb - sudo dpkg -i sonic-sairedis.arm64/libsairedis-dev_*.deb - sudo dpkg -i sonic-sairedis.arm64/libsaimetadata_*.deb - sudo dpkg -i sonic-sairedis.arm64/libsaimetadata-dev_*.deb - sudo dpkg -i sonic-sairedis.arm64/syncd-vs_*.deb - workingDirectory: $(Pipeline.Workspace) - displayName: "Install sonic swss common and sairedis" - - checkout: self - submodules: true - - script: | - ./autogen.sh - dpkg-buildpackage -us -uc -b -j$(nproc) && cp ../*.deb . - displayName: "Compile sonic swss" - - publish: $(System.DefaultWorkingDirectory)/ - artifact: sonic-swss.arm64 - displayName: "Archive swss debian packages" - -- job: - displayName: "armhf" - timeoutInMinutes: 180 - pool: sonicbld - - container: - image: sonicdev-microsoft.azurecr.io:443/sonic-slave-buster-armhf:latest - - steps: - - 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" - - task: DownloadPipelineArtifact@2 - inputs: - source: specific - project: build - pipeline: 9 - artifacts: sonic-swss-common.armhf - runVersion: 'latestFromBranch' - runBranch: 'refs/heads/master' - displayName: "Download sonic swss common deb packages" - - task: DownloadPipelineArtifact@2 - inputs: - source: specific - project: build - pipeline: 12 - artifacts: sonic-sairedis.armhf - runVersion: 'latestFromBranch' - runBranch: 'refs/heads/master' - displayName: "Download sonic sairedis deb packages" - - script: | - sudo dpkg -i sonic-swss-common.armhf/libswsscommon_1.0.0_armhf.deb - sudo dpkg -i sonic-swss-common.armhf/libswsscommon-dev_1.0.0_armhf.deb - sudo dpkg -i sonic-sairedis.armhf/libsaivs_*.deb - sudo dpkg -i sonic-sairedis.armhf/libsaivs-dev_*.deb - sudo dpkg -i sonic-sairedis.armhf/libsairedis_*.deb - sudo dpkg -i sonic-sairedis.armhf/libsairedis-dev_*.deb - sudo dpkg -i sonic-sairedis.armhf/libsaimetadata_*.deb - sudo dpkg -i sonic-sairedis.armhf/libsaimetadata-dev_*.deb - sudo dpkg -i sonic-sairedis.armhf/syncd-vs_*.deb - workingDirectory: $(Pipeline.Workspace) - displayName: "Install sonic swss common and sairedis" - - checkout: self - submodules: true - - script: | - ./autogen.sh - dpkg-buildpackage -us -uc -b -j$(nproc) && cp ../*.deb . - displayName: "Compile sonic swss" - - publish: $(System.DefaultWorkingDirectory)/ - artifact: sonic-swss.armhf - displayName: "Archive swss debian packages" +stages: +- stage: Build + + jobs: + - template: .azure-pipelines/build-template.yml + parameters: + arch: amd64 + sonic_slave: sonic-slave-buster + swss_common_artifact_name: sonic-swss-common + sairedis_artifact_name: sonic-sairedis + artifact_name: sonic-swss + + - template: .azure-pipelines/build-template.yml + parameters: + arch: armhf + timeout: 240 + pool: sonicbld + sonic_slave: sonic-slave-buster-armhf + swss_common_artifact_name: sonic-swss-common.armhf + sairedis_artifact_name: sonic-sairedis.armhf + artifact_name: sonic-swss.armhf + + - template: .azure-pipelines/build-template.yml + parameters: + arch: arm64 + timeout: 240 + pool: sonicbld + sonic_slave: sonic-slave-buster-arm64 + swss_common_artifact_name: sonic-swss-common.arm64 + sairedis_artifact_name: sonic-sairedis.arm64 + artifact_name: sonic-swss.arm64