Skip to content

Configure google-services.json for macrobenchmark tests. #2653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 40 additions & 16 deletions ci/fireci/fireciplugins/macrobenchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ def macrobenchmark():
async def _launch_macrobenchmark_test():
_logger.info('Starting macrobenchmark test...')

artifact_versions, config, _ = await asyncio.gather(
artifact_versions, config, _, _ = await asyncio.gather(
_parse_artifact_versions(),
_parse_config_yaml(),
_create_gradle_wrapper()
_create_gradle_wrapper(),
_copy_google_services(),
)

with chdir('macrobenchmark'):
Expand Down Expand Up @@ -84,13 +85,21 @@ async def _create_gradle_wrapper():
'./gradlew',
'wrapper',
'--gradle-version',
'7.0',
'6.9',
'--project-dir',
'macrobenchmark'
)
await proc.wait()


async def _copy_google_services():
if 'FIREBASE_CI' in os.environ:
src = os.environ['FIREBASE_GOOGLE_SERVICES_PATH']
dst = 'macrobenchmark/template/app/google-services.json'
_logger.info(f'Running on CI. Copying "{src}" to "{dst}"...')
shutil.copyfile(src, dst)


class MacrobenchmarkTest:
"""Builds the test based on configurations and runs the test on FTL."""
def __init__(
Expand All @@ -117,19 +126,7 @@ async def _create_test_src(self):
app_id = self.test_app_config['application-id']
self.logger.info(f'Creating test app "{app_name}" with application-id "{app_id}"...')

mustache_context = {
'application-id': app_id,
'plugins': self.test_app_config['plugins'] if 'plugins' in self.test_app_config else [],
'dependencies': [
{
'key': x,
'version': self.artifact_versions[x]
} for x in self.test_app_config['dependencies']
] if 'dependencies' in self.test_app_config else [],
}

if app_name != 'baseline':
mustache_context['plugins'].append('com.google.gms.google-services')
mustache_context = await self._prepare_mustache_context()

shutil.copytree('template', self.test_app_dir)
with chdir(self.test_app_dir):
Expand Down Expand Up @@ -172,6 +169,33 @@ async def _upload_apks_to_ftl(self):

await self._exec_subprocess(executable, args)

async def _prepare_mustache_context(self):
app_name = self.test_app_config['name']
app_id = self.test_app_config['application-id']

mustache_context = {
'application-id': app_id,
'plugins': [],
'dependencies': [],
}

if app_name != 'baseline':
mustache_context['plugins'].append('com.google.gms.google-services')

if 'plugins' in self.test_app_config:
mustache_context['plugins'].extend(self.test_app_config['plugins'])

if 'dependencies' in self.test_app_config:
for dep in self.test_app_config['dependencies']:
if '@' in dep:
key, version = dep.split('@', 1)
dependency = {'key': key, 'version': version}
else:
dependency = {'key': dep, 'version': self.artifact_versions[dep]}
mustache_context['dependencies'].append(dependency)

return mustache_context

async def _exec_subprocess(self, executable, args):
command = " ".join([executable, *args])
self.logger.info(f'Executing command: "{command}"...')
Expand Down
1 change: 1 addition & 0 deletions macrobenchmark/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ firebase-inappmessaging-display:
name: inappmessaging
application-id: com.google.firebase.benchmark.inappmessaging
dependencies:
- com.google.firebase:[email protected]
- com.google.firebase:firebase-inappmessaging-ktx
- com.google.firebase:firebase-inappmessaging-display-ktx

Expand Down