Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow install beta #211

Merged
merged 13 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Improve data provider output
- Add .env variable `DEFAULT_PATH`
- Improve duplicated function names output
- Allow installing (non-stable) main using the installer

## [0.9.0](https://github.com/TypedDevs/bashunit/compare/0.8.0...0.9.0) - 2023-10-15

Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ cat bashunit >> bin/temp.sh
grep -v '^source' bin/temp.sh > bin/bashunit
rm bin/temp.sh

chmod +x bin/bashunit
chmod u+x bin/bashunit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘πŸ»


echo "Build complete. bashunit has been generated in the bin folder."
4 changes: 4 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ curl -s https://bashunit.typeddevs.com/install.sh | bash -s [dir] [version]
- `[dir]`: the destiny directory to save the executable bashunit; `lib` by default
- `[version]`: the [release](https://github.com/TypedDevs/bashunit/releases) to download, for instance `{{ pkg.version }}`; `latest` by default

::: tip
You can use `main` as `[version]` to get the latest **main branch**. We try to keep it stable, but there is no promise. Useful to have access to the latest features/bug fixes, even consider yourself as a beta tester.
:::

::: tip
Committing (or not) this file to your project it's up to you. In the end, it is a dev dependency.
:::
Expand Down
34 changes: 27 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,39 @@ DIR=${1-lib}
VERSION=${2-latest}
TAG="$LATEST_BASHUNIT_VERSION"

function install_main() {
echo "> Downloading non-stable main"
git clone --depth 1 --no-tags https://github.com/TypedDevs/bashunit temp_bashunit
cd temp_bashunit
./build.sh
cd ..
cp temp_bashunit/bin/bashunit bashunit
sed -i -e 's/BASHUNIT_VERSION=".*"/BASHUNIT_VERSION="(non-stable) main"/g' bashunit
rm -rf temp_bashunit
echo "> bashunit has been installed in the '$DIR' folder"
}

function install_concrete_version() {
if [[ $VERSION != 'latest' ]]; then
TAG="$VERSION"
echo "> Downloading a concrete version: '$TAG'"
else
echo "> Downloading the latest version: '$TAG'"
fi

curl -L -O -J "https://github.com/TypedDevs/bashunit/releases/download/$TAG/bashunit" 2>/dev/null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make senses to add header on the curl to track the version requested as well as the OS that is using?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chmod u+x "bashunit"
echo "> bashunit has been installed in the '$DIR' folder"
antonio-gg-dev marked this conversation as resolved.
Show resolved Hide resolved
}

cd "$(dirname "$0")"
rm -f "$DIR"/bashunit
[ -d "$DIR" ] || mkdir "$DIR"
cd "$DIR"

if [[ $VERSION != 'latest' ]]; then
TAG="$VERSION"
echo "> Downloading a concrete version: '$TAG'"
if [[ $VERSION == 'main' ]]; then
antonio-gg-dev marked this conversation as resolved.
Show resolved Hide resolved
install_main
else
echo "> Downloading the latest version: '$TAG'"
install_concrete_version
antonio-gg-dev marked this conversation as resolved.
Show resolved Hide resolved
fi

curl -L -O -J "https://github.com/TypedDevs/bashunit/releases/download/$TAG/bashunit" 2>/dev/null
chmod u+x "bashunit"
echo "> bashunit has been installed in the '$DIR' folder"
16 changes: 16 additions & 0 deletions tests/acceptance/install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,19 @@ function test_install_downloads_the_given_version() {
assert_file_exists "$install_dir"
assert_equals "$(printf "\e[1m\e[32mbashunit\e[0m - 0.8.0")" "$("$install_dir" --version)"
}

function test_install_downloads_the_main_version() {
mock git "cp -r .. temp_bashunit"
local install_dir="./lib/bashunit"
local output

output="$(./install.sh lib main)"

assert_contains "Downloading non-stable main" "$output"
assert_contains "bashunit has been installed in the 'lib' folder" "$output"
assert_file_exists "$install_dir"
assert_equals "$(printf "\e[1m\e[32mbashunit\e[0m - (non-stable) main")" "$("$install_dir" --version)"

# TODO: Remove this after merging https://github.com/TypedDevs/bashunit/pull/212
unset -f git
}
antonio-gg-dev marked this conversation as resolved.
Show resolved Hide resolved
Loading