Skip to content

Commit 1fba4a7

Browse files
authored
Configure google-services.json for macrobenchmark tests. (#2653)
* Copy google-services.json before tests run * Change gradle wrapper version to 6.9
1 parent f23b397 commit 1fba4a7

File tree

2 files changed

+41
-16
lines changed

2 files changed

+41
-16
lines changed

ci/fireci/fireciplugins/macrobenchmark.py

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ def macrobenchmark():
4040
async def _launch_macrobenchmark_test():
4141
_logger.info('Starting macrobenchmark test...')
4242

43-
artifact_versions, config, _ = await asyncio.gather(
43+
artifact_versions, config, _, _ = await asyncio.gather(
4444
_parse_artifact_versions(),
4545
_parse_config_yaml(),
46-
_create_gradle_wrapper()
46+
_create_gradle_wrapper(),
47+
_copy_google_services(),
4748
)
4849

4950
with chdir('macrobenchmark'):
@@ -84,13 +85,21 @@ async def _create_gradle_wrapper():
8485
'./gradlew',
8586
'wrapper',
8687
'--gradle-version',
87-
'7.0',
88+
'6.9',
8889
'--project-dir',
8990
'macrobenchmark'
9091
)
9192
await proc.wait()
9293

9394

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+
94103
class MacrobenchmarkTest:
95104
"""Builds the test based on configurations and runs the test on FTL."""
96105
def __init__(
@@ -117,19 +126,7 @@ async def _create_test_src(self):
117126
app_id = self.test_app_config['application-id']
118127
self.logger.info(f'Creating test app "{app_name}" with application-id "{app_id}"...')
119128

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()
133130

134131
shutil.copytree('template', self.test_app_dir)
135132
with chdir(self.test_app_dir):
@@ -172,6 +169,33 @@ async def _upload_apks_to_ftl(self):
172169

173170
await self._exec_subprocess(executable, args)
174171

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+
175199
async def _exec_subprocess(self, executable, args):
176200
command = " ".join([executable, *args])
177201
self.logger.info(f'Executing command: "{command}"...')

macrobenchmark/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ firebase-inappmessaging-display:
4444
name: inappmessaging
4545
application-id: com.google.firebase.benchmark.inappmessaging
4646
dependencies:
47+
- com.google.firebase:[email protected]
4748
- com.google.firebase:firebase-inappmessaging-ktx
4849
- com.google.firebase:firebase-inappmessaging-display-ktx
4950

0 commit comments

Comments
 (0)