Debian Codegraph @

.evergreen/legacy_config_generator/evergreen_config_lib/functions.py

raw
1 # Copyright 2009-present MongoDB, Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 from collections import OrderedDict as OD
16
17 from evergreen_config_generator.functions import Function, s3_put
18
19 from evergreen_config_lib import shell_mongoc
20
21 build_path = '${build_variant}/${revision}/${version_id}/${build_id}'
22
23 all_functions = OD(
24 [
25 (
26 'install ssl',
27 Function(
28 shell_mongoc(
29 '.evergreen/scripts/install-ssl.sh',
30 test=False,
31 add_expansions_to_env=True,
32 ),
33 ),
34 ),
35 (
36 'upload coverage',
37 Function(
38 shell_mongoc(
39 r"""
40 export AWS_ACCESS_KEY_ID=${aws_key}
41 export AWS_SECRET_ACCESS_KEY=${aws_secret}
42 aws s3 cp coverage s3://mciuploads/${project}/%s/coverage/ --recursive --acl public-read --region us-east-1
43 """
44 % (build_path,),
45 test=False,
46 silent=True,
47 ),
48 s3_put(
49 build_path + '/coverage/index.html',
50 aws_key='${aws_key}',
51 aws_secret='${aws_secret}',
52 local_file='mongoc/coverage/index.html',
53 bucket='mciuploads',
54 permissions='public-read',
55 content_type='text/html',
56 display_name='Coverage Report',
57 ),
58 ),
59 ),
60 (
61 'upload scan artifacts',
62 Function(
63 shell_mongoc(
64 r"""
65 if find scan -name \*.html | grep -q html; then
66 (cd scan && find . -name index.html -exec echo "<li><a href='{}'>{}</a></li>" \;) >> scan.html
67 else
68 echo "No issues found" > scan.html
69 fi
70 """,
71 ),
72 shell_mongoc(
73 r"""
74 export AWS_ACCESS_KEY_ID=${aws_key}
75 export AWS_SECRET_ACCESS_KEY=${aws_secret}
76 aws s3 cp scan s3://mciuploads/${project}/%s/scan/ --recursive --acl public-read --region us-east-1
77 """
78 % (build_path,),
79 test=False,
80 silent=True,
81 ),
82 s3_put(
83 build_path + '/scan/index.html',
84 aws_key='${aws_key}',
85 aws_secret='${aws_secret}',
86 local_file='mongoc/scan.html',
87 bucket='mciuploads',
88 permissions='public-read',
89 content_type='text/html',
90 display_name='Scan Build Report',
91 ),
92 ),
93 ),
94 # Use "silent=True" to hide output since errors may contain credentials.
95 (
96 'run auth tests',
97 Function(
98 shell_mongoc(
99 '.evergreen/scripts/run-auth-tests.sh',
100 add_expansions_to_env=True,
101 ),
102 ),
103 ),
104 (
105 'link sample program',
106 Function(
107 shell_mongoc(
108 r"""
109 # Compile a program that links dynamically or statically to libmongoc,
110 # using variables from pkg-config or CMake's find_package command.
111 export BUILD_SAMPLE_WITH_CMAKE=${BUILD_SAMPLE_WITH_CMAKE}
112 export ENABLE_SSL=${ENABLE_SSL}
113 export ENABLE_SNAPPY=${ENABLE_SNAPPY}
114 LINK_STATIC= .evergreen/scripts/link-sample-program.sh
115 LINK_STATIC=1 .evergreen/scripts/link-sample-program.sh
116 """,
117 include_expansions_in_env=['distro_id'],
118 ),
119 ),
120 ),
121 (
122 'link sample program bson',
123 Function(
124 shell_mongoc(
125 r"""
126 # Compile a program that links dynamically or statically to libbson,
127 # using variables from pkg-config or from CMake's find_package command.
128 BUILD_SAMPLE_WITH_CMAKE= LINK_STATIC= .evergreen/scripts/link-sample-program-bson.sh
129 BUILD_SAMPLE_WITH_CMAKE= LINK_STATIC=1 .evergreen/scripts/link-sample-program-bson.sh
130 BUILD_SAMPLE_WITH_CMAKE=1 LINK_STATIC= .evergreen/scripts/link-sample-program-bson.sh
131 BUILD_SAMPLE_WITH_CMAKE=1 LINK_STATIC=1 .evergreen/scripts/link-sample-program-bson.sh
132 """,
133 include_expansions_in_env=['distro_id'],
134 ),
135 ),
136 ),
137 (
138 'link sample program MSVC',
139 Function(
140 shell_mongoc(
141 r"""
142 # Build libmongoc with CMake and compile a program that links
143 # dynamically or statically to it, using variables from CMake's
144 # find_package command.
145 export ENABLE_SSL=${ENABLE_SSL}
146 export ENABLE_SNAPPY=${ENABLE_SNAPPY}
147 LINK_STATIC= cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc.cmd
148 LINK_STATIC=1 cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc.cmd
149 """,
150 )
151 ),
152 ),
153 (
154 'link sample program mingw',
155 Function(
156 shell_mongoc(
157 r"""
158 # Build libmongoc with CMake and compile a program that links
159 # dynamically to it, using variables from pkg-config.exe.
160 PATH="/cygdrive/c/ProgramData/chocolatey/lib/winlibs/tools/mingw64/bin:$PATH" # mingw-w64 GCC
161 cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-mingw.cmd
162 """,
163 )
164 ),
165 ),
166 (
167 'link sample program MSVC bson',
168 Function(
169 shell_mongoc(
170 r"""
171 # Build libmongoc with CMake and compile a program that links
172 # dynamically or statically to it, using variables from CMake's
173 # find_package command.
174 export ENABLE_SSL=${ENABLE_SSL}
175 export ENABLE_SNAPPY=${ENABLE_SNAPPY}
176 LINK_STATIC= cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc-bson.cmd
177 LINK_STATIC=1 cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-msvc-bson.cmd
178 """,
179 )
180 ),
181 ),
182 (
183 'link sample program mingw bson',
184 Function(
185 shell_mongoc(
186 r"""
187 # Build libmongoc with CMake and compile a program that links
188 # dynamically to it, using variables from pkg-config.exe.
189 PATH="/cygdrive/c/ProgramData/chocolatey/lib/winlibs/tools/mingw64/bin:$PATH" # mingw-w64 GCC
190 cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-mingw-bson.cmd
191 """,
192 )
193 ),
194 ),
195 (
196 'update codecov.io',
197 Function(
198 shell_mongoc(
199 r"""
200 # Note: coverage is currently only enabled on the ubuntu1804 distro.
201 # This script does not support MacOS, Windows, or non-x86_64 distros.
202 # Update accordingly if code coverage is expanded to other distros.
203 curl -Os https://uploader.codecov.io/latest/linux/codecov
204 chmod +x codecov
205 # -Z: Exit with a non-zero value if error.
206 # -g: Run with gcov support.
207 # -t: Codecov upload token.
208 # perl: filter verbose "Found" list and "Processing" messages.
209 ./codecov -Zgt "${codecov_token}" | perl -lne 'print if not m|^.*\.gcov(\.\.\.)?$|'
210 """,
211 test=False,
212 ),
213 ),
214 ),
215 (
216 'compile coverage',
217 Function(
218 shell_mongoc(
219 'COVERAGE=ON .evergreen/scripts/compile.sh',
220 add_expansions_to_env=True,
221 ),
222 ),
223 ),
224 (
225 'run aws tests',
226 Function(
227 # Assume role to get AWS secrets.
228 {'command': 'ec2.assume_role', 'params': {'role_arn': '${aws_test_secrets_role}'}},
229 shell_mongoc(
230 r"""
231 pushd ../drivers-evergreen-tools/.evergreen/auth_aws
232 ./setup_secrets.sh drivers/aws_auth
233 popd # ../drivers-evergreen-tools/.evergreen/auth_aws
234 """,
235 include_expansions_in_env=['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AWS_SESSION_TOKEN'],
236 ),
237 shell_mongoc(
238 r"""
239 pushd ../drivers-evergreen-tools/.evergreen/auth_aws
240 . ./activate-authawsvenv.sh
241 popd # ../drivers-evergreen-tools/.evergreen/auth_aws
242 .evergreen/scripts/run-aws-tests.sh
243 """,
244 include_expansions_in_env=['TESTCASE'],
245 ),
246 ),
247 ),
248 ]
249 )