Beispiel #1
0
async def async_main(context):
    android_product = task.extract_android_product_from_scopes(context)
    product_config = _get_product_config(context, android_product)
    publish_config = get_publish_config(product_config, context.task['payload'], android_product)
    contact_server = not bool(context.config.get('do_not_contact_server'))

    logging.getLogger('oauth2client').setLevel(logging.WARNING)
    _log_warning_forewords(contact_server, publish_config['dry_run'], publish_config['target_store'])

    log.info('Verifying upstream artifacts...')
    artifacts_per_task_id, failed_artifacts_per_task_id = artifacts.get_upstream_artifacts_full_paths_per_task_id(context)

    all_apks_paths = [
        artifact
        for artifacts_list in artifacts_per_task_id.values()
        for artifact in artifacts_list
        if artifact.endswith('.apk')
    ]

    if not publish_config.get('skip_check_signature', True):
        log.info('Verifying APKs\' signatures...')
        for apk_path in all_apks_paths:
            jarsigner.verify(context, publish_config, apk_path)
            manifest.verify(product_config, apk_path)
    else:
        log.info('This product is configured with "skip_check_signature", so the signing of the '
                 'APK will not be verified.')

    log.info('Delegating publication to mozapkpublisher...')
    with contextlib.ExitStack() as stack:
        files = [stack.enter_context(open(apk_file_name)) for apk_file_name in all_apks_paths]
        publish.publish(product_config, publish_config, files, contact_server)

    log.info('Done!')
 def test_craft_push_config_skip_checking_same_locales(self, mock_push_apk):
     product_config = {"skip_check_same_locales": True}
     publish(product_config,
             self.publish_config,
             self.apks,
             contact_server=True)
     _, args = mock_push_apk.call_args
     assert args["skip_check_same_locales"] is True
    def test_craft_push_config_allows_to_contact_google_play_or_not(
            self, mock_push_apk):
        publish({}, self.publish_config, self.apks, contact_server=True)
        _, args = mock_push_apk.call_args
        assert args['contact_server'] is True

        publish({}, self.publish_config, self.apks, False)
        _, args = mock_push_apk.call_args
        assert args['contact_server'] is False
 def test_craft_push_config_skip_checking_multiple_locales(
         self, mock_push_apk):
     product_config = {
         'skip_check_multiple_locales': True,
     }
     publish(product_config,
             self.publish_config,
             self.apks,
             contact_server=True)
     _, args = mock_push_apk.call_args
     assert args['skip_check_multiple_locales'] is True
 def test_craft_push_config_allows_committing_apks(self, mock_push_apk):
     publish_config = {
         'target_store': 'google',
         'dry_run': False,
         'google_track': 'beta',
         'package_names': ['org.mozilla.focus', 'org.mozilla.klar'],
         'username': '******',
         'secret': '/google_credentials.p12',
     }
     publish({}, publish_config, self.apks, contact_server=True)
     _, args = mock_push_apk.call_args
     assert args['dry_run'] is False
 def test_craft_push_config_allows_committing_apks(self, mock_push_apk):
     publish_config = {
         "target_store": "google",
         "dry_run": False,
         "google_track": "beta",
         "package_names": ["org.mozilla.focus", "org.mozilla.klar"],
         "username": "******",
         "secret": "/google_credentials.p12",
     }
     publish({}, publish_config, self.apks, contact_server=True)
     _, args = mock_push_apk.call_args
     assert args["dry_run"] is False
 def test_publish_allows_rollout_percentage(self, mock_push_apk):
     publish_config = {
         'target_store': 'google',
         'dry_run': True,
         'google_track': 'production',
         'google_rollout_percentage': 10,
         'package_names': ['org.mozilla.fennec_aurora'],
         'username': '******',
         'secret': '/google_credentials.p12',
     }
     publish({}, publish_config, self.apks, contact_server=True)
     _, args = mock_push_apk.call_args
     assert args['track'] == 'production'
     assert args['rollout_percentage'] == 10
 def test_publish_allows_rollout_percentage(self, mock_push_apk):
     publish_config = {
         "target_store": "google",
         "dry_run": True,
         "google_track": "production",
         "google_rollout_percentage": 10,
         "package_names": ["org.mozilla.fennec_aurora"],
         "username": "******",
         "secret": "/google_credentials.p12",
     }
     publish({}, publish_config, self.apks, contact_server=True)
     _, args = mock_push_apk.call_args
     assert args["track"] == "production"
     assert args["rollout_percentage"] == 10
    def test_publish_config(self, mock_push_apk):
        publish({}, self.publish_config, self.apks, contact_server=True)

        mock_push_apk.assert_called_with(
            apks=[
                MockFile('/path/to/x86.apk'),
                MockFile('/path/to/arm_v15.apk')
            ],
            target_store='google',
            username='******',
            secret='/google_credentials.p12',
            track='beta',
            expected_package_names=['org.mozilla.fennec_aurora'],
            rollout_percentage=None,
            dry_run=True,
            contact_server=True,
            skip_check_multiple_locales=False,
            skip_check_ordered_version_codes=False,
            skip_check_same_locales=False,
            skip_checks_fennec=False,
        )