-
Notifications
You must be signed in to change notification settings - Fork 32
/
azurepipeline.yml
70 lines (62 loc) · 2.23 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
trigger:
branches:
include:
- "*"
pr:
branches:
include:
- "*"
jobs:
- job: Build
pool:
vmImage: ubuntu-20.04
variables:
DIFF_COVER_CHECK_THRESHOLD: 80
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 -r test/requirements.txt
pip install -U pytest
cd test
pytest -vv
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/20.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'