<commit_before># Roll versions script:
# /src/mojo/src/sky/apk/demo/AndroidManifest.xml version and string.
# Update versions of pub packages:

# Make a commit, upload it, land it.

import os
import subprocess

def run(cwd, args):
    print 'RUNNING:', ' '.join(args), 'IN:', cwd
    subprocess.check_call(args, cwd=cwd)

# Input paths:
# FIXME: These could be args?
MOJO_ROOT = '/src/mojo/src'
SKY_SDK_ROOT = '/src/sky_sdk'
DEMO_SITE_ROOT = '/src/domokit.github.io'

# Derived paths:
DART_SDK_ROOT = os.path.join(MOJO_ROOT, 'third_party/dart-sdk/dart-sdk')
PUB_PATH = os.path.join(DART_SDK_ROOT, 'bin/pub')
PACKAGES_ROOT = os.path.join(SKY_SDK_ROOT, 'packages')


run(MOJO_ROOT, ['git', 'pull', '--rebase'])
run(MOJO_ROOT, ['gclient', 'sync'])
run(MOJO_ROOT, ['mojo/tools/mojob.py', 'gn', '--android', '--release'])
run(MOJO_ROOT, ['mojo/tools/mojob.py', 'build', '--android', '--release'])
# Run tests?

run(SKY_SDK_ROOT, ['git', 'reset', '--hard', 'origin/master'])
run(MOJO_ROOT, [
    'sky/tools/deploy_sdk.py',
    '--non-interactive',
    '--commit',
    SKY_SDK_ROOT
])
# tag for version?

run(DEMO_SITE_ROOT, ['git', 'reset', '--hard', 'origin/master'])
run(MOJO_ROOT, ['mojo/tools/deploy_domokit_site.py', DEMO_SITE_ROOT])
# tag for version?

for package in os.listdir(PACKAGES_ROOT):
    package_path = os.path.join(PACKAGES_ROOT, package)
    if not os.path.isdir(package_path):
        continue
    run(package_path, [PUB_PATH, 'publish', '--force'])

run(SKY_SDK_ROOT, ['git', 'push'])
run(DEMO_SITE_ROOT, ['git', 'push'])

# http://stackoverflow.com/questions/14665518/api-to-automatically-upload-apk-to-google-play
# https://developers.google.com/resources/api-libraries/documentation/androidpublisher/v2/python/latest/androidpublisher_v2.edits.apks.html<commit_msg>Allow big_red_button to take path arguments<commit_after># Roll versions script:
# /src/mojo/src/sky/apk/demo/AndroidManifest.xml version and string.
# Update versions of pub packages:

# Make a commit, upload it, land it.

# Useful links:
# http://stackoverflow.com/questions/14665518/api-to-automatically-upload-apk-to-google-play
# https://developers.google.com/resources/api-libraries/documentation/androidpublisher/v2/python/latest/androidpublisher_v2.edits.apks.html

import argparse
import os
import subprocess

DEFAULT_MOJO_ROOT = '/src/mojo/src'
DEFAULT_SKY_SDK_ROOT = '/src/sky_sdk'
DEFAULT_DEMO_SITE_ROOT = '/src/domokit.github.io'

def run(cwd, args):
    print 'RUNNING:', ' '.join(args), 'IN:', cwd
    subprocess.check_call(args, cwd=cwd)


def main():
    parser = argparse.ArgumentParser(description='Deploy!')
    parser.add_argument('--mojo-root',
                        action='store',
                        type=str,
                        metavar='mojo_root',
                        help='Path to mojo/src',
                        default=DEFAULT_MOJO_ROOT)
    parser.add_argument('--sky-sdk-root',
                        action='store',
                        type=str,
                        metavar='sky_sdk_root',
                        help='Path to sky_sdk',
                        default=DEFAULT_SKY_SDK_ROOT)
    parser.add_argument('--demo-site-root',
                        action='store',
                        type=str,
                        metavar='demo_site_root',
                        help='Path to domokit.github.io',
                        default=DEFAULT_DEMO_SITE_ROOT)
    args = parser.parse_args()

    mojo_root = args.mojo_root
    sky_sdk_root = args.sky_sdk_root
    demo_site_root = args.demo_site_root

    # Derived paths:
    dart_sdk_root = os.path.join(mojo_root, 'third_party/dart-sdk/dart-sdk')
    pub_path = os.path.join(dart_sdk_root, 'bin/pub')
    packages_root = os.path.join(sky_sdk_root, 'packages')

    run(mojo_root, ['git', 'pull', '--rebase'])
    run(mojo_root, ['gclient', 'sync'])
    run(mojo_root, ['mojo/tools/mojob.py', 'gn', '--android', '--release'])
    run(mojo_root, ['mojo/tools/mojob.py', 'build', '--android', '--release'])
    # Run tests?

    run(sky_sdk_root, ['git', 'reset', '--hard', 'origin/master'])
    run(mojo_root, [
        'sky/tools/deploy_sdk.py',
        '--non-interactive',
        '--commit',
        sky_sdk_root
    ])
    # tag for version?

    run(demo_site_root, ['git', 'reset', '--hard', 'origin/master'])
    run(mojo_root, ['mojo/tools/deploy_domokit_site.py', demo_site_root])
    # tag for version?

    for package in os.listdir(packages_root):
        package_path = os.path.join(packages_root, package)
        if not os.path.isdir(package_path):
            continue
        run(package_path, [pub_path, 'publish', '--force'])

    run(sky_sdk_root, ['git', 'push'])
    run(demo_site_root, ['git', 'push'])


if __name__ == '__main__':
    sys.exit(main())
{'fraction_non_alphanumeric': 0.15868701651683045, 'fraction_numerical': 0.004181476061049551, 'mean_word_length': 3.0508044030482644, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3793309', 'n_tokens_mistral': 1735, 'n_tokens_neox': 1680, 'n_words': 289}