Skip to content

Commit

Permalink
feat: always update development images
Browse files Browse the repository at this point in the history
- new option to force download of an image and override the cache
- never use the cached image for in-development versions
  (*-trunk | *-alpha)
  • Loading branch information
theseion committed Dec 23, 2023
1 parent 3f608f0 commit 3f0f6a9
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
9 changes: 8 additions & 1 deletion gtoolkit/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}'."
Expand Down
10 changes: 8 additions & 2 deletions pharo/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down
24 changes: 23 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,29 @@ 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:
# config_clean
# config_debug
# config_headless
# config_smalltalk
# config_update_image
# config_verbose
# Arguments:
# All positional parameters
Expand Down Expand Up @@ -344,6 +360,10 @@ parse_options() {
fi
shift 2
;;
-u | --update-image)
config_update_image="true"
shift
;;
-v | --verbose)
config_verbose="true"
shift
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion squeak/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3f0f6a9

Please sign in to comment.