Skip to content

Commit

Permalink
adapted install script to download releases instead of building them
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-wm-arthur committed Mar 20, 2020
1 parent 9b4d2be commit b6b0506
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 37 deletions.
6 changes: 2 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,14 @@ pipeline {
steps {
dir (".ci_bin") {
sh "npm i bats"
sh "export CI_BIN=$(pwd)"
}
dir ("go") {
sh "go get -mod=readonly ./..."
sh "go build -mod=readonly -o ../.ci_bin/dolt ./cmd/dolt/."
sh "go build -mod=readonly -o $CI_BIN/dolt ./cmd/dolt/."
}
sh "dolt config --global --add user.name 'Liquidata Jenkins'"
sh "dolt config --global --add user.email 'jenkins@liquidata.co'"
sh "git fetch"
sh "git tag -l"
sh "git branch"
sh "git checkout -b build$BUILD_ID"
dir ("bats/compatibility") {
sh "./runner.sh"
Expand Down
101 changes: 68 additions & 33 deletions bats/compatibility/runner.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

function build_dolt() {
pushd "$dolt_dir" > /dev/null || exit
pushd "$DOLT_DIR" > /dev/null || exit
git checkout "$1" > /dev/null
go install .
popd > /dev/null || exit
Expand All @@ -12,11 +12,11 @@ function setup_dir() {
mkdir "$1"
pushd "$1" > /dev/null || exit

cp -r "$top_dir"/bats/* .
cp -r "$TOP_DIR"/bats/* .

mkdir "repo"
pushd "repo" > /dev/null || exit
"$top_dir/setup_repo.sh" > setup_repo.log
"$TOP_DIR/setup_repo.sh" > setup_repo.log
popd > /dev/null || exit

num_tests=$(($(grep -c '@test' *.bats)))
Expand All @@ -31,10 +31,44 @@ function setup_dir() {
function run_bats_tests() {
pushd "$1" > /dev/null || exit
bats_out=$(bats .)
status=$?
STATUS=$?
echo "$bats_out" | tr -cd "[:print:]\n" | sed 's/\[3J\[H\[2J//'
popd > /dev/null || exit
return $status
return $STATUS
}

assert_linux_or_macos() {
OS=$(uname)
ARCH=$(uname -m)
if [ "$OS" != Linux -a "$OS" != Darwin ]; then
fail "E_UNSUPPORTED_OS" "dolt install.sh only supports macOS and Linux."
fi
if [ "$ARCH" != x86_64 -a "$ARCH" != i386 -a "$ARCH" != i686 ]; then
fail "E_UNSUPPOSED_ARCH" "dolt install.sh only supports installing dolt on x86_64 or x86."
fi

if [ "$OS" == Linux ]; then
PLATFORM_TUPLE=linux
else
PLATFORM_TUPLE=darwin
fi
if [ "$ARCH" == x86_64 ]; then
PLATFORM_TUPLE=$PLATFORM_TUPLE-amd64
else
PLATFORM_TUPLE=$PLATFORM_TUPLE-386
fi
echo "platform: $PLATFORM_TUPLE"
}

function download_and_install_release() {
curl -L $1 > f
tar zxf f
if [[ -z "${CI_BIN}" ]]; then
install "dolt-$PLATFORM_TUPLE/bin/dolt" "$CI_BIN"
else
[ -d /usr/local/bin ] || install -o 0 -g 0 -d /usr/local/bin
sudo install -o 0 -g 0 "dolt-$PLATFORM_TUPLE/bin/dolt /usr/local/bin"
fi
}

# ensure that we have a clean working change set before we begin
Expand All @@ -43,56 +77,57 @@ if [[ $(git diff --stat) != '' ]]; then
exit 1
fi

# copy all the test files to take them out of source control
# when we checkout different Dolt releases we don't want to
# delete our environment
test_env="env_test"
rm -r $test_env
mkdir $test_env
cp -r test_files/* $test_env
pushd $test_env > /dev/null || exit
# copy all the test files to create test_env
TEST_ENV="env_test"
rm -r $TEST_ENV
mkdir $TEST_ENV
cp -r test_files/* $TEST_ENV
pushd $TEST_ENV > /dev/null || exit

TOP_DIR=$(pwd)
STARTING_BRANCH=$(git rev-parse --abbrev-ref HEAD)
DOLT_DIR="../../../go/cmd/dolt/"
STATUS=0

top_dir=$(pwd)
starting_branch=$(git rev-parse --abbrev-ref HEAD)
dolt_dir="../../../go/cmd/dolt/"
# Set the PLATFORM_TUPLE var
assert_linux_or_macos

# for each legacy version, setup a repository
# using dolt built from the current branch
build_dolt "$starting_branch"
while IFS= read -r ver
build_dolt "$STARTING_BRANCH"
while IFS= read -r VER
do
setup_dir "$ver-forward_compat"
setup_dir "$VER-forward_compat"
done < <(grep -v '^ *#' < dolt_versions.txt)

status=0

while IFS= read -r ver
while IFS= read -r VER
do
build_dolt "$ver"
setup_dir "$ver-backward_compat"
download_and_install_release "https://github.com/liquidata-inc/dolt/releases/download/$VER/dolt-$PLATFORM_TUPLE.tar.gz"
setup_dir "$VER-backward_compat"

# run compatibility.bats to ensure dolt @ $ver can
# run compatibility.bats to ensure dolt @ $VER can
# read a repo created with dolt @ HEAD
echo
echo "testing dolt @ $(git describe --tags) against repo in $ver-forward_compat/"
run_bats_tests "$ver-forward_compat"
status=$((status+$?))
echo "testing dolt @ $(dolt version) against repo in $VER-forward_compat/"
run_bats_tests "$VER-forward_compat"
STATUS=$((STATUS+$?))
echo
done < <(grep -v '^ *#' < dolt_versions.txt)

# now build dolt @ HEAD and make sure we can read
# all of the legacy repositories we created
build_dolt "$starting_branch"
build_dolt "$STARTING_BRANCH"

while IFS= read -r ver
while IFS= read -r VER
do
echo
echo "testing dolt @ $(git rev-parse --abbrev-ref HEAD) against repo in $ver-backward_compat/"
run_bats_tests "$ver-backward_compat"
status=$((status+$?))
echo "testing dolt @ $(git rev-parse --abbrev-ref HEAD) against repo in $VER-backward_compat/"
run_bats_tests "$VER-backward_compat"
STATUS=$((STATUS+$?))
echo
done < <(grep -v '^ *#' < dolt_versions.txt)

popd > /dev/null || exit

exit $status
exit $STATUS

0 comments on commit b6b0506

Please sign in to comment.