From e0748a6fd1736ed002cba4df28c2f11b138edc7d Mon Sep 17 00:00:00 2001 From: lguohan Date: Thu, 11 Feb 2021 21:03:56 -0800 Subject: [PATCH] [ci]: use build template (#793) Signed-off-by: Guohan Lu --- .azure-pipelines/build-template.yml | 129 +++++++++++++ azure-pipelines.yml | 289 +++------------------------- 2 files changed, 161 insertions(+), 257 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 000000000000..fca262783701 --- /dev/null +++ b/.azure-pipelines/build-template.yml @@ -0,0 +1,129 @@ +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: swss_common_artifact_name + type: string + +- name: artifact_name + type: string + +- name: syslog_artifact_name + type: string + +- name: run_unit_test + 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' + + container: + image: sonicdev-microsoft.azurecr.io:443/${{ parameters.sonic_slave }}:latest + + steps: + - script: | + sudo apt-get install -qq -y \ + qtbase5-dev \ + libdbus-glib-1-2 \ + libdbus-glib-1-dev \ + libpcsclite-dev \ + docbook-to-man \ + docbook-utils \ + aspell-en \ + libhiredis0.14 \ + libhiredis-dev \ + libnl-3-dev \ + libnl-genl-3-dev \ + libnl-route-3-dev \ + libnl-nf-3-dev \ + libnl-cli-3-dev \ + swig3.0 \ + libpython2.7-dev \ + libzmq5 libzmq3-dev + + sudo apt-get install -y redis-server + sudo sed -ri 's/^# unixsocket/unixsocket/' /etc/redis/redis.conf + sudo sed -ri 's/^unixsocketperm .../unixsocketperm 777/' /etc/redis/redis.conf + sudo sed -ri 's/redis-server.sock/redis.sock/' /etc/redis/redis.conf + sudo service redis-server start + + sudo apt-get install -y rsyslog + sudo service rsyslog start + + 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" + - 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 + workingDirectory: $(Pipeline.Workspace) + displayName: "Install sonic swss Common" + - checkout: self + submodules: true + - script: | + ./autogen.sh + fakeroot dpkg-buildpackage -b -us -uc -Tbinary-syncd-vs -j$(nproc) && cp ../*.deb . + displayName: "Compile sonic sairedis" + - script: | + sudo cp azsyslog.conf /etc/rsyslog.conf + sudo service rsyslog restart + displayName: "Update rsyslog.conf" + - ${{ if eq(parameters.run_unit_test, true) }}: + - script: | + make check + displayName: "Run sonic sairedis unit tests" + - publish: $(System.DefaultWorkingDirectory)/ + artifact: ${{ parameters.artifact_name }} + displayName: "Archive sonic sairedis debian packages" + - script: | + pwd + sudo chmod a+r /var/log/syslog* + tar -czf syslog-all.tgz /var/log/syslog* + ls -al . + ls -al /var/log/ + displayName: "Env info" + condition: always() + - task: CopyFiles@2 + displayName: "Copy syslog to staging directory" + condition: always() + inputs: + contents: 'syslog-all.tgz' + targetFolder: $(Build.ArtifactStagingDirectory) + - publish: $(Build.ArtifactStagingDirectory)/ + artifact: ${{ parameters.syslog_artifact_name }} + displayName: "Publish syslog artifacts" + condition: always() diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fb8d389b0c29..e5ed7ad266be 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,261 +7,36 @@ trigger: branches: 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 -qq -y \ - qtbase5-dev \ - libdbus-glib-1-2 \ - libdbus-glib-1-dev \ - libpcsclite-dev \ - docbook-to-man \ - docbook-utils \ - aspell-en \ - libhiredis0.14 \ - libhiredis-dev \ - libnl-3-dev \ - libnl-genl-3-dev \ - libnl-route-3-dev \ - libnl-nf-3-dev \ - libnl-cli-3-dev \ - swig3.0 \ - libpython2.7-dev \ - libzmq5 libzmq3-dev - - sudo apt-get install -y redis-server - sudo sed -ri 's/^# unixsocket/unixsocket/' /etc/redis/redis.conf - sudo sed -ri 's/^unixsocketperm .../unixsocketperm 777/' /etc/redis/redis.conf - sudo sed -ri 's/redis-server.sock/redis.sock/' /etc/redis/redis.conf - sudo service redis-server start - - sudo apt-get install -y rsyslog - sudo service rsyslog start - - 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" - - 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 - workingDirectory: $(Pipeline.Workspace) - displayName: "Install sonic swss Common" - - checkout: self - submodules: true - - script: | - ./autogen.sh - fakeroot dpkg-buildpackage -b -us -uc -Tbinary-syncd-vs -j$(nproc) && cp ../*.deb . - displayName: "Compile sonic sairedis" - - script: | - sudo cp azsyslog.conf /etc/rsyslog.conf - sudo service rsyslog restart - displayName: "Update rsyslog.conf" - - script: | - make check - displayName: "Run sonic sairedis unit tests" - - publish: $(System.DefaultWorkingDirectory)/ - artifact: sonic-sairedis - displayName: "Archive sonic sairedis debian packages" - - script: | - pwd - sudo chmod a+r /var/log/syslog* - tar -czf syslog-all.tgz /var/log/syslog* - ls -al . - ls -al /var/log/ - displayName: "Env info" - condition: always() - - task: CopyFiles@2 - displayName: "Copy syslog to staging directory" - condition: always() - inputs: - contents: 'syslog-all.tgz' - targetFolder: $(Build.ArtifactStagingDirectory) - - publish: $(Build.ArtifactStagingDirectory)/ - artifact: sonic-sairedis.syslog.amd64 - displayName: "Publish syslog artifacts" - condition: always() - -- job: - timeoutInMinutes: 180 - displayName: "arm64" - pool: sonicbld - - container: - image: sonicdev-microsoft.azurecr.io:443/sonic-slave-buster-arm64:latest - - steps: - - script: | - sudo apt-get install -qq -y \ - qtbase5-dev \ - libdbus-glib-1-2 \ - libdbus-glib-1-dev \ - libpcsclite-dev \ - docbook-to-man \ - docbook-utils \ - aspell-en \ - libhiredis0.14 \ - libhiredis-dev \ - libnl-3-dev \ - libnl-genl-3-dev \ - libnl-route-3-dev \ - libnl-nf-3-dev \ - libnl-cli-3-dev \ - swig3.0 \ - libpython2.7-dev \ - libzmq5 libzmq3-dev - - sudo apt-get install -y redis-server - sudo sed -ri 's/^# unixsocket/unixsocket/' /etc/redis/redis.conf - sudo sed -ri 's/^unixsocketperm .../unixsocketperm 777/' /etc/redis/redis.conf - sudo sed -ri 's/redis-server.sock/redis.sock/' /etc/redis/redis.conf - sudo service redis-server start - - sudo apt-get install -y rsyslog - sudo service rsyslog start - - 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" - - 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 - workingDirectory: $(Pipeline.Workspace) - displayName: "Install sonic swss Common" - - checkout: self - submodules: true - - script: | - ./autogen.sh - fakeroot dpkg-buildpackage -b -us -uc -Tbinary-syncd-vs -j$(nproc) && cp ../*.deb . - displayName: "Compile sonic sairedis" - - script: | - sudo cp azsyslog.conf /etc/rsyslog.conf - sudo service rsyslog restart - displayName: "Update rsyslog.conf" - - publish: $(System.DefaultWorkingDirectory)/ - artifact: sonic-sairedis.arm64 - displayName: "Archive sonic sairedis debian packages" - - script: | - pwd - sudo chmod a+r /var/log/syslog* - tar -czf syslog-all.tgz /var/log/syslog* - ls -al . - ls -al /var/log/ - displayName: "Env info" - condition: always() - - task: CopyFiles@2 - displayName: "Copy syslog to staging directory" - condition: always() - inputs: - contents: 'syslog-all.tgz' - targetFolder: $(Build.ArtifactStagingDirectory) - - publish: $(Build.ArtifactStagingDirectory)/ - artifact: sonic-sairedis.syslog.arm64 - displayName: "Publish syslog artifacts" - condition: always() - -- job: - timeoutInMinutes: 180 - displayName: "armhf" - pool: sonicbld - - container: - image: sonicdev-microsoft.azurecr.io:443/sonic-slave-buster-armhf:latest - - steps: - - script: | - sudo apt-get install -qq -y \ - qtbase5-dev \ - libdbus-glib-1-2 \ - libdbus-glib-1-dev \ - libpcsclite-dev \ - docbook-to-man \ - docbook-utils \ - aspell-en \ - libhiredis0.14 \ - libhiredis-dev \ - libnl-3-dev \ - libnl-genl-3-dev \ - libnl-route-3-dev \ - libnl-nf-3-dev \ - libnl-cli-3-dev \ - swig3.0 \ - libpython2.7-dev \ - libzmq5 libzmq3-dev - - sudo apt-get install -y redis-server - sudo sed -ri 's/^# unixsocket/unixsocket/' /etc/redis/redis.conf - sudo sed -ri 's/^unixsocketperm .../unixsocketperm 777/' /etc/redis/redis.conf - sudo sed -ri 's/redis-server.sock/redis.sock/' /etc/redis/redis.conf - sudo service redis-server start - - sudo apt-get install -y rsyslog - sudo service rsyslog start - - 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" - - 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 - workingDirectory: $(Pipeline.Workspace) - displayName: "Install sonic swss Common" - - checkout: self - submodules: true - - script: | - ./autogen.sh - fakeroot dpkg-buildpackage -b -us -uc -Tbinary-syncd-vs -j$(nproc) && cp ../*.deb . - displayName: "Compile sonic sairedis" - - script: | - sudo cp azsyslog.conf /etc/rsyslog.conf - sudo service rsyslog restart - displayName: "Update rsyslog.conf" - - publish: $(System.DefaultWorkingDirectory)/ - artifact: sonic-sairedis.armhf - displayName: "Archive sonic sairedis debian packages" - - script: | - pwd - sudo chmod a+r /var/log/syslog* - tar -czf syslog-all.tgz /var/log/syslog* - ls -al . - ls -al /var/log/ - displayName: "Env info" - condition: always() - - task: CopyFiles@2 - displayName: "Copy syslog to staging directory" - condition: always() - inputs: - contents: 'syslog-all.tgz' - targetFolder: $(Build.ArtifactStagingDirectory) - - publish: $(Build.ArtifactStagingDirectory)/ - artifact: sonic-sairedis.syslog.armhf - displayName: "Publish syslog artifacts" - condition: always() +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 + artifact_name: sonic-sairedis + syslog_artifact_name: sonic-sairedis.syslog + run_unit_test: true + + - template: .azure-pipelines/build-template.yml + parameters: + arch: armhf + timeout: 180 + pool: sonicbld + sonic_slave: sonic-slave-buster-armhf + swss_common_artifact_name: sonic-swss-common.armhf + artifact_name: sonic-sairedis.armhf + syslog_artifact_name: sonic-sairedis.syslog.armhf + + - template: .azure-pipelines/build-template.yml + parameters: + arch: arm64 + timeout: 180 + pool: sonicbld + sonic_slave: sonic-slave-buster-arm64 + swss_common_artifact_name: sonic-swss-common.arm64 + artifact_name: sonic-sairedis.arm64 + syslog_artifact_name: sonic-sairedis.syslog.arm64