mirror of
https://github.com/facebook/proxygen.git
synced 2025-08-07 07:02:53 +03:00
getdeps: add build cache abstraction
Summary: This diff adds a small abstraction that allows for uploading and downloading from an artifact cache. We try to download from this cache at build time, but will only try to populate it for continuous builds--those are built from code that has been reviewed and landed on master. This restriction helps to avoid thrashing the cache with works in progress and results in a slightly more trustworthy state of the cache contents. In addition to this, we choose only to cache third party projects. The rationale is that our first party projects move too quickly to be worth caching, especially since the cache granularity is for the whole project rather than just changed elements of a given project. In a later diff I will introduce some implementations of the cache class that work with eg: Travis or Circle CI caching. Reviewed By: simpkins Differential Revision: D16873307 fbshipit-source-id: 2bfb69e36615791747b499073586562f2ca48be9
This commit is contained in:
committed by
Facebook Github Bot
parent
612c3d8e09
commit
2037c7f32a
41
build/fbcode_builder/getdeps/cache.py
Normal file
41
build/fbcode_builder/getdeps/cache.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# Copyright (c) 2019-present, Facebook, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the BSD-style license found in the
|
||||
# LICENSE file in the root directory of this source tree. An additional grant
|
||||
# of patent rights can be found in the PATENTS file in the same directory.
|
||||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
|
||||
class ArtifactCache(object):
|
||||
""" The ArtifactCache is a small abstraction that allows caching
|
||||
named things in some external storage mechanism.
|
||||
The primary use case is for storing the build products on CI
|
||||
systems to accelerate the build """
|
||||
|
||||
def download_to_file(self, name, dest_file_name):
|
||||
""" If `name` exists in the cache, download it and place it
|
||||
in the specified `dest_file_name` location on the filesystem.
|
||||
If a transient issue was encountered a TransientFailure shall
|
||||
be raised.
|
||||
If `name` doesn't exist in the cache `False` shall be returned.
|
||||
If `dest_file_name` was successfully updated `True` shall be
|
||||
returned.
|
||||
All other conditions shall raise an appropriate exception. """
|
||||
return False
|
||||
|
||||
def upload_from_file(self, name, source_file_name):
|
||||
""" Causes `name` to be populated in the cache by uploading
|
||||
the contents of `source_file_name` to the storage system.
|
||||
If a transient issue was encountered a TransientFailure shall
|
||||
be raised.
|
||||
If the upload failed for some other reason, an appropriate
|
||||
exception shall be raised. """
|
||||
pass
|
||||
|
||||
|
||||
def create_cache():
|
||||
""" This function is monkey patchable to provide an actual
|
||||
implementation """
|
||||
return None
|
Reference in New Issue
Block a user