From: Ward Vandewege Date: Tue, 2 Jun 2020 14:05:44 +0000 (-0400) Subject: Some refactoring in the build scripts: move duplicated code to calculate X-Git-Tag: 2.1.0~205 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/479b879e96bf60332b9a436e4ef4e5de517f028b?hp=ca3d1e44680d06398885e551ecf4bb601c0801b6 Some refactoring in the build scripts: move duplicated code to calculate the cwl runner package version to a function. Remove unused argument to the `version_from_git` function. No issue # Arvados-DCO-1.1-Signed-off-by: Ward Vandewege --- diff --git a/build/build-dev-docker-jobs-image.sh b/build/build-dev-docker-jobs-image.sh index a3d439be6f..7da8089837 100755 --- a/build/build-dev-docker-jobs-image.sh +++ b/build/build-dev-docker-jobs-image.sh @@ -69,15 +69,7 @@ fi . build/run-library.sh -python_sdk_ts=$(cd sdk/python && timestamp_from_git) -cwl_runner_ts=$(cd sdk/cwl && timestamp_from_git) - -python_sdk_version=$(cd sdk/python && nohash_version_from_git 0.1) -cwl_runner_version=$(cd sdk/cwl && nohash_version_from_git 1.0) - -if [[ $python_sdk_ts -gt $cwl_runner_ts ]]; then - cwl_runner_version=$(cd sdk/python && nohash_version_from_git 1.0) -fi +calculate_python_sdk_cwl_package_versions set -x docker build --no-cache --build-arg sdk=$sdk --build-arg runner=$runner --build-arg salad=$salad --build-arg cwltool=$cwltool --build-arg pythoncmd=$py --build-arg pipcmd=$pipcmd -f "$WORKSPACE/sdk/dev-jobs.dockerfile" -t arvados/jobs:$cwl_runner_version "$WORKSPACE/sdk" diff --git a/build/run-build-docker-jobs-image.sh b/build/run-build-docker-jobs-image.sh index 842975adb0..ec8357701d 100755 --- a/build/run-build-docker-jobs-image.sh +++ b/build/run-build-docker-jobs-image.sh @@ -139,15 +139,7 @@ if [[ -z "$ARVADOS_BUILDING_VERSION" ]] && ! [[ -z "$version_tag" ]]; then ARVADOS_BUILDING_ITERATION="1" fi -python_sdk_ts=$(cd sdk/python && timestamp_from_git) -cwl_runner_ts=$(cd sdk/cwl && timestamp_from_git) - -python_sdk_version=$(cd sdk/python && nohash_version_from_git 0.1) -cwl_runner_version=$(cd sdk/cwl && nohash_version_from_git 1.0) - -if [[ $python_sdk_ts -gt $cwl_runner_ts ]]; then - cwl_runner_version=$(cd sdk/python && nohash_version_from_git 1.0) -fi +calculate_python_sdk_cwl_package_versions echo cwl_runner_version $cwl_runner_version python_sdk_version $python_sdk_version diff --git a/build/run-library.sh b/build/run-library.sh index 7dc293ab61..b75b6cca78 100755 --- a/build/run-library.sh +++ b/build/run-library.sh @@ -48,7 +48,6 @@ version_from_git() { # Output the version being built, or if we're building a # dev/prerelease, output a version number based on the git log for # the given $subdir. - local minorversion="$1"; shift # unused local subdir="$1"; shift if [[ -n "$ARVADOS_BUILDING_VERSION" ]]; then echo "$ARVADOS_BUILDING_VERSION" @@ -66,7 +65,7 @@ nohash_version_from_git() { echo "$ARVADOS_BUILDING_VERSION" return fi - version_from_git $1 | cut -d. -f1-4 + version_from_git | cut -d. -f1-4 } timestamp_from_git() { @@ -74,6 +73,18 @@ timestamp_from_git() { format_last_commit_here "%ct" "$subdir" } +calculate_python_sdk_cwl_package_versions() { + python_sdk_ts=$(cd sdk/python && timestamp_from_git) + cwl_runner_ts=$(cd sdk/cwl && timestamp_from_git) + + python_sdk_version=$(cd sdk/python && nohash_version_from_git) + cwl_runner_version=$(cd sdk/cwl && nohash_version_from_git) + + if [[ $python_sdk_ts -gt $cwl_runner_ts ]]; then + cwl_runner_version=$python_sdk_version + fi +} + handle_python_package () { # This function assumes the current working directory is the python package directory if [ -n "$(find dist -name "*-$(nohash_version_from_git).tar.gz" -print -quit)" ]; then @@ -127,7 +138,7 @@ calculate_go_package_version() { cd "$WORKSPACE" ts="$(timestamp_from_git "$dir")" if [[ "$ts" -gt "$timestamp" ]]; then - version=$(version_from_git "" "$dir") + version=$(version_from_git "$dir") timestamp="$ts" fi done