@@ -40,10 +40,11 @@ def macrobenchmark():
40
40
async def _launch_macrobenchmark_test ():
41
41
_logger .info ('Starting macrobenchmark test...' )
42
42
43
- artifact_versions , config , _ = await asyncio .gather (
43
+ artifact_versions , config , _ , _ = await asyncio .gather (
44
44
_parse_artifact_versions (),
45
45
_parse_config_yaml (),
46
- _create_gradle_wrapper ()
46
+ _create_gradle_wrapper (),
47
+ _copy_google_services (),
47
48
)
48
49
49
50
with chdir ('macrobenchmark' ):
@@ -84,13 +85,21 @@ async def _create_gradle_wrapper():
84
85
'./gradlew' ,
85
86
'wrapper' ,
86
87
'--gradle-version' ,
87
- '7.0 ' ,
88
+ '6.9 ' ,
88
89
'--project-dir' ,
89
90
'macrobenchmark'
90
91
)
91
92
await proc .wait ()
92
93
93
94
95
+ async def _copy_google_services ():
96
+ if 'FIREBASE_CI' in os .environ :
97
+ src = os .environ ['FIREBASE_GOOGLE_SERVICES_PATH' ]
98
+ dst = 'macrobenchmark/template/app/google-services.json'
99
+ _logger .info (f'Running on CI. Copying "{ src } " to "{ dst } "...' )
100
+ shutil .copyfile (src , dst )
101
+
102
+
94
103
class MacrobenchmarkTest :
95
104
"""Builds the test based on configurations and runs the test on FTL."""
96
105
def __init__ (
@@ -117,19 +126,7 @@ async def _create_test_src(self):
117
126
app_id = self .test_app_config ['application-id' ]
118
127
self .logger .info (f'Creating test app "{ app_name } " with application-id "{ app_id } "...' )
119
128
120
- mustache_context = {
121
- 'application-id' : app_id ,
122
- 'plugins' : self .test_app_config ['plugins' ] if 'plugins' in self .test_app_config else [],
123
- 'dependencies' : [
124
- {
125
- 'key' : x ,
126
- 'version' : self .artifact_versions [x ]
127
- } for x in self .test_app_config ['dependencies' ]
128
- ] if 'dependencies' in self .test_app_config else [],
129
- }
130
-
131
- if app_name != 'baseline' :
132
- mustache_context ['plugins' ].append ('com.google.gms.google-services' )
129
+ mustache_context = await self ._prepare_mustache_context ()
133
130
134
131
shutil .copytree ('template' , self .test_app_dir )
135
132
with chdir (self .test_app_dir ):
@@ -172,6 +169,33 @@ async def _upload_apks_to_ftl(self):
172
169
173
170
await self ._exec_subprocess (executable , args )
174
171
172
+ async def _prepare_mustache_context (self ):
173
+ app_name = self .test_app_config ['name' ]
174
+ app_id = self .test_app_config ['application-id' ]
175
+
176
+ mustache_context = {
177
+ 'application-id' : app_id ,
178
+ 'plugins' : [],
179
+ 'dependencies' : [],
180
+ }
181
+
182
+ if app_name != 'baseline' :
183
+ mustache_context ['plugins' ].append ('com.google.gms.google-services' )
184
+
185
+ if 'plugins' in self .test_app_config :
186
+ mustache_context ['plugins' ].extend (self .test_app_config ['plugins' ])
187
+
188
+ if 'dependencies' in self .test_app_config :
189
+ for dep in self .test_app_config ['dependencies' ]:
190
+ if '@' in dep :
191
+ key , version = dep .split ('@' , 1 )
192
+ dependency = {'key' : key , 'version' : version }
193
+ else :
194
+ dependency = {'key' : dep , 'version' : self .artifact_versions [dep ]}
195
+ mustache_context ['dependencies' ].append (dependency )
196
+
197
+ return mustache_context
198
+
175
199
async def _exec_subprocess (self , executable , args ):
176
200
command = " " .join ([executable , * args ])
177
201
self .logger .info (f'Executing command: "{ command } "...' )
0 commit comments