forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.yml
244 lines (220 loc) · 8.98 KB
/
env.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#
# Note to use the outputs created here - this `stage` must be set as a dependency in the relevant stage
# eg:
#
# stage: mystage
# dependsOn: ["env"]
#
# To use a variable as a condition for a `stage` you can specify it as follows:
#
# condition: and(not(canceled()), succeeded(), ne(dependencies.env.outputs['repo.changed.mobileOnly'], 'true'))
#
# To use a variable as a condition for a `job` you can specify it as follows:
#
# job:
# condition: and(not(canceled()), succeeded(), ne(stageDependencies.env.repo.outputs['changed.mobileOnly'], 'true'))
#
# NB: Avoid using _inclusive_ lists to trigger CI - eg _dont_ only trigger mobile CI if `mobile/` changed.
# Instead use _exclusive_ bools - eg _do_ suppress other CI if only `mobile/` changed
#
# Note the difference in name resolution when used in stages and jobs.
#
# Note also, other conditions such as `not(canceled())` are not assumed and so need to be added to
# any conditions explicitly.
#
# To use a variable in a `step` you can specify it as follows:
#
# stage: my_next_stage
# jobs:
# job: another_job
# variables:
# mobileOnly: $[stageDependencies.env.repo.outputs['changed.mobileOnly']]
# steps:
# - bash: echo $(mobileOnly)
#
jobs:
# Warm build image caches
- job: cache
displayName: Cache
pool:
vmImage: $(agentUbuntu)
steps:
- template: cached.yml
parameters:
prime: true
- job: cache_arm
dependsOn: []
displayName: Cache (arm64)
pool: envoy-arm-small
steps:
- template: cached.yml
parameters:
prime: true
arch: .arm64
- job: repo
dependsOn: []
displayName: Repository
pool:
vmImage: $(agentUbuntu)
steps:
- checkout: self
fetchDepth: 0
fetchTags: true
- bash: |
# TODO(phlax): move this to a script to ensure proper linting etc
set -e
# Only exclude checks in pull requests.
if [[ $(Build.Reason) != "PullRequest" ]]; then
echo "##vso[task.setvariable variable=mobileOnly;isoutput=true]false"
echo "##vso[task.setvariable variable=docsOnly;isoutput=true]false"
echo "##vso[task.setvariable variable=examplesOnly;isoutput=true]false"
echo "##vso[task.setvariable variable=requirements;isoutput=true]true"
exit 0
fi
CHANGE_TARGET="origin/$(System.PullRequest.TargetBranch)"
echo "Comparing changes ${CHANGE_TARGET}...HEAD"
CHANGED_PATHS="$(git diff --name-only ${CHANGE_TARGET}...HEAD | cut -d/ -f1 | sort -u | jq -sR 'rtrimstr("\n") | split("\n")')"
echo "$CHANGED_PATHS" | jq '.'
CHANGED_PATH_COUNT=$(echo $CHANGED_PATHS | jq '. | length')
CHANGED_MOBILE_ONLY=false
CHANGED_DOCS_ONLY=false
CHANGED_EXAMPLES_ONLY=false
CHANGED_MOBILE=$(echo $CHANGED_PATHS | jq '. as $A | "mobile" | IN($A[])')
if [[ $CHANGED_MOBILE == true && $CHANGED_PATH_COUNT -eq 1 ]]; then
CHANGED_MOBILE_ONLY=true
fi
CHANGED_DOCS=$(echo $CHANGED_PATHS | jq '. as $A | "docs" | IN($A[])')
if [[ $CHANGED_DOCS == true && $CHANGED_PATH_COUNT -eq 1 ]]; then
CHANGED_DOCS_ONLY=true
fi
CHANGED_EXAMPLES=$(echo $CHANGED_PATHS | jq '. as $A | "examples" | IN($A[])')
if [[ $CHANGED_EXAMPLES == true && $CHANGED_PATH_COUNT -eq 1 ]]; then
CHANGED_EXAMPLES_ONLY=true
fi
echo "##vso[task.setvariable variable=mobileOnly;isoutput=true]${CHANGED_MOBILE_ONLY}"
echo "##vso[task.setvariable variable=docsOnly;isoutput=true]${CHANGED_DOCS_ONLY}"
echo "##vso[task.setvariable variable=examplesOnly;isoutput=true]${CHANGED_EXAMPLES_ONLY}"
displayName: "Detect repo changes"
workingDirectory: $(Build.SourcesDirectory)
name: changed
- bash: |
set -e
VERSION_DEV="$(cat VERSION.txt | cut -d- -f2)"
VERSION_PATCH="$(cat VERSION.txt | cut -d- -f1 | rev | cut -d. -f1 | rev)"
echo "##vso[task.setvariable variable=versionPatch;isoutput=true]$VERSION_PATCH"
if [[ $VERSION_DEV == "dev" ]]; then
echo "##vso[task.setvariable variable=isDev;isoutput=true]true"
else
if [[ $(Build.Reason) == "PullRequest" ]]; then
# Check to make sure that it was this PR that changed the version, otherwise fail
# as the branch needs to be reopened first.
# NB: this will not stop a PR that has already passed checks from being landed.
DIFF_TARGET_BRANCH="origin/$(System.PullRequest.TargetBranch)"
DIFF_REF="$(git merge-base HEAD "${DIFF_TARGET_BRANCH}")"
CHANGES="$(git diff "$DIFF_REF" HEAD VERSION.txt)"
if [[ -z "$CHANGES" ]]; then
echo "VERSION.txt is not a development version. Please re-open the branch before making further changes" >&2
exit 1
fi
fi
echo "##vso[task.setvariable variable=isDev;isoutput=true]false"
fi
displayName: Set development/release env
name: state
- bash: |
# TODO(phlax): move this to a script to ensure proper linting etc
set -e
# Run everything in postsubmit
if [[ "$(Build.Reason)" != "PullRequest" ]]; then
echo "##vso[task.setvariable variable=build;isoutput=true]true"
echo "##vso[task.setvariable variable=checks;isoutput=true]true"
echo "##vso[task.setvariable variable=docker;isoutput=true]true"
echo "##vso[task.setvariable variable=packaging;isoutput=true]true"
exit 0
fi
RUN_BUILD=true
RUN_CHECKS=true
RUN_DOCKER=true
RUN_PACKAGING=true
RUN_RELEASE_TESTS=true
if [[ "$(changed.mobileOnly)" == true || "$(changed.docsOnly)" == true ]]; then
RUN_BUILD=false
RUN_DOCKER=false
fi
if [[ "$(changed.mobileOnly)" == true || "$(changed.docsOnly)" == true ]]; then
RUN_CHECKS=false
RUN_PACKAGING=false
fi
if [[ "$(changed.examplesOnly)" == true ]]; then
RUN_CHECKS=false
fi
if [[ "$ISSTABLEBRANCH" == True && -n "$POSTSUBMIT" && "$(state.isDev)" == false ]]; then
RUN_RELEASE_TESTS=false
fi
echo "##vso[task.setvariable variable=build;isoutput=true]${RUN_BUILD}"
echo "##vso[task.setvariable variable=checks;isoutput=true]${RUN_CHECKS}"
echo "##vso[task.setvariable variable=docker;isoutput=true]${RUN_DOCKER}"
echo "##vso[task.setvariable variable=packaging;isoutput=true]${RUN_PACKAGING}"
echo "##vso[task.setvariable variable=releaseTests;isoutput=true]${RUN_RELEASE_TESTS}"
displayName: "Decide what to run"
workingDirectory: $(Build.SourcesDirectory)
name: run
- bash: |
# TODO(phlax): move this to a script to ensure proper linting etc
set -e
PUBLISH_GITHUB_RELEASE=$(run.packaging)
PUBLISH_DOCKERHUB=false
if [[ "$ISSTABLEBRANCH" == True && -n "$POSTSUBMIT" && "$NOSYNC" != true ]]; then
# main
if [[ "$ISMAIN" == True ]]; then
# Update the Dockerhub README
PUBLISH_DOCKERHUB=true
# Not main, and not -dev
elif [[ "$(state.isDev)" == false ]]; then
if [[ "$(state.versionPatch)" -eq 0 ]]; then
# A just-forked branch
PUBLISH_GITHUB_RELEASE=false
fi
fi
fi
# Only run Envoy release CI if explictly set
if ([[ "$PRESUBMIT" != 'true' ]] && [[ "$POSTSUBMIT" != 'true' ]]) || [[ $(Build.Reason) == "Schedule" ]]; then
PUBLISH_GITHUB_RELEASE=false
fi
echo "##vso[task.setvariable variable=githubRelease;isoutput=true]${PUBLISH_GITHUB_RELEASE}"
echo "##vso[task.setvariable variable=dockerhub;isoutput=true]${PUBLISH_DOCKERHUB}"
displayName: "Decide what to publish"
workingDirectory: $(Build.SourcesDirectory)
name: publish
- bash: |
set -e
echo "env.outputs['changed.mobileOnly']: $(changed.mobileOnly)"
echo "env.outputs['changed.docsOnly']: $(changed.docsOnly)"
echo "env.outputs['changed.examplesOnly']: $(changed.examplesOnly)"
echo
echo "env.outputs['state.isDev']: $(state.isDev)"
echo "env.outputs['state.versionPatch']: $(state.versionPatch)"
echo
echo "env.outputs['run.build']: $(run.build)"
echo "env.outputs['run.checks']: $(run.checks)"
echo "env.outputs['run.packaging']: $(run.packaging)"
echo "env.outputs['run.releaseTests]: $(run.releaseTests)"
echo
echo "env.outputs['publish.githubRelease']: $(publish.githubRelease)"
echo "env.outputs['publish.dockerhub]: $(publish.dockerhub)"
displayName: "Print build environment"
- job: test_artifacts
dependsOn: []
displayName: Test artifacts
condition: ne(variables['Build.DefinitionName'], 'envoy-postsubmit')
pool:
vmImage: $(agentUbuntu)
steps:
- script: $(Build.SourcesDirectory)/.azure-pipelines/gpg/generate-test-key.sh
displayName: "Generate snakeoil GPG key for testing"
workingDirectory: $(Build.StagingDirectory)
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: "$(Build.StagingDirectory)/envoy"
artifactName: test.env
timeoutInMinutes: 10