-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathazure-pipelines.yml
142 lines (136 loc) · 4.74 KB
/
azure-pipelines.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Demonstrate creating a self hosted GPU accelerated build agent using Terraform,
# and then running a job on that agent that shows OpenGL is available when building inside a container
# TODO:
# - create temporary and unique agent pool to avoid clashes between different builds (or look at demands as a mechanism)
# - robust checking that the GPU agent has been destroyed (don't run the meter!)
# - allow the GPU builder to stick around for a few minutes, don't always destroy it
# - correctly deregister the GPU build agent from the pool before destroying it
# - consider generating temp ssh keys on the fly to provision GPU build agent
# - Figure out dependencies between matrixed jobs
trigger:
- master
# no PR triggers: only committers to the master branch should be able to trigger these builds
pr: none
jobs:
- job: GPUCreateTerraform
strategy:
matrix:
azure:
cspName: 'azure'
aws:
cspName: 'aws'
gcp:
cspName: 'gcp'
maxParallel: 3
pool:
vmImage: ubuntu-18.04
steps:
- task: DownloadSecureFile@1
name: ssh_public_key
displayName: 'Download ssh public key'
inputs:
secureFile: id_rsa.pub
- task: DownloadSecureFile@1
name: ssh_private_key
displayName: 'Download ssh private key'
inputs:
secureFile: id_rsa
- script: |
mkdir ~/.ssh
chmod 700 ~/.ssh
sudo cp $(ssh_private_key.secureFilePath) ~/.ssh/id_rsa
sudo cp $(ssh_public_key.secureFilePath) ~/.ssh/id_rsa.pub
sudo chown $(id -u):$(id -g) ~/.ssh/id_rsa
sudo chown $(id -u):$(id -g) ~/.ssh/id_rsa.pub
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
displayName: 'Install ssh keys'
- script: |
cd $(cspName)
terraform init -backend-config="token=$TF_API_TOKEN" -backend-config="organization=$TF_API_ORGANIZATION" -backend-config=backend.hcl
terraform apply -auto-approve
displayName: 'Terraform builds the GPU build agent on $(cspName)'
env:
ARM_CLIENT_ID: $(ARM_CLIENT_ID)
ARM_CLIENT_SECRET: $(ARM_CLIENT_SECRET)
ARM_SUBSCRIPTION_ID: $(ARM_SUBSCRIPTION_ID)
ARM_TENANT_ID: $(ARM_TENANT_ID)
TF_VAR_aws_access_key_id: $(TF_VAR_aws_access_key_id)
TF_VAR_aws_secret_access_key: $(TF_VAR_aws_secret_access_key)
GOOGLE_CLOUD_KEYFILE_JSON: $(GOOGLE_CLOUD_KEYFILE_JSON)
AZURE_DEVOPS_ORGANIZATION: $(AZURE_DEVOPS_ORGANIZATION)
AZURE_DEVOPS_PAT_TOKEN: $(AZURE_DEVOPS_PAT_TOKEN)
AZURE_DEVOPS_GPU_POOL: 'GPU Ubuntu 18.04 $(cspName)'
TF_API_TOKEN: $(TF_API_TOKEN)
TF_API_ORGANIZATION: $(TF_API_ORGANIZATION)
- job: GPUDemoOpenGL
dependsOn: GPUCreateTerraform
strategy:
matrix:
azure:
cspName: 'azure'
aws:
cspName: 'aws'
gcp:
cspName: 'gcp'
maxParallel: 3
pool:
name: 'GPU Ubuntu 18.04 $(cspName)'
container:
image: aswftesting/ci-ocio:2019.1
options: --gpus all -v /tmp/.X11-unix:/tmp/.X11-unix
steps:
- script: |
glxinfo
displayName: 'Demonstrate GPU accelerated X visuals on $(cspName)'
env:
DISPLAY: ':0.0'
- job: GPUDestroyTerraform
dependsOn: GPUDemoOpenGL
strategy:
matrix:
azure:
cspName: 'azure'
aws:
cspName: 'aws'
gcp:
cspName: 'gcp'
maxParallel: 3
pool:
vmImage: ubuntu-18.04
steps:
- task: DownloadSecureFile@1
name: ssh_public_key
displayName: 'Download ssh public key'
inputs:
secureFile: id_rsa.pub
- task: DownloadSecureFile@1
name: ssh_private_key
displayName: 'Download ssh private key'
inputs:
secureFile: id_rsa
- script: |
mkdir ~/.ssh
chmod 700 ~/.ssh
sudo cp $(ssh_private_key.secureFilePath) ~/.ssh/id_rsa
sudo cp $(ssh_public_key.secureFilePath) ~/.ssh/id_rsa.pub
sudo chown $(id -u):$(id -g) ~/.ssh/id_rsa
sudo chown $(id -u):$(id -g) ~/.ssh/id_rsa.pub
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
displayName: 'Install ssh keys'
- script: |
cd $(cspName)
terraform init -backend-config="token=$TF_API_TOKEN" -backend-config="organization=$TF_API_ORGANIZATION" -backend-config=backend.hcl
terraform destroy -auto-approve
displayName: 'Terraform destroys the GPU build agent on $(cspName)'
env:
ARM_CLIENT_ID: $(ARM_CLIENT_ID)
ARM_CLIENT_SECRET: $(ARM_CLIENT_SECRET)
ARM_SUBSCRIPTION_ID: $(ARM_SUBSCRIPTION_ID)
ARM_TENANT_ID: $(ARM_TENANT_ID)
TF_VAR_aws_access_key_id: $(TF_VAR_aws_access_key_id)
TF_VAR_aws_secret_access_key: $(TF_VAR_aws_secret_access_key)
GOOGLE_CLOUD_KEYFILE_JSON: $(GOOGLE_CLOUD_KEYFILE_JSON)
TF_API_TOKEN: $(TF_API_TOKEN)
TF_API_ORGANIZATION: $(TF_API_ORGANIZATION)