Example #1
0
def BuildAndTestAar(use_goma, skip_tests, build_dir):
  version = '1.0.' + _GetCommitPos()
  commit = _GetCommitHash()
  logging.info('Building and Testing AAR version %s with hash %s', version,
               commit)

  # If build directory is not specified, create a temporary directory.
  use_tmp_dir = not build_dir
  if use_tmp_dir:
    build_dir = tempfile.mkdtemp()

  try:
    base_name = ARTIFACT_ID + '-' + version
    aar_file = os.path.join(build_dir, base_name + '.aar')

    logging.info('Building at %s', build_dir)
    BuildAar(ARCHS,
             aar_file,
             use_goma=use_goma,
             ext_build_dir=os.path.join(build_dir, 'aar-build'))

    tests_pass = skip_tests or _TestAAR(build_dir)
    if not tests_pass:
      raise Exception('Test failure.')

    logging.info('Test success.')

  finally:
    if use_tmp_dir:
      shutil.rmtree(build_dir, True)
Example #2
0
def ReleaseAar(use_goma):
  version = '1.0.' + _GetCommitPos()
  commit = _GetCommitHash()
  logging.info('Releasing AAR version %s with hash %s', version, commit)

  user = os.environ.get('BINTRAY_USER', None)
  api_key = os.environ.get('BINTRAY_API_KEY', None)
  if not user or not api_key:
    raise Exception('Environment variables BINTRAY_USER and BINTRAY_API_KEY '
                    'must be defined.')

  tmp_dir = tempfile.mkdtemp()

  try:
    base_name = ARTIFACT_ID + '-' + version
    aar_file = os.path.join(tmp_dir, base_name + '.aar')
    third_party_licenses_file = os.path.join(tmp_dir, 'LICENSE.md')
    pom_file = os.path.join(tmp_dir, base_name + '.pom')

    logging.info('Building at %s', tmp_dir)
    BuildAar(ARCHS, aar_file,
             use_goma=use_goma,
             ext_build_dir=os.path.join(tmp_dir, 'aar-build'))
    _GeneratePom(pom_file, version, commit)

    _UploadFile(user, api_key, aar_file, version, base_name + '.aar')
    _UploadFile(user, api_key, third_party_licenses_file, version,
                'THIRD_PARTY_LICENSES.md')
    _UploadFile(user, api_key, pom_file, version, base_name + '.pom')
  finally:
    shutil.rmtree(tmp_dir, True)

  logging.info('Library successfully uploaded. Please test and publish it on '
               'Bintray.')
Example #3
0
def ReleaseAar(use_goma, skip_tests, publish, build_dir):
    version = '1.0.' + _GetCommitPos()
    commit = _GetCommitHash()
    logging.info('Releasing AAR version %s with hash %s', version, commit)

    user = os.environ.get('BINTRAY_USER', None)
    api_key = os.environ.get('BINTRAY_API_KEY', None)
    if not user or not api_key:
        raise Exception(
            'Environment variables BINTRAY_USER and BINTRAY_API_KEY '
            'must be defined.')

    # If build directory is not specified, create a temporary directory.
    use_tmp_dir = not build_dir
    if use_tmp_dir:
        build_dir = tempfile.mkdtemp()

    try:
        base_name = ARTIFACT_ID + '-' + version
        aar_file = os.path.join(build_dir, base_name + '.aar')
        third_party_licenses_file = os.path.join(build_dir, 'LICENSE.md')
        pom_file = os.path.join(build_dir, base_name + '.pom')

        logging.info('Building at %s', build_dir)
        BuildAar(ARCHS,
                 aar_file,
                 use_goma=use_goma,
                 ext_build_dir=os.path.join(build_dir, 'aar-build'))
        _GeneratePom(pom_file, version, commit)

        _UploadFile(user, api_key, aar_file, version, base_name + '.aar')
        _UploadFile(user, api_key, third_party_licenses_file, version,
                    'THIRD_PARTY_LICENSES.md')
        _UploadFile(user, api_key, pom_file, version, base_name + '.pom')

        tests_pass = skip_tests or _TestAAR(build_dir, user, api_key, version)
        if not tests_pass:
            logging.info('Discarding library.')
            _PublishAAR(user, api_key, version, {'discard': True})
            _DeleteUnpublishedVersion(user, api_key, version)
            raise Exception('Test failure. Discarded library.')

        if publish:
            logging.info('Publishing library.')
            _PublishAAR(user, api_key, version, {})
        else:
            logging.info(
                'Note: The library has not not been published automatically.'
                ' Please do so manually if desired.')
    finally:
        if use_tmp_dir:
            shutil.rmtree(build_dir, True)