Skip to content

Commit 88cb175

Browse files
committed
feat: ability to download multiple artifacts
Modify `download_ci_artifacts` to accept artifacts paths as input and download by passing these paths to `ensure_ci_artifacts`. `ensure_ci_artifacts` will default to latest s3 artifacts if no args were provided. Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
1 parent 7795001 commit 88cb175

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

.buildkite/common.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,11 @@ def to_json(self):
376376
"""Serialize the pipeline to JSON"""
377377
return json.dumps(self.to_dict(), indent=4, sort_keys=True, ensure_ascii=False)
378378

379+
def devtool_download_artifacts(self, artifacts_s3_url):
380+
"""Generate a `devtool download_ci_artifacts` command"""
381+
parts = ["./tools/devtool -y download_ci_artifacts"]
382+
383+
379384
def devtool_test(self, devtool_opts=None, pytest_opts=None):
380385
"""Generate a `devtool test` command"""
381386
cmds = []

tools/devtool

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,10 @@ cmd_help() {
426426
echo " Builds the rootfs and guest kernel artifacts we use for our CI."
427427
echo " Run './tools/devtool build_ci_artifacts help' for more details about the available commands."
428428
echo ""
429-
echo " download_ci_artifacts [--force]"
429+
echo " download_ci_artifacts [--force] [artifact1 artifact2 ...]"
430430
echo " Downloads the CI artifacts used for testing from our S3 bucket. If --force is passed, purges any existing"
431-
echo " artifacts first. Useful for refreshing local artifacts after an update, or if something got messed up."
431+
echo " artifacts first. If specific artifacts are listed, only those will be downloaded; otherwise all artifacts"
432+
echo " are downloaded. Useful for refreshing local artifacts after an update, or if something got messed up."
432433
echo ""
433434

434435
cat <<EOF
@@ -577,20 +578,45 @@ cmd_distclean() {
577578
}
578579

579580
cmd_download_ci_artifacts() {
580-
if [ "$1" = "--force" ]; then
581+
local force=false
582+
local artifacts=()
583+
584+
while [ $# -gt 0 ]; do
585+
case "$1" in
586+
--force)
587+
force=true
588+
;;
589+
*)
590+
artifacts+=("$1")
591+
;;
592+
esac
593+
shift
594+
done
595+
596+
if [ "$force" = true ]; then
581597
rm -rf $ARTIFACTS_DIR
582598
fi
583599

584-
ensure_ci_artifacts
600+
if [ ${#artifacts[@]} -eq 0 ]; then
601+
say "No artifacts were specified"
602+
fi
603+
604+
for artifact in "${artifacts[@]}"; do
605+
ensure_ci_artifacts $artifact
606+
done
585607
}
586608

587609
ensure_ci_artifacts() {
588-
if ! command -v aws >/dev/null; then
589-
die "AWS CLI not installed, which is required for downloading artifacts for integration tests."
610+
local artifacts=$1
611+
612+
if [ -z $artifacts ]; then
613+
local default_artifacts=$(get_newest_s3_artifacts)
614+
say "No specific artifacts are defined. Using default artifacts: " $default_artifacts
615+
artifacts=$default_artifacts
590616
fi
591617

592618
# Fetch all the artifacts so they are local
593-
local artifacts_s3_url=$(get_newest_s3_artifacts)
619+
local artifacts_s3_url=$artifacts
594620
local artifacts_s3_url_arch=$artifacts_s3_url/$(uname -m)
595621
local artifacts_local_path=$(get_local_artifacts_path $artifacts_s3_url)/$(uname -m)
596622

@@ -710,6 +736,7 @@ cmd_test() {
710736
do_build=1
711737
do_archive=1
712738
do_kvm_check=1
739+
do_ci_artifacts_check=1
713740
# Parse any command line args.
714741
while [ $# -gt 0 ]; do
715742
case "$1" in
@@ -737,6 +764,9 @@ cmd_test() {
737764
"--no-kvm-check")
738765
do_kvm_check=0
739766
;;
767+
"--no-ci-artifacts-check")
768+
do_ci_artifacts_check=0
769+
;;
740770
"--") { shift; break; } ;;
741771
*)
742772
die "Unknown argument: $1. Please use --help for help."
@@ -749,7 +779,7 @@ cmd_test() {
749779
[ $do_kvm_check != 0 ] && ensure_kvm
750780
ensure_devctr
751781
ensure_build_dir
752-
ensure_ci_artifacts
782+
[ $do_ci_artifacts_check != 0 ] && ensure_ci_artifacts
753783
if [ $do_build != 0 ]; then
754784
cmd_build --release
755785
if [ -n "$BUILDKITE_PULL_REQUEST_BASE_BRANCH" ]; then

0 commit comments

Comments
 (0)