ci_pushbuild.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/bash
  2. #
  3. ## bacillus (https://gogs.blitter.com/Russtopia/bacillus) build/test CI script
  4. export GOPATH="${HOME}/go"
  5. export PATH=/usr/local/bin:/usr/bin:/usr/lib/ccache/bin:/bin:$GOPATH/bin
  6. export GO111MODULE=on
  7. # GOCACHE will be phased out in v1.12. [github.com/golang/go/issues/26809]
  8. export GOCACHE="${HOME}/.cache/go-build"
  9. echo "workdir: ${BACILLUS_WORKDIR}"
  10. mkdir -p "${BACILLUS_ARTFDIR}"
  11. echo "---"
  12. go env
  13. echo "---"
  14. echo "passed env:"
  15. env
  16. echo "---"
  17. cd ${REPO}
  18. branch=$(git for-each-ref --sort=-committerdate --format='%(refname)' | head -n 1)
  19. echo "Building most recent push on branch $branch"
  20. git checkout "$branch"
  21. ls
  22. ############
  23. stage "Build"
  24. ############
  25. make all
  26. ############
  27. stage "UnitTests"
  28. ############
  29. go test -v .
  30. ############
  31. stage "Test(Authtoken)"
  32. ############
  33. if [ -f ~/.xs_id ]; then
  34. echo "Clearing test user $USER ~/.xs_id file ..."
  35. mv ~/.xs_id ~/.xs_id.bak
  36. fi
  37. echo "Setting dummy authtoken in ~/.xs_id ..."
  38. echo "localhost:${USER}:asdfasdfasdf" >~/.xs_id
  39. echo "Performing remote command on @localhost via authtoken login ..."
  40. tokentest=$(timeout 10 xs -x "echo -n FOO" @localhost)
  41. if [ "${tokentest}" != "FOO" ]; then
  42. echo "AUTHTOKEN LOGIN FAILED"
  43. exit 1
  44. else
  45. echo "client cmd performed OK."
  46. unset tokentest
  47. fi
  48. ############
  49. stage "Test(xc S->C)"
  50. ############
  51. echo "Testing secure copy from server -> client ..."
  52. ./xc_testfiles.sh
  53. tmpdir=$$
  54. mkdir -p /tmp/$tmpdir
  55. cd /tmp/$tmpdir
  56. xc @localhost:${BACILLUS_WORKDIR}/build/xs/cptest .
  57. echo -n "Integrity check on copied files (sha1sum) ..."
  58. sha1sum $(find cptest -type f | sort) >sc.sha1sum
  59. diff sc.sha1sum ${BACILLUS_WORKDIR}/build/xs/cptest.sha1sum
  60. stat=$?
  61. cd -
  62. rm -rf /tmp/$tmpdir
  63. if [ $stat -eq "0" ]; then
  64. echo "OK."
  65. else
  66. echo "FAILED!"
  67. exit $stat
  68. fi
  69. ############
  70. stage "Test(xc C->S)"
  71. ############
  72. echo "TODO ..."
  73. if [ -f ~/.xs_id.bak ]; then
  74. echo "Restoring test user $USER ~/.xs_id file ..."
  75. mv ~/.xs_id.bak ~/.xs_id
  76. fi
  77. ############
  78. stage "Lint"
  79. ############
  80. make lint
  81. ############
  82. stage "Artifacts"
  83. ############
  84. echo -n "Creating tarfile ..."
  85. tar -cz --exclude=.git --exclude=cptest -f ${BACILLUS_ARTFDIR}/xs.tgz .
  86. ############
  87. stage "Cleanup"
  88. ############
  89. rm -rf cptest
  90. echo
  91. echo "--Done--"