forked from KomodoPlatform/komodo-defi-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines-build-stage-job.yml
128 lines (126 loc) · 5.71 KB
/
azure-pipelines-build-stage-job.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# Job template for MM2 Build
parameters:
name: '' # defaults for any parameters that aren't specified
os: ''
bob_passphrase: ''
bob_userpass: ''
alice_passphrase: ''
alice_userpass: ''
telegram_api_key: ''
jobs:
- job: ${{ parameters.name }}
timeoutInMinutes: 0 # 0 means infinite for self-hosted agent
pool:
name: Default
demands: agent.os -equals ${{ parameters.os }}
steps:
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
clean: ${{ eq( variables['Build.Reason'], 'Schedule' ) }} # clean up only on Scheduled build
- bash: |
if [ $CLEANUP = "true" ]
then
git clean -ffdx
fi
displayName: Clean Up
failOnStderr: false
continueOnError: true
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#set-a-job-scoped-variable-from-a-script
- bash: |
export TAG="$(git rev-parse --short=9 HEAD)"
echo "##vso[task.setvariable variable=COMMIT_HASH]${TAG}"
displayName: Setup ENV
# On MacOS, cross-compile for x86_64-apple-darwin
- bash: |
rm -rf upload
mkdir upload
VERSION=$(Build.BuildId)_$(Build.SourceBranchName)_$(COMMIT_HASH)_$(Agent.OS)_CI
if ! grep -q $VERSION MM_VERSION; then
echo $VERSION > MM_VERSION
fi
cat MM_VERSION
if [ $AGENT_OS = "Darwin" ]
then
cargo build --bin mm2 --profile ci --target x86_64-apple-darwin
else
cargo build --bin mm2 --profile ci
fi
displayName: 'Build MM2'
condition: ne ( variables['Build.Reason'], 'PullRequest' )
env:
MANUAL_MM_VERSION: true
JEMALLOC_SYS_WITH_MALLOC_CONF: "background_thread:true,narenas:1,tcache:false,dirty_decay_ms:0,muzzy_decay_ms:0,metadata_thp:auto"
- task: Docker@2
displayName: Build & Push container of dev branch
condition: and( eq( variables['Agent.OS'], 'Linux' ), eq( variables['Build.SourceBranchName'], 'dev' ) )
inputs:
containerRegistry: dockerhub
repository: komodoofficial/atomicdexapi
command: buildAndPush
tags: |
dev-$(COMMIT_HASH)
dev-latest
Dockerfile: Dockerfile.dev-release
- bash: |
rm -rf atomicdex-deployments
git clone [email protected]:KomodoPlatform/atomicdex-deployments.git
if [ -d "atomicdex-deployments/atomicDEX-API" ]; then
cd atomicdex-deployments/atomicDEX-API
sed -i "1s/^.*$/$(COMMIT_HASH)/" .commit
git add .commit
git commit -m "[atomicDEX-API] $(COMMIT_HASH) is committed for git & container registry"
git push
fi
condition: and( eq( variables['Agent.OS'], 'Linux' ), eq( variables['Build.SourceBranchName'], 'dev' ) )
displayName: 'Update playground deployment'
# Explicit --test-threads=16 makes testing process slightly faster on agents that have <16 CPU cores.
# Always run tests on main branch and PRs
# On MacOS, run for x86_64-apple-darwin
- bash: |
if [ $AGENT_OS = "Darwin" ]
then
cargo test --all --target x86_64-apple-darwin --profile ci -- --test-threads=16
else
cargo test --all --profile ci -- --test-threads=32
fi
displayName: 'Test MM2'
timeoutInMinutes: 22
env:
BOB_PASSPHRASE: $(${{ parameters.bob_passphrase }})
BOB_USERPASS: $(${{ parameters.bob_userpass }})
ALICE_PASSPHRASE: $(${{ parameters.alice_passphrase }})
ALICE_USERPASS: $(${{ parameters.alice_userpass }})
TELEGRAM_API_KEY: $(${{ parameters.telegram_api_key }})
RUST_LOG: debug
MANUAL_MM_VERSION: true
condition: or( eq( variables['Build.Reason'], 'PullRequest' ), eq( variables['Build.SourceBranchName'], 'main' ), eq( variables['Build.SourceBranchName'], 'dev' ) )
- bash: |
containers=$(docker ps -q | wc -l)
echo $containers
if [ $containers -gt 0 ]; then
docker rm -f $(docker ps -q)
fi
displayName: 'Clean up Docker containers'
# Run unconditionally even if previous steps failed
condition: true
- bash: |
zip upload/mm2-$(COMMIT_HASH)-$(Agent.OS)-CI target/ci/mm2 -j
displayName: 'Prepare CI build upload Linux'
condition: and ( eq( variables['Agent.OS'], 'Linux' ), ne ( variables['Build.Reason'], 'PullRequest' ) )
- bash: |
zip upload/mm2-$(COMMIT_HASH)-$(Agent.OS)-CI target/x86_64-apple-darwin/ci/mm2 -j
displayName: 'Prepare CI build upload MacOS'
condition: and ( eq( variables['Agent.OS'], 'Darwin' ), ne ( variables['Build.Reason'], 'PullRequest' ) )
- powershell: |
7z a .\upload\mm2-$(COMMIT_HASH)-$(Agent.OS)-CI.zip .\target\ci\mm2.exe .\target\ci\*.dll "$Env:windir\system32\msvcr100.dll" "$Env:windir\system32\msvcp140.dll" "$Env:windir\system32\vcruntime140.dll"
displayName: 'Prepare CI build upload Windows'
condition: and ( eq( variables['Agent.OS'], 'Windows_NT' ), ne ( variables['Build.Reason'], 'PullRequest' ) )
# https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/copy-files-over-ssh?view=vsts
- task: CopyFilesOverSSH@0
inputs:
sshEndpoint: nightly_build_server
sourceFolder: 'upload' # Optional
contents: "**"
targetFolder: "uploads/$(Build.SourceBranchName)" # Optional
overwrite: true
displayName: 'Upload nightly'
condition: ne ( variables['Build.Reason'], 'PullRequest' )