Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions rules/scripts/bitstreams_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
parser.add_argument('--latest-update',
default='latest.txt',
help='Last time the cache was updated')
parser.add_argument('--branch',
default="master",
help='Upstream git branch to search for bitstreams.')
parser.add_argument('--bucket-url', default=BUCKET_URL, help='GCP Bucket URL')
parser.add_argument('--build-file',
default='BUILD.bazel',
Expand Down Expand Up @@ -217,7 +220,7 @@ def Get(self, file, **kwargs):
time.sleep(wait_time)
wait_time *= 2.0

def GetBitstreamsAvailable(self, refresh, load_latest_update=True):
def GetBitstreamsAvailable(self, branch, refresh, load_latest_update=True):
"""Inventory which bitstreams are available.

Args:
Expand Down Expand Up @@ -265,7 +268,7 @@ def GetBitstreamsAvailable(self, refresh, load_latest_update=True):
else:
break

latest = self.Get('master/latest.txt').decode('utf-8').split('\n')
latest = self.Get(f'{branch}/latest.txt').decode('utf-8').split('\n')
self.available['latest'] = latest[1]

def GetClosest(self, repodir, key):
Expand Down Expand Up @@ -600,7 +603,7 @@ def main(argv):
cache.NeedRefresh(args.refresh_time))
# Do we need to load the latest_update file?
load_latest_update = (desired_bitstream == 'latest')
cache.GetBitstreamsAvailable(need_refresh and not args.offline,
cache.GetBitstreamsAvailable(args.branch, need_refresh and not args.offline,
load_latest_update)

# If commanded to print bitstream availability, do so.
Expand Down
4 changes: 2 additions & 2 deletions rules/scripts/bitstreams_workspace_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_fetch_available_bitstreams_single_page(self):
name='cache.Get',
side_effect=MOCKED_GET_RETURN,
)
self.cache.GetBitstreamsAvailable(refresh=True)
self.cache.GetBitstreamsAvailable(branch="master", refresh=True)
self.assertEqual(self.cache.Get.call_count, 2)
self.assertEqual(self.cache.available, {
"0": "master/bitstream-0.tar.gz",
Expand Down Expand Up @@ -269,7 +269,7 @@ def test_fetch_available_bitstreams_with_pagination(self):
name='cache.Get',
side_effect=MOCKED_GET_RETURN,
)
self.cache.GetBitstreamsAvailable(refresh=True)
self.cache.GetBitstreamsAvailable(branch="master", refresh=True)
self.assertEqual(self.cache.Get.call_count, 3)
self.assertEqual(
self.cache.available, {
Expand Down
2 changes: 1 addition & 1 deletion util/prep-bazel-airgapped-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ if [[ ${AIRGAPPED_DIR_CONTENTS} == "ALL" || \
readonly LATEST_BISTREAM_HASH_FILE="${SYSTEM_BITSTREAM_CACHE}/latest.txt"
# The revision named in latest.txt is not necessarily on disk. Induce the
# cache backend to fetch the latest bitstreams.
BITSTREAM=latest ${BAZELISK} fetch @bitstreams//...
BITSTREAM="latest" ${BAZELISK} fetch @bitstreams//...
cp "${LATEST_BISTREAM_HASH_FILE}" \
"${BAZEL_AIRGAPPED_DIR}/${BAZEL_BITSTREAMS_CACHE}/"
LATEST_BISTREAM_HASH=$(cat "${LATEST_BISTREAM_HASH_FILE}")
Expand Down
Loading