From 3f0f6a9b5801b5cff126a075295d99a95444724a Mon Sep 17 00:00:00 2001 From: Max Leske Date: Sat, 23 Dec 2023 10:36:06 +0100 Subject: [PATCH] feat: always update development images - new option to force download of an image and override the cache - never use the cached image for in-development versions (*-trunk | *-alpha) --- gtoolkit/run.sh | 9 ++++++++- helpers.sh | 3 ++- pharo/run.sh | 10 ++++++++-- run.sh | 24 +++++++++++++++++++++++- squeak/run.sh | 9 ++++++++- 5 files changed, 49 insertions(+), 6 deletions(-) diff --git a/gtoolkit/run.sh b/gtoolkit/run.sh index 76eaebdb..5bf195c0 100644 --- a/gtoolkit/run.sh +++ b/gtoolkit/run.sh @@ -111,7 +111,14 @@ gtoolkit::prepare_gt() { download_name="$(basename "${gtoolkit_image_url}")" target="${SMALLTALK_CI_CACHE}/${download_name}" - if ! is_file "${target}"; then + if "${config_update_image}" && is_dir "${target}"; then + print_info "Removing cached image resources for ${smalltalk_name} (update forced)" + rm -r "${target}" + fi + if ! is_dir "${target}"; then + mkdir "${target}" + fi + if ! is_file "${target}"/*.image; then fold_start download_image "Downloading ${smalltalk_name} image..." download_file "${gtoolkit_image_url}" "${target}" fold_end download_image diff --git a/helpers.sh b/helpers.sh index 1ffc8e5e..51535dbf 100644 --- a/helpers.sh +++ b/helpers.sh @@ -339,7 +339,8 @@ download_file() { fi if program_exists "curl"; then - curl --fail --silent --show-error --location \ + ls -la "${target}" + curl --fail -v --show-error --location \ --retry 3 --retry-delay 5 --max-time 300 \ -o "${target}" "${url}" || print_error_and_exit \ "curl failed to download ${url} to '${target}'." diff --git a/pharo/run.sh b/pharo/run.sh index cab26ffe..bf34e524 100644 --- a/pharo/run.sh +++ b/pharo/run.sh @@ -278,14 +278,20 @@ pharo::prepare_image() { local target="${SMALLTALK_CI_CACHE}/${smalltalk_name}" local pharo_zeroconf="${target}/zeroconfig" + if "${config_update_image}" && is_dir "${target}"; then + print_info "Removing cached image resources for ${smalltalk_name} (update forced)" + rm -r "${target}" + fi if ! is_dir "${target}"; then mkdir "${target}" - pushd "${target}" > /dev/null + fi + if ! is_file "${target}"/*.image; then + pushd "${target}" >/dev/null fold_start download_image "Downloading ${smalltalk_name} image..." download_file "${pharo_image_url}" "${pharo_zeroconf}" retry 3 "bash ${pharo_zeroconf}" fold_end download_image - popd > /dev/null + popd >/dev/null fi print_info "Preparing Pharo image..." diff --git a/run.sh b/run.sh index 0da83a30..32062793 100755 --- a/run.sh +++ b/run.sh @@ -280,6 +280,21 @@ validate_configuration() { fi } +################################################################################ +# Set options that depend on the contex, i.e., the input values and selections +# performed so far. +################################################################################ +set_context_options() { + case "${config_smalltalk}" in + *-alpha | *-trunk) + print_info "Forcing image update for in-development version" + config_update_image="true" + ;; + *) + ;; + esac +} + ################################################################################ # Handle user-defined options. # Locals: @@ -287,6 +302,7 @@ validate_configuration() { # config_debug # config_headless # config_smalltalk +# config_update_image # config_verbose # Arguments: # All positional parameters @@ -344,6 +360,10 @@ parse_options() { fi shift 2 ;; + -u | --update-image) + config_update_image="true" + shift + ;; -v | --verbose) config_verbose="true" shift @@ -529,10 +549,11 @@ main() { local config_clean="false" local config_debug="false" local config_first_arg_or_empty="" - local config_headless="true" + export config_headless="true" local config_image="" local config_colorful="true" export config_tracking="true" + export config_update_image="false" local config_verbose="false" local config_vm="" local config_vm_dir @@ -544,6 +565,7 @@ main() { ensure_ston_config_exists "${config_first_arg_or_empty}" select_smalltalk validate_configuration + set_context_options config_vm_dir="${SMALLTALK_CI_VMS}/${config_smalltalk}" prepare_folders export_coveralls_data diff --git a/squeak/run.sh b/squeak/run.sh index 758eba42..157f6cbc 100755 --- a/squeak/run.sh +++ b/squeak/run.sh @@ -74,7 +74,14 @@ squeak::download_prepared_image() { local git_tag=$2 local target="${SMALLTALK_CI_CACHE}/${download_name}" - if ! is_file "${target}"; then + if "${config_update_image}" && is_dir "${target}"; then + print_info "Removing cached image resources for ${smalltalk_name} (update forced)" + rm -r "${target}" + fi + if ! is_dir "${target}"; then + mkdir "${target}" + fi + if ! is_file "${target}"/*.image; then fold_start download_image "Downloading '${download_name}' testing image..." download_file "${BASE_DOWNLOAD}/${git_tag}/${download_name}" "${target}" fold_end download_image