-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve test coverage by adding a matrix build with supported bash versions and more tests
- Loading branch information
Showing
29 changed files
with
255 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
language: bash | ||
language: shell | ||
dist: bionic | ||
email: false | ||
before_install: | ||
- sudo apt-get install npm -y | ||
- sudo npm install -g bats | ||
script: ./bin/run_tests && ./bin/package | ||
env: | ||
- BASH=rc | ||
- BASH=latest | ||
- BASH=5.0.17 | ||
- BASH=4.4.23 | ||
- BASH=4.3.48 | ||
|
||
before_script: | ||
- docker pull bash:$BASH | ||
- docker run bash:$BASH --version | ||
script: | ||
- ./bin/run_linter && docker run -v $PWD:/bash bash:$BASH /bash/bin/ci_run_tests | ||
deploy: | ||
provider: releases | ||
api_key: | ||
script: ./bin/package | ||
token: | ||
secure: c5h0E4QkBWe7Bka6mkowP/z6QEiqwKGV5/E9MhX9COzxhtQGlDa7rYJ7AlS43o9sXOqJR7P8Hq5KJAXqYoOamKpXB7M+1IGlDjeVB8uHBKZ/53Iwj6ZUrnXvmIrbY3X6Cr2cK2JVkmKeHx4MhT3HZKCv+MGbA3EfcIghEk/KSi8GcP84oqMLLvOhXStvVgOh2n80w4KUlqXct7DWBTc8kZAhlp2jFXBXOTdk7ihwGzS98qvHyFEO+asW63PwqpCAj74Qmj9KECIStTWGr/ieArpIuoWMVB3yvmmmZkAcm0hckwdgnwcwS47MWo3PDoUO/QuAy0CoVdWGmkz+NekudXrN7xTuTgP0afA5VF0hX7DtDsu18BoiQonauAfImNz5dYVonqMXqHSVZXcwCuyAs/zfbpFVjrngUnPrZN+rD/NwdAB3EbTIFHdQz3dqsrFhKbeHzg2dQv6NNUn9FY/hD7kol2xODONLk0A8tnZwEVRLEKSA/aBPcjh1gq63im4DpONUpf2EjtHSWVJ/kaqiKgc+kQGeF/KdH36O57qP5ttiZuYmjftiNS2n6vlu2ODgQiBrwVlbTXOdR2+lYLrQKF26L7IvslLX7PJUG9S79OjSxob/+NyuFgKYbD0SUT7nN6enwS1UVi3vO+LOJkWmq3fFULjy3stbcreH9L48iTs= | ||
file: sbp-${TRAVIS_TAG}.tar.gz | ||
on: | ||
tags: true | ||
skip_cleanup: 'true' | ||
cleanup: 'false' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
apk -U add bats git | ||
|
||
/bash/bin/run_tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#! /usr/bin/env bash | ||
|
||
set -e | ||
|
||
SBP_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd ) | ||
export SBP_PATH | ||
|
||
shellcheck -x --severity=error "${SBP_PATH}/sbp.bash" "${SBP_PATH}/src/main.bash" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,72 @@ | ||
#! /usr/bin/env bash | ||
|
||
decorate::calculate_complementing_color() { | ||
local -n return_value=$1 | ||
local -n calculate_complementing_color_result=$1 | ||
local source_color=$2 | ||
input_colors=() | ||
output_colors=() | ||
|
||
if [[ -z "${source_color//[0123456789]}" ]]; then | ||
# This is not accurate | ||
return_value="$(( 255 - source_color ))" | ||
calculate_complementing_color_result="$(( 255 - source_color ))" | ||
else | ||
mapfile -t input_colors < <(tr ';' '\n' <<< "$source_color") | ||
r_lum=$(( ${input_colors[0]} * 2126 )) | ||
g_lum=$(( ${input_colors[1]} * 7152 )) | ||
b_lum=$(( ${input_colors[2]} * 722 )) | ||
local red=${input_colors[0]} | ||
local green=${input_colors[1]} | ||
local blue=${input_colors[2]} | ||
|
||
lum=$(( r_lum + g_lum + b_lum )) | ||
red=$(( red * 2126 )) | ||
green=$(( green * 7152 )) | ||
blue=$(( blue * 722 )) | ||
|
||
lum=$(( red + green + blue )) | ||
if [[ "$lum" -gt 1400000 ]]; then | ||
return_value='0;0;0' | ||
calculate_complementing_color_result='0;0;0' | ||
else | ||
return_value='255;255;255' | ||
calculate_complementing_color_result='255;255;255' | ||
fi | ||
|
||
fi | ||
} | ||
|
||
decorate::print_colors() { | ||
local -n return_value=$1 | ||
local -n print_colors_result=$1 | ||
local fg_code=$2 | ||
local bg_code=$3 | ||
local fg_color bg_color | ||
|
||
decorate::print_fg_color 'fg_color' "$fg_code" | ||
decorate::print_bg_color 'bg_color' "$bg_code" | ||
return_value="${fg_color}${bg_color}" | ||
print_colors_result="${fg_color}${bg_color}" | ||
} | ||
|
||
decorate::print_bg_color() { | ||
local -n return_value=$1 | ||
local -n print_bg_color_result=$1 | ||
local bg_code=$2 | ||
local escaped=$3 | ||
|
||
if [[ -z "$bg_code" ]]; then | ||
bg_escaped="\e[49m" | ||
elif [[ -z "${bg_code//[0123456789]}" ]]; then | ||
bg_escaped="\e[48;5;${bg_code}m" | ||
else | ||
bg_escaped="\e[48;2;${bg_code}m" | ||
fi | ||
|
||
if [[ -z "$escaped" ]]; then | ||
return_value="\[${bg_escaped}\]" | ||
else | ||
return_value="${bg_escaped}" | ||
fi | ||
decorate::format_color 'print_bg_color_result' 48 "$bg_code" | ||
} | ||
|
||
decorate::print_fg_color() { | ||
local -n return_value=$1 | ||
local -n print_fg_color_result=$1 | ||
local fg_code=$2 | ||
local escaped=$3 | ||
|
||
if [[ -z "$fg_code" ]]; then | ||
fg_escaped="\e[39m" | ||
elif [[ -z "${fg_code//[0123456789]}" ]]; then | ||
fg_escaped="\e[38;5;${fg_code}m" | ||
else | ||
fg_escaped="\e[38;2;${fg_code}m" | ||
fi | ||
decorate::format_color 'print_fg_color_result' 38 "$fg_code" | ||
} | ||
|
||
decorate::format_color() { | ||
local -n format_color_result=$1 | ||
local color_code=$2 | ||
local color_value=$3 | ||
local color_reset_code=$(( color_code + 1 )) | ||
|
||
if [[ -z "$escaped" ]]; then | ||
return_value="\[${fg_escaped}\]" | ||
if [[ -z "$color_value" ]]; then | ||
format_color_result="\e[${color_reset_code}m" | ||
elif [[ -z "${color_value//[0123456789]}" ]]; then | ||
format_color_result="\e[${color_code};5;${color_value}m" | ||
else | ||
return_value="${fg_escaped}" | ||
format_color_result="\e[${color_code};2;${color_value}m" | ||
fi | ||
|
||
format_color_result="\[${format_color_result}\]" | ||
} |
Oops, something went wrong.