Skip to content

Commit

Permalink
Merge pull request #365 from TypedDevs/feat/improve-installer
Browse files Browse the repository at this point in the history
Improve installer
  • Loading branch information
Chemaclass authored Oct 12, 2024
2 parents 65ecbf2 + a33bae0 commit a247ece
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
37 changes: 14 additions & 23 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,34 +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 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
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 ./
Expand All @@ -44,9 +37,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
Expand All @@ -57,13 +50,11 @@ function install() {
######### MAIN ##########
#########################

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")"
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' ')
Expand Down

0 comments on commit a247ece

Please sign in to comment.