forked from sonic-net/sonic-restapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azurepipeline.yml
71 lines (63 loc) · 2.24 KB
/
azurepipeline.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
trigger:
branches:
include:
- "*"
pr:
branches:
include:
- "*"
jobs:
- job: Build
pool:
vmImage: ubuntu-18.04
variables:
DIFF_COVER_CHECK_THRESHOLD: 50
DIFF_COVER_ENABLE: 'true'
DIFF_COVER_WORKING_DIRECTORY: $(System.DefaultWorkingDirectory)
steps:
- checkout: self
clean: true
- script: |
set -ex
./build.sh
docker run -d --rm -p8090:8090 -p6379:6379 --name rest-api --cap-add NET_ADMIN --privileged -t rest-api-image-test_local:latest
docker save rest-api-image-test_local | gzip > rest-api-image-test_local.gz
docker save rest-api-build-image | gzip > rest-api-build-image.gz
cp *.gz $(Build.ArtifactStagingDirectory)
mkdir $(Build.ArtifactStagingDirectory)/debs
cp debs/*.deb $(Build.ArtifactStagingDirectory)/debs
cp debian/sonic-rest-api/usr/sbin/go-server-server $(Build.ArtifactStagingDirectory)
displayName: 'Build image'
- script: |
set -ex
pip install requests
pip install redis
pip install -U pytest
cd test
pytest -v
docker exec rest-api cat /tmp/rest-api.err.log
docker exec rest-api ps aux
sleep 600
cd ..
docker cp rest-api:/coverage.cov ./
docker run -d --rm=true --name rest-api_build -v /tmp/target:/src -v $(pwd):/src/rest -w /src/rest rest-api-build-image tail -f /dev/null
mkdir htmlcov
docker exec rest-api_build sh /src/rest/cover.sh
displayName: Test
- publish: $(Build.ArtifactStagingDirectory)/
artifact: 'sonic-restapi'
displayName: "Archive artifacts"
- 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/ubuntu/18.04/prod
sudo apt-get update
sudo apt-get install -y dotnet-sdk-5.0
displayName: "Install .NET CORE"
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/htmlcov/'
displayName: 'Publish test coverage'