Ejemplo n.º 1
0
def main():
  global FLAG_skip_wait_for_artifacts

  parser = argparse.ArgumentParser(description='Dart SDK autoroller for Flutter.')
  parser.add_argument('--dart-sdk-revision',
                      help='Provide a Dart SDK revision to roll instead of '
                        'choosing one automatically')
  parser.add_argument('--no-update-repos',
                      help='Skip cleaning and updating local repositories',
                      action='store_true')
  parser.add_argument('--skip-roll',
                      help='Skip running dart_roll_helper.py',
                      action='store_true')
  parser.add_argument('--skip-tests',
                      help='Skip running Flutter tests',
                      action='store_true')
  parser.add_argument('--skip-build',
                      help='Skip building all configurations',
                      action='store_true')
  parser.add_argument('--skip-update-deps',
                      help='Skip updating the Dart SDK dependencies',
                      action='store_true')
  parser.add_argument('--skip-wait-for-artifacts',
                      help="Don't wait for PR statuses to pass or for engine" +
                      " artifacts to be uploaded to the cloud",
                      action='store_true', default=False)
  parser.add_argument('--skip-update-licenses',
                      help='Skip updating the licenses for the Flutter engine',
                      action='store_true')
  parser.add_argument('--skip-pull-request',
                      help="Skip creating a pull request and don't commit",
                      action='store_true')

  args = parser.parse_args()
  FLAG_skip_wait_for_artifacts = args.skip_wait_for_artifacts
  github_api_key = os.getenv('GITHUB_API_KEY')
  dart_sdk_path  = os.getenv('DART_SDK_HOME')
  flutter_path   = os.getenv('FLUTTER_HOME')
  engine_path    = os.getenv('ENGINE_HOME')
  local_dart_sdk_repo       = Repo(dart_sdk_path)
  local_flutter_repo        = Repo(flutter_path)
  local_engine_flutter_repo = Repo(os.path.join(engine_path, 'flutter'))
  assert(not local_dart_sdk_repo.bare)
  assert(not local_flutter_repo.bare)
  assert(not local_engine_flutter_repo.bare)

  github = Github(github_api_key)
  github_engine_repo  = github.get_repo('flutter/engine')
  github_flutter_repo = github.get_repo('flutter/flutter')

  atexit.register(cleanup_children)
  signal.signal(signal.SIGTERM, sys_exit)

  if not args.no_update_repos:
    print_status('Cleaning and updating local trees...')
    clean_and_update_repo(local_dart_sdk_repo)
    clean_and_update_repo(local_flutter_repo)
    clean_and_update_repo(local_engine_flutter_repo)
  else:
    print_warning('Skipping cleaning and updating of local trees')

  # Use the most recent Dart SDK commit for the roll.
  if not args.skip_roll:
    print_status('Starting Dart roll helper')
    most_recent_commit = ''
    dart_roll_helper_args = []
    if args.skip_update_deps:
      dart_roll_helper_args.append('--no-update-deps')
    elif args.dart_sdk_revision != None:
      most_recent_commit = args.dart_sdk_revision
    else:
      # Get the most recent commit that is a reasonable candidate.
      most_recent_commit = get_most_recent_green_build()
    if args.skip_tests:
      dart_roll_helper_args.append('--no-test')
    if args.skip_build:
      dart_roll_helper_args.append('--no-build')
    if args.skip_update_licenses:
      dart_roll_helper_args.append('--no-update-licenses')
    if not args.skip_pull_request:
      dart_roll_helper_args.append('--create-commit')


    # Will exit with code ERROR_OLD_COMMIT_PROVIDED if `most_recent_commit` is
    # older than the current revision of the SDK used by Flutter.
    result = run_dart_roll_helper(most_recent_commit, dart_roll_helper_args)
    if result != 0:
      sys.exit(result)
  else:
    print_warning('Skipping roll step!')

  if not args.skip_pull_request:
    # If the local roll was successful, try to merge into the engine.
    print_status('Creating flutter/engine pull request')
    current_date = datetime.datetime.today().strftime('%Y-%m-%d')

    try:
      pr = create_pull_request(github_engine_repo,
                          local_engine_flutter_repo,
                          get_pr_title(local_engine_flutter_repo),
                          'dart-sdk-roll-{}'.format(current_date))
    except DartAutorollerException as e:
      print_error(('Error while creating flutter/engine pull request: {}.'
                   ' Aborting roll.').format(e))
      sys.exit(1)

    print_status('Waiting for PR checks to complete...')
    merge_on_success(github_engine_repo, local_engine_flutter_repo, pr)
    print_status('PR checks complete!')
  else:
    print_warning('Not creating flutter/engine PR!')

  # TODO(bkonyi): uncomment if we decide to roll the engine into the framework.
  # print_status('Starting roll of flutter/engine into flutter/flutter')
  # If the roll into the engine succeeded, prep the roll into the framework.
  # run_engine_roll_helper(local_engine_flutter_repo,
  #                        flutter_path,
  #                        local_flutter_repo,
  #                        github_flutter_repo)

  # Status code should be 0 anyway, but let's make sure our exit status is
  # consistent throughout the tool on a successful roll.
  sys.exit(ERROR_ROLL_SUCCESS)
Ejemplo n.º 2
0
def main():
    global CURRENT_PR
    global FLAG_skip_wait_for_artifacts
    global GITHUB_ENGINE_REPO
    global GITHUB_ENGINE_FORK

    parser = argparse.ArgumentParser(
        description='Dart SDK autoroller for Flutter.')
    parser.add_argument('--dart-sdk-revision',
                        help='Provide a Dart SDK revision to roll instead of '
                        'choosing one automatically')
    parser.add_argument('--no-update-repos',
                        help='Skip cleaning and updating local repositories',
                        action='store_true')
    parser.add_argument('--skip-roll',
                        help='Skip running dart_roll_helper.py',
                        action='store_true')
    parser.add_argument('--skip-tests',
                        help='Skip running Flutter tests',
                        action='store_true')
    parser.add_argument('--skip-build',
                        help='Skip building all configurations',
                        action='store_true')
    parser.add_argument('--skip-update-deps',
                        help='Skip updating the Dart SDK dependencies',
                        action='store_true')
    parser.add_argument(
        '--skip-wait-for-artifacts',
        help="Don't wait for PR statuses to pass or for engine" +
        " artifacts to be uploaded to the cloud",
        action='store_true',
        default=False)
    parser.add_argument(
        '--skip-update-licenses',
        help='Skip updating the licenses for the Flutter engine',
        action='store_true')
    parser.add_argument('--skip-pull-request',
                        help="Skip creating a pull request and don't commit",
                        action='store_true')

    args = parser.parse_args()
    FLAG_skip_wait_for_artifacts = args.skip_wait_for_artifacts
    github_api_key = os.getenv('GITHUB_API_KEY')
    dart_sdk_path = os.getenv('DART_SDK_HOME')
    flutter_path = os.getenv('FLUTTER_HOME')
    engine_path = os.getenv('ENGINE_HOME')
    engine_fork = os.getenv('ENGINE_FORK')
    local_dart_sdk_repo = Repo(dart_sdk_path)
    local_flutter_repo = Repo(flutter_path)
    local_engine_flutter_repo = Repo(os.path.join(engine_path, 'flutter'))
    assert (not local_dart_sdk_repo.bare)
    assert (not local_flutter_repo.bare)
    assert (not local_engine_flutter_repo.bare)

    github = Github(github_api_key)
    GITHUB_ENGINE_REPO = github.get_repo('flutter/engine')
    GITHUB_ENGINE_FORK = github.get_repo(engine_fork)
    github_flutter_repo = github.get_repo('flutter/flutter')

    atexit.register(cleanup_children)
    signal.signal(signal.SIGTERM, sys_exit)

    if not args.no_update_repos:
        print_status('Cleaning and updating local trees...')
        clean_build_outputs()
        clean_and_update_repo(local_dart_sdk_repo)
        clean_and_update_repo(local_flutter_repo)
        clean_and_update_forked_repo(local_engine_flutter_repo)
    else:
        print_warning('Skipping cleaning and updating of local trees')

    # Use the most recent Dart SDK commit for the roll.
    if not args.skip_roll:
        print_status('Starting Dart roll helper')
        most_recent_commit = ''
        dart_roll_helper_args = []
        if args.skip_update_deps:
            dart_roll_helper_args.append('--no-update-deps')
        elif args.dart_sdk_revision != None:
            most_recent_commit = args.dart_sdk_revision
        else:
            # Get the most recent commit that is a reasonable candidate.
            most_recent_commit = get_most_recent_green_build()
        if args.skip_tests:
            dart_roll_helper_args.append('--no-test')
        if args.skip_build:
            dart_roll_helper_args.append('--no-build')
        if args.skip_update_licenses:
            dart_roll_helper_args.append('--no-update-licenses')
        if not args.skip_pull_request:
            dart_roll_helper_args.append('--create-commit')

        # Will exit with code ERROR_OLD_COMMIT_PROVIDED if `most_recent_commit` is
        # older than the current revision of the SDK used by Flutter.
        result = run_dart_roll_helper(most_recent_commit,
                                      dart_roll_helper_args)
        if result != 0:
            sys.exit(result)
    else:
        print_warning('Skipping roll step!')

    if not args.skip_pull_request:
        # If the local roll was successful, try to merge into the engine.
        print_status('Creating flutter/engine pull request')
        current_date = datetime.datetime.today().strftime('%Y-%m-%d')

        try:
            CURRENT_PR = create_pull_request(
                GITHUB_ENGINE_REPO, local_engine_flutter_repo,
                get_pr_title(local_engine_flutter_repo),
                'dart-sdk-roll-{}'.format(current_date))
        except DartAutorollerException as e:
            print_error(
                ('Error while creating flutter/engine pull request: {}.'
                 ' Aborting roll.').format(e))
            sys.exit(1)

        print_status('Waiting for PR checks to complete...')
        merge_on_success(GITHUB_ENGINE_REPO, local_engine_flutter_repo,
                         CURRENT_PR)
        print_status('PR checks complete!')
        CURRENT_PR = None
    else:
        print_warning('Not creating flutter/engine PR!')

    # TODO(bkonyi): uncomment if we decide to roll the engine into the framework.
    # print_status('Starting roll of flutter/engine into flutter/flutter')
    # If the roll into the engine succeeded, prep the roll into the framework.
    # run_engine_roll_helper(local_engine_flutter_repo,
    #                        flutter_path,
    #                        local_flutter_repo,
    #                        github_flutter_repo)

    # Status code should be 0 anyway, but let's make sure our exit status is
    # consistent throughout the tool on a successful roll.
    sys.exit(ERROR_ROLL_SUCCESS)