2020-01-29 21:25:14 +00:00
|
|
|
#!/bin/bash
|
2020-08-22 02:47:37 +00:00
|
|
|
#
|
|
|
|
## bacillus (https://gogs.blitter.com/Russtopia/bacillus) build/test CI script
|
2020-01-29 21:25:14 +00:00
|
|
|
|
|
|
|
export GOPATH="${HOME}/go"
|
2020-01-30 20:58:08 +00:00
|
|
|
export PATH=/usr/local/bin:/usr/bin:/usr/lib/ccache/bin:/bin:$GOPATH/bin
|
2022-04-10 02:48:31 +00:00
|
|
|
unset GO111MODULE
|
2024-03-02 22:46:15 +00:00
|
|
|
#export GOPROXY="direct"
|
2022-04-10 02:47:31 +00:00
|
|
|
#!# GOCACHE will be phased out in v1.12. [github.com/golang/go/issues/26809]
|
|
|
|
#!export GOCACHE="${HOME}/.cache/go-build"
|
2020-01-29 21:25:14 +00:00
|
|
|
|
2020-01-30 20:58:08 +00:00
|
|
|
echo "workdir: ${BACILLUS_WORKDIR}"
|
|
|
|
mkdir -p "${BACILLUS_ARTFDIR}"
|
|
|
|
|
2020-01-29 21:25:14 +00:00
|
|
|
echo "---"
|
|
|
|
go env
|
|
|
|
echo "---"
|
|
|
|
echo "passed env:"
|
|
|
|
env
|
|
|
|
echo "---"
|
|
|
|
|
|
|
|
cd ${REPO}
|
|
|
|
branch=$(git for-each-ref --sort=-committerdate --format='%(refname)' | head -n 1)
|
|
|
|
echo "Building most recent push on branch $branch"
|
|
|
|
git checkout "$branch"
|
|
|
|
ls
|
|
|
|
|
2020-08-22 02:47:37 +00:00
|
|
|
############
|
2020-01-29 21:25:14 +00:00
|
|
|
stage "Build"
|
2020-08-22 02:47:37 +00:00
|
|
|
############
|
2022-08-13 04:56:09 +00:00
|
|
|
echo "Invoking 'make clean' ..."
|
|
|
|
make clean
|
2022-04-09 18:50:24 +00:00
|
|
|
echo "Invoking 'make all' ..."
|
2020-01-29 21:25:14 +00:00
|
|
|
make all
|
|
|
|
|
2022-04-10 03:05:42 +00:00
|
|
|
############
|
|
|
|
stage "Lint"
|
|
|
|
############
|
|
|
|
make lint
|
|
|
|
|
2020-08-22 02:47:37 +00:00
|
|
|
############
|
2020-02-18 05:16:10 +00:00
|
|
|
stage "UnitTests"
|
2020-08-22 02:47:37 +00:00
|
|
|
############
|
2020-02-18 05:16:10 +00:00
|
|
|
go test -v .
|
|
|
|
|
2020-08-22 02:47:37 +00:00
|
|
|
############
|
2020-01-29 21:25:14 +00:00
|
|
|
stage "Test(Authtoken)"
|
2020-08-22 02:47:37 +00:00
|
|
|
############
|
2024-01-30 05:47:03 +00:00
|
|
|
if [ -f ~/.config/xs/.xs_id ]; then
|
|
|
|
echo "Clearing test user $USER .xs_id file ..."
|
|
|
|
mv ~/.config/xs/.xs_id ~/.config/xs/.xs_id.bak
|
2020-08-22 02:49:17 +00:00
|
|
|
fi
|
2024-01-30 05:47:03 +00:00
|
|
|
echo "Setting dummy authtoken in .xs_id ..."
|
|
|
|
echo "localhost:${USER}:asdfasdfasdf" >~/.config/xs/.xs_id
|
2020-01-29 21:25:14 +00:00
|
|
|
echo "Performing remote command on @localhost via authtoken login ..."
|
|
|
|
tokentest=$(timeout 10 xs -x "echo -n FOO" @localhost)
|
|
|
|
if [ "${tokentest}" != "FOO" ]; then
|
|
|
|
echo "AUTHTOKEN LOGIN FAILED"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "client cmd performed OK."
|
|
|
|
unset tokentest
|
|
|
|
fi
|
|
|
|
|
2020-08-22 02:47:37 +00:00
|
|
|
############
|
2021-01-15 08:31:36 +00:00
|
|
|
stage "Test(xc S->C)"
|
2020-08-22 02:47:37 +00:00
|
|
|
############
|
2020-01-29 21:25:14 +00:00
|
|
|
echo "Testing secure copy from server -> client ..."
|
2021-01-15 08:31:36 +00:00
|
|
|
./xc_testfiles.sh
|
2021-01-15 09:23:01 +00:00
|
|
|
|
2020-01-29 21:25:14 +00:00
|
|
|
tmpdir=$$
|
|
|
|
mkdir -p /tmp/$tmpdir
|
|
|
|
cd /tmp/$tmpdir
|
|
|
|
xc @localhost:${BACILLUS_WORKDIR}/build/xs/cptest .
|
|
|
|
echo -n "Integrity check on copied files (sha1sum) ..."
|
|
|
|
sha1sum $(find cptest -type f | sort) >sc.sha1sum
|
|
|
|
diff sc.sha1sum ${BACILLUS_WORKDIR}/build/xs/cptest.sha1sum
|
|
|
|
stat=$?
|
|
|
|
cd -
|
2020-09-14 04:51:18 +00:00
|
|
|
|
2020-01-29 21:25:14 +00:00
|
|
|
rm -rf /tmp/$tmpdir
|
|
|
|
if [ $stat -eq "0" ]; then
|
|
|
|
echo "OK."
|
|
|
|
else
|
|
|
|
echo "FAILED!"
|
|
|
|
exit $stat
|
|
|
|
fi
|
|
|
|
|
2020-08-22 02:47:37 +00:00
|
|
|
############
|
2021-01-15 08:31:36 +00:00
|
|
|
stage "Test(xc C->S)"
|
2020-08-22 02:47:37 +00:00
|
|
|
############
|
2020-01-29 21:25:14 +00:00
|
|
|
echo "TODO ..."
|
|
|
|
|
2024-01-30 05:47:03 +00:00
|
|
|
if [ -f ~/.config/xs/.xs_id.bak ]; then
|
|
|
|
echo "Restoring test user $USER .xs_id file ..."
|
|
|
|
mv ~/.config/xs/.xs_id.bak ~/.config/xs/.xs_id
|
2020-08-24 06:33:58 +00:00
|
|
|
fi
|
|
|
|
|
2020-08-22 02:47:37 +00:00
|
|
|
############
|
2020-01-29 21:25:14 +00:00
|
|
|
stage "Artifacts"
|
2020-08-22 02:47:37 +00:00
|
|
|
############
|
2020-01-29 21:25:14 +00:00
|
|
|
echo -n "Creating tarfile ..."
|
|
|
|
tar -cz --exclude=.git --exclude=cptest -f ${BACILLUS_ARTFDIR}/xs.tgz .
|
|
|
|
|
2020-08-22 02:47:37 +00:00
|
|
|
############
|
2020-01-29 21:25:14 +00:00
|
|
|
stage "Cleanup"
|
2020-08-22 02:47:37 +00:00
|
|
|
############
|
2021-01-15 08:31:36 +00:00
|
|
|
rm -rf cptest
|
2020-01-29 21:25:14 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "--Done--"
|