From e94ffe73aafb83b78729a7a9a67782508270c876 Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Sat, 12 Oct 2024 15:49:29 +0200 Subject: [PATCH 1/3] refactor: remove get_latest_tag in favor of hardcoded VERSION --- .github/RELEASE.md | 1 + install.sh | 16 ++++------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/RELEASE.md b/.github/RELEASE.md index 97717e02..099d755a 100644 --- a/.github/RELEASE.md +++ b/.github/RELEASE.md @@ -3,6 +3,7 @@ This is a guide to know the steps to create a new release. 1. Update the version in [BASHUNIT_VERSION](../bashunit) +1. Update the version in [LATEST_BASHUNIT_VERSION](../install.sh) 1. Update the version in [CHANGELOG.md](../CHANGELOG.md) 1. Update the version in [package.json](../package.json) 1. Build the project `./build.sh bin` diff --git a/install.sh b/install.sh index 865b9f89..9fb607a2 100755 --- a/install.sh +++ b/install.sh @@ -10,17 +10,9 @@ function check_git_is_installed() { fi } -function get_latest_tag() { - git ls-remote --tags "$BASHUNIT_GIT_REPO" | - awk '{print $2}' | - sed 's|^refs/tags/||' | - sort -Vr | - head -n 1 -} - function build_and_install_beta() { echo "> Downloading non-stable version: 'beta'" - git clone --depth 1 --no-tags https://github.com/TypedDevs/bashunit temp_bashunit 2>/dev/null + git clone --depth 1 --no-tags $BASHUNIT_GIT_REPO temp_bashunit 2>/dev/null cd temp_bashunit ./build.sh >/dev/null local latest_commit @@ -44,9 +36,9 @@ function install() { fi if command -v curl > /dev/null 2>&1; then - curl -L -O -J "https://github.com/TypedDevs/bashunit/releases/download/$TAG/bashunit" 2>/dev/null + curl -L -O -J "$BASHUNIT_GIT_REPO/releases/download/$TAG/bashunit" 2>/dev/null elif command -v wget > /dev/null 2>&1; then - wget "https://github.com/TypedDevs/bashunit/releases/download/$TAG/bashunit" 2>/dev/null + wget "$BASHUNIT_GIT_REPO/releases/download/$TAG/bashunit" 2>/dev/null else echo "Cannot download bashunit: curl or wget not found." fi @@ -62,8 +54,8 @@ check_git_is_installed DIR=${1-lib} VERSION=${2-latest} +LATEST_BASHUNIT_VERSION="0.17.0" BASHUNIT_GIT_REPO="https://github.com/TypedDevs/bashunit" -LATEST_BASHUNIT_VERSION="$(get_latest_tag)" TAG="$LATEST_BASHUNIT_VERSION" cd "$(dirname "$0")" From 89d605a81c4115716abfc10e207a9d562a1788c1 Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Sat, 12 Oct 2024 16:00:01 +0200 Subject: [PATCH 2/3] refactor: build_and_install_beta --- install.sh | 21 ++++++++++----------- tests/acceptance/install_test.sh | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index 9fb607a2..65c457f8 100755 --- a/install.sh +++ b/install.sh @@ -1,26 +1,27 @@ #!/bin/bash # shellcheck disable=SC2155 # shellcheck disable=SC2164 -# shellcheck disable=SC2103 -function check_git_is_installed() { +function build_and_install_beta() { + echo "> Downloading non-stable version: 'beta'" + if ! command -v git >/dev/null 2>&1; then echo "Error: git is not installed." >&2 exit 1 fi -} -function build_and_install_beta() { - echo "> Downloading non-stable version: 'beta'" git clone --depth 1 --no-tags $BASHUNIT_GIT_REPO temp_bashunit 2>/dev/null cd temp_bashunit ./build.sh >/dev/null - local latest_commit - latest_commit=$(git rev-parse --short=8 HEAD) + local latest_commit=$(git rev-parse --short=7 HEAD) + # shellcheck disable=SC2103 cd .. - local beta_version - beta_version='(non-stable) beta after '"$LATEST_BASHUNIT_VERSION"' ['"$(date +'%Y-%m-%d')"'] 🐍 #'"$latest_commit" + local beta_version=$(printf "(non-stable) beta after %s [%s] 🐍 #%s" \ + "$LATEST_BASHUNIT_VERSION" \ + "$(date +'%Y-%m-%d')" \ + "$latest_commit" + ) sed -i -e 's/BASHUNIT_VERSION=".*"/BASHUNIT_VERSION="'"$beta_version"'"/g' temp_bashunit/bin/bashunit cp temp_bashunit/bin/bashunit ./ @@ -49,8 +50,6 @@ function install() { ######### MAIN ########## ######################### -check_git_is_installed - DIR=${1-lib} VERSION=${2-latest} diff --git a/tests/acceptance/install_test.sh b/tests/acceptance/install_test.sh index fb07ed65..25a1132b 100644 --- a/tests/acceptance/install_test.sh +++ b/tests/acceptance/install_test.sh @@ -67,7 +67,7 @@ function test_install_downloads_the_non_stable_beta_version() { "$output" assert_file_exists "$installed_bashunit" assert_matches\ - "$(printf "\(non-stable\) beta after ([0-9]+\.[0-9]+\.[0-9]+) \[2023-11-13\] 🐍 \#[a-fA-F0-9]{8}")"\ + "$(printf "\(non-stable\) beta after ([0-9]+\.[0-9]+\.[0-9]+) \[2023-11-13\] 🐍 \#[a-fA-F0-9]{7}")"\ "$("$installed_bashunit" --env "$TEST_ENV_FILE" --version)" assert_directory_not_exists "./deps/temp_bashunit" file_count_of_deps_directory=$(find ./deps -mindepth 1 -maxdepth 1 -print | wc -l | tr -d ' ') From a33bae00ce806b9df9935fab4dabf9435fbd4988 Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Sat, 12 Oct 2024 16:04:38 +0200 Subject: [PATCH 3/3] docs: update changelog --- CHANGELOG.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c54ff575..eb17b52b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,14 +16,15 @@ - temp_dir - cleanup_temp_files - log -- Improved clean up temporal files and directories -- Improved CI test speed by running them in parallel - Add default env values: - `DEFAULT_PATH="tests"` - `LOG_PATH="out.log"` - `LOAD_FILE="tests/bootstrap.sh"` - Add check that git is installed to `install.sh` -- Display seconds on total time taken +- Improved time taken display +- Improved clean up temporal files and directories +- Improved CI test speed by running them in parallel +- Removed git dependency for stable installations ## [0.17.0](https://github.com/TypedDevs/bashunit/compare/0.16.0...0.17.0) - 2024-10-01