From eda0ca97d19715be4fd1cfa4cf7a28afa9937a9c Mon Sep 17 00:00:00 2001 From: lguohan Date: Wed, 31 Mar 2021 01:51:35 -0700 Subject: [PATCH] [ci]: setup proper azp (#44) Signed-off-by: Guohan Lu --- .artifactignore | 2 ++ azure-pipelines.yml | 85 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 76 insertions(+), 11 deletions(-) create mode 100644 .artifactignore diff --git a/.artifactignore b/.artifactignore new file mode 100644 index 000000000000..1126a160d97d --- /dev/null +++ b/.artifactignore @@ -0,0 +1,2 @@ +**/* +!*.deb diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3539641a0a21..ac91bb4eb00a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,32 +7,95 @@ trigger: branches: include: - master - pr: branches: include: - master -pool: - vmImage: ubuntu-20.04 - stages: - stage: Build jobs: - job: - displayName: "build" + displayName: "Build" timeoutInMinutes: 60 + + pool: + vmImage: ubuntu-20.04 + + container: + image: sonicdev-microsoft.azurecr.io:443/sonic-slave-buster:latest + steps: - checkout: self clean: true submodules: recursive displayName: 'Checkout code' + + - task: DownloadPipelineArtifact@2 + inputs: + source: specific + project: build + pipeline: 1 + artifact: sonic-buildimage.vs + runVersion: 'latestFromBranch' + runBranch: 'refs/heads/master' + displayName: "Download sonic buildimage" + - script: | - echo Hello - # the following is copied from jenkins - # set -ex - # ./scripts/common/sonic-mgmt-common-build/build.sh - # ./scripts/common/sonic-mgmt-common-build/test.sh - - publish: $(System.DefaultWorkingDirectory)/target/ + # REDIS + 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 + + # LIBYANG + sudo dpkg -i ../target/debs/buster/libyang*1.0.73*.deb + displayName: "Install dependency" + + - script: | + ls -l + dpkg-buildpackage -rfakeroot -us -uc -b -j$(nproc) && cp ../*.deb . + displayName: "Build" + + - publish: $(System.DefaultWorkingDirectory)/ artifact: sonic-mgmt-common displayName: "Archive artifacts" + + - script: | + # Run sanity tests for sonic-mgmt-common. + # Assumes sonic-mgmt-common is already compiled and all dependencies + # are installed. + + set -x + + STATUS=0 + DEBDIR=$(realpath debian/sonic-mgmt-common) + + [[ -f tools/test/database_config.json ]] && \ + export DB_CONFIG_PATH=${PWD}/tools/test/database_config.json + + # Run CVL tests + + pushd build/tests/cvl + + CVL_SCHEMA_PATH=testdata/schema \ + ./cvl.test -test.v -logtostderr || STATUS=1 + + popd + + # Run translib tests + + pushd build/tests/translib + + export CVL_SCHEMA_PATH=${DEBDIR}/usr/sbin/schema + export YANG_MODELS_PATH=${DEBDIR}/usr/models/yang + + ./db.test -test.v -logtostderr || STATUS=1 + + ./translib.test -test.v -logtostderr || STATUS=1 + + popd + + exit ${STATUS} + displayName: "Sanity test"