def main():
    install_logging('Prepare_Content_Packs_For_Testing.log')
    packs_dir = '/home/runner/work/content-private/content-private/content/artifacts/packs'
    temp_dir = '/home/runner/work/content-private/content-private/content/temp-dir'
    if not os.path.exists(packs_dir):
        os.mkdir(packs_dir)
    if not os.path.exists(temp_dir):
        os.mkdir(temp_dir)
    upload_config = option_handler()
    path_to_artifacts = upload_config.artifacts_path
    extract_destination_path = upload_config.extract_path
    service_account = upload_config.service_account
    pack_name = upload_config.pack_names
    storage_base_path = upload_config.storage_base_path

    storage_client = init_storage_client(service_account)
    private_testing_bucket_client = storage_client.bucket(
        GCPConfig.CI_PRIVATE_BUCKET)

    extract_packs_artifacts(path_to_artifacts, extract_destination_path)
    path_to_pack = os.path.join(extract_destination_path, pack_name)
    premium_pack = Pack(pack_name, path_to_pack)

    upload_premium_pack_to_private_testing_bucket(
        premium_pack, pack_name, private_testing_bucket_client,
        storage_base_path)
Beispiel #2
0
def main():
    install_logging('prepare_public_index_for_private_testing.log',
                    logger=logging)
    upload_config = option_handler()
    service_account = upload_config.service_account
    build_number = upload_config.ci_build_number
    public_bucket_name = upload_config.public_bucket_name
    private_bucket_name = upload_config.private_bucket_name
    storage_base_path = upload_config.storage_base_path
    extract_public_index_path = upload_config.extract_public_index_path
    changed_pack = upload_config.pack_name
    extract_destination_path = upload_config.extract_artifacts_path
    packs_artifacts_path = upload_config.artifacts_path
    dummy_index_dir_path = upload_config.dummy_index_dir_path
    dummy_index_path = os.path.join(dummy_index_dir_path, 'index.zip')
    dummy_index_lock_path = os.path.join(dummy_index_dir_path, 'lock.txt')

    storage_client = init_storage_client(service_account)
    public_storage_bucket = storage_client.bucket(public_bucket_name)
    private_storage_bucket = storage_client.bucket(private_bucket_name)

    dummy_index_blob = public_storage_bucket.blob(dummy_index_path)

    with lock_and_unlock_dummy_index(public_storage_bucket,
                                     dummy_index_lock_path):

        extract_packs_artifacts(packs_artifacts_path, extract_destination_path)
        public_index_folder_path, public_index_blob, _ = download_and_extract_index(
            public_storage_bucket, extract_public_index_path,
            storage_base_path)

        # In order for the packs to be downloaded successfully, their price has to be 0
        change_packs_price_to_zero(public_index_folder_path)

        private_packs, private_index_path, private_index_blob = update_index_with_priced_packs(
            private_storage_bucket, extract_destination_path,
            public_index_folder_path, changed_pack, True, storage_base_path)
        private_packs = add_private_packs_from_dummy_index(
            private_packs, dummy_index_blob)
        upload_modified_index(public_index_folder_path,
                              extract_public_index_path, dummy_index_blob,
                              build_number, private_packs)