-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
256 additions
and
0 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
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,18 @@ | ||
#!/bin/bash | ||
script_dir=$(cd $(dirname $0) && pwd) | ||
|
||
# This file should only be included, not executed. | ||
if [ "${BASH_SOURCE[0]}" == "${0}" ]; then | ||
echo "This script should be included, not executed." | ||
exit 1 | ||
fi | ||
|
||
export PACKAGE_NAME="web-indexer" | ||
export SOURCE_VERSION=$(git describe --tags --always --dirty) | ||
export EXPECTED_VERSION=$(echo "$SOURCE_VERSION" | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+).*/\1/') | ||
|
||
export OS="linux" | ||
export FILENAME_BASE="${PACKAGE_NAME}_${SOURCE_VERSION}_${OS}_amd64" | ||
export DIST_DIR="${script_dir}/../../dist" | ||
export TERM=xterm-256color | ||
|
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,49 @@ | ||
#!/bin/bash | ||
script_dir=$(cd $(dirname $0) && pwd) | ||
source $script_dir/common.sh | ||
|
||
FAILED=0 | ||
FAILED_TESTS="" | ||
PASSED_TESTS="" | ||
|
||
green=`tput setaf 2` | ||
red=`tput setaf 1` | ||
reset=`tput sgr0` | ||
|
||
tests=$(ls $script_dir/test-*.sh) | ||
|
||
if [ -n "$1" ]; then | ||
tests=$(ls $script_dir/test-$1*.sh) | ||
fi | ||
|
||
if [ -z "$tests" ]; then | ||
echo "No tests found in $script_dir" | ||
exit 1 | ||
fi | ||
|
||
for test_script in $tests; do | ||
echo "===============================================================================" | ||
echo "▶ Running $(basename $test_script) for $EXPECTED_VERSION" | ||
echo "===============================================================================" | ||
if ! bash $test_script; then | ||
echo "${red}FAILED: ${test_script}${reset}" | ||
FAILED=1 | ||
FAILED_TESTS="$FAILED_TESTS $test_script" | ||
continue | ||
fi | ||
|
||
echo "${green}PASSED: $(basename $test_script)${reset}" | ||
PASSED_TESTS="$PASSED_TESTS $(basename $test_script)" | ||
done | ||
|
||
echo | ||
echo "===============================================================================" | ||
if [ $FAILED -eq 1 ]; then | ||
echo "${red}Failed:$FAILED_TESTS${reset}" | ||
if [ -n "$PASSED_TESTS" ]; then | ||
echo "${green}Passed:$PASSED_TESTS${reset}" | ||
fi | ||
exit 1 | ||
else | ||
echo "${green}All tests passed!${reset}" | ||
fi |
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,36 @@ | ||
#!/bin/bash | ||
script_dir=$(cd $(dirname $0) && pwd) | ||
source $script_dir/common.sh | ||
|
||
docker run -v ${DIST_DIR}:/tmp/dist \ | ||
--rm alpine /bin/ash -c " | ||
cp /tmp/dist/${FILENAME_BASE}.apk /tmp; | ||
cd /tmp; | ||
apk add --no-cache --allow-untrusted ${FILENAME_BASE}.apk; | ||
# Verify installation | ||
echo '=== Verifying installation ==='; | ||
if ! command -v $PACKAGE_NAME &> /dev/null; then | ||
echo '$PACKAGE_NAME could not be installed.' >&2; | ||
exit 1; | ||
fi; | ||
echo 'ok'; | ||
# Check the version | ||
echo '=== Checking executed version ==='; | ||
INSTALLED_VERSION=\$($PACKAGE_NAME --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+'); | ||
if [ \"\$INSTALLED_VERSION\" != \"$EXPECTED_VERSION\" ]; then | ||
echo 'Version mismatch: expected $EXPECTED_VERSION, got '\"\$INSTALLED_VERSION\"'.' >&2; | ||
exit 1; | ||
fi; | ||
echo 'ok'; | ||
echo 'All tests passed!'; | ||
" | ||
|
||
if [ $? -eq 0 ]; then | ||
echo "Package $PACKAGE_NAME tests passed successfully." | ||
else | ||
echo "Package $PACKAGE_NAME tests failed." >&2 | ||
exit 1 | ||
fi |
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,37 @@ | ||
#!/bin/bash | ||
script_dir=$(cd $(dirname $0) && pwd) | ||
source $script_dir/common.sh | ||
|
||
docker run -v ${DIST_DIR}:/tmp/dist \ | ||
--rm archlinux /bin/bash -c " | ||
cp /tmp/dist/${FILENAME_BASE}.pkg.tar.zst /tmp; | ||
cd /tmp; | ||
pacman -U ${FILENAME_BASE}.pkg.tar.zst --noconfirm; | ||
# Verify installation | ||
echo '=== Verifying installation ==='; | ||
if ! command -v $PACKAGE_NAME &> /dev/null; then | ||
echo '$PACKAGE_NAME could not be installed.' >&2; | ||
exit 1; | ||
fi; | ||
echo 'ok'; | ||
# Check the version | ||
echo '=== Checking executed version ==='; | ||
INSTALLED_VERSION=\$($PACKAGE_NAME --version | grep -oP '\d+\.\d+\.\d+'); | ||
if [ \"\$INSTALLED_VERSION\" != \"$EXPECTED_VERSION\" ]; then | ||
echo 'Version mismatch: expected $EXPECTED_VERSION, got '\"\$INSTALLED_VERSION\"'.' >&2; | ||
exit 1; | ||
fi; | ||
echo 'ok'; | ||
echo 'All tests passed!'; | ||
" | ||
|
||
if [ $? -eq 0 ]; then | ||
echo "Package $PACKAGE_NAME tests passed successfully." | ||
else | ||
echo "Package $PACKAGE_NAME tests failed." >&2 | ||
exit 1 | ||
fi |
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,37 @@ | ||
#!/bin/bash | ||
script_dir=$(cd $(dirname $0) && pwd) | ||
source $script_dir/common.sh | ||
|
||
docker run -v ${DIST_DIR}:/tmp/dist \ | ||
--rm debian /bin/bash -c " | ||
cp /tmp/dist/${FILENAME_BASE}.deb /tmp; | ||
cd /tmp; | ||
dpkg -i ${FILENAME_BASE}.deb; | ||
# Verify installation | ||
echo '=== Verifying installation ==='; | ||
if ! command -v $PACKAGE_NAME &> /dev/null; then | ||
echo '$PACKAGE_NAME could not be installed.' >&2; | ||
exit 1; | ||
fi; | ||
echo 'ok'; | ||
# Check the version | ||
echo '=== Checking executed version ==='; | ||
INSTALLED_VERSION=\$($PACKAGE_NAME --version | grep -oP '\d+\.\d+\.\d+'); | ||
if [ \"\$INSTALLED_VERSION\" != \"$EXPECTED_VERSION\" ]; then | ||
echo 'Version mismatch: expected $EXPECTED_VERSION, got '\"\$INSTALLED_VERSION\"'.' >&2; | ||
exit 1; | ||
fi; | ||
echo 'ok'; | ||
echo 'All tests passed!'; | ||
" | ||
|
||
if [ $? -eq 0 ]; then | ||
echo "Package $PACKAGE_NAME tests passed successfully." | ||
else | ||
echo "Package $PACKAGE_NAME tests failed." >&2 | ||
exit 1 | ||
fi |
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,38 @@ | ||
#!/bin/bash | ||
script_dir=$(cd $(dirname $0) && pwd) | ||
source $script_dir/common.sh | ||
|
||
docker run -v ${DIST_DIR}:/tmp/dist \ | ||
--rm rockylinux:9 /bin/bash -c " | ||
cp /tmp/dist/${FILENAME_BASE}.tar.gz /tmp; | ||
tar -xzf /tmp/${FILENAME_BASE}.tar.gz -C /tmp; | ||
mv /tmp/${PACKAGE_NAME} /usr/local/bin/${PACKAGE_NAME}; | ||
chmod +x /usr/local/bin/${PACKAGE_NAME}; | ||
# Verify installation | ||
echo '=== Verifying installation ==='; | ||
if ! command -v $PACKAGE_NAME &> /dev/null; then | ||
echo '$PACKAGE_NAME could not be installed.' >&2; | ||
exit 1; | ||
fi; | ||
echo 'ok'; | ||
# Check the version | ||
echo '=== Checking executed version ==='; | ||
INSTALLED_VERSION=\$($PACKAGE_NAME --version | grep -oP '\d+\.\d+\.\d+'); | ||
if [ \"\$INSTALLED_VERSION\" != \"$EXPECTED_VERSION\" ]; then | ||
echo 'Version mismatch: expected $EXPECTED_VERSION, got '\"\$INSTALLED_VERSION\"'.' >&2; | ||
exit 1; | ||
fi; | ||
echo 'ok'; | ||
echo 'All tests passed!'; | ||
" | ||
|
||
if [ $? -eq 0 ]; then | ||
echo "Package $PACKAGE_NAME tests passed successfully." | ||
else | ||
echo "Package $PACKAGE_NAME tests failed." >&2 | ||
exit 1 | ||
fi |
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,38 @@ | ||
#!/bin/bash | ||
script_dir=$(cd $(dirname $0) && pwd) | ||
source $script_dir/common.sh | ||
|
||
docker run -v ${DIST_DIR}:/tmp/dist \ | ||
--rm rockylinux:9 /bin/bash -c " | ||
cp /tmp/dist/${FILENAME_BASE}.rpm /tmp; | ||
cd /tmp; | ||
rpm -i ${FILENAME_BASE}.rpm; | ||
# Verify installation | ||
echo '=== Verifying installation ==='; | ||
if ! command -v $PACKAGE_NAME &> /dev/null; then | ||
echo '$PACKAGE_NAME could not be installed.' >&2; | ||
exit 1; | ||
fi; | ||
echo 'ok'; | ||
# Check the version | ||
echo '=== Checking executed version ==='; | ||
INSTALLED_VERSION=\$($PACKAGE_NAME --version | grep -oP '\d+\.\d+\.\d+'); | ||
if [ \"\$INSTALLED_VERSION\" != \"$EXPECTED_VERSION\" ]; then | ||
echo 'Version mismatch: expected $EXPECTED_VERSION, got '\"\$INSTALLED_VERSION\"'.' >&2; | ||
exit 1; | ||
fi; | ||
echo 'ok'; | ||
echo 'All tests passed!'; | ||
" | ||
|
||
if [ $? -eq 0 ]; then | ||
echo "Package $PACKAGE_NAME tests passed successfully." | ||
else | ||
echo "Package $PACKAGE_NAME tests failed." >&2 | ||
exit 1 | ||
fi | ||
|