Skip to content

Commit

Permalink
Merge pull request #304 from otiai10/fix/freebsd-test
Browse files Browse the repository at this point in the history
Fix FreeBSD Test
  • Loading branch information
otiai10 committed Mar 12, 2024
2 parents 2450fdc + 8375442 commit a10f3d9
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 102 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/runtime-vagrant.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/runtime-vmactions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: BSD Test

on:
push:
branches:
- main
- develop
- bsd/*

jobs:
free_bsd_test:
runs-on: ubuntu-latest
name: A job to run test in FreeBSD
env:
GOPATH: /home/runner/go
steps:
- uses: actions/checkout@v4
- name: Test in FreeBSD
id: test
uses: vmactions/freebsd-vm@v1
with:
envs: 'GOPATH'
usesh: true
prepare: |
pkg install -y curl tesseract tesseract-data git go
run: |
freebsd-version
mkdir -p ${GOPATH}/src/github.com/otiai10
cp -r . ${GOPATH}/src/github.com/otiai10/gosseract
cd ${GOPATH}/src/github.com/otiai10/gosseract
go get -v -t -d ./...
go test -v -cover ./...
90 changes: 48 additions & 42 deletions test/runtime
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The "runtime test" is to test gosseract package in specific environments,
such as OS, Go version and Tesseract version.
Options:
--driver|-d {name} Specify VM driver software, either of [docker, vagrant].
--driver|-d {name} Specify VM driver software, either of [docker].
--build|-b Build testable images if provided, otherwise pull images.
--no-cache|-c Build testable images without layer cache (only available with -b)
--push|-p Push local images to dockerhub (for development purpose).
Expand Down Expand Up @@ -158,43 +158,49 @@ function test_docker_runtimes() {
# }}}

# {{{ Runner function for "--driver vagrant"
function test_vagrant_runtimes() {
if [ -n "${LIST}" ]; then
echo "Available runtimes (vagrant):"
for runtime in `ls ${PROJDIR}/test/runtimes/*.Vagrantfile`; do
testcase=`basename ${runtime} | sed -e s/\.Vagrantfile$//`
echo " ${testcase}"
done
return 0
fi

for runtime in `ls ${PROJDIR}/test/runtimes/*.Vagrantfile`; do
testcase=`basename ${runtime} | sed -e s/\.Vagrantfile$//`
if [ -n "${MATCH}" ]; then
if [[ "${testcase}" != *${MATCH}* ]]; then continue; fi
fi
echo "┌───────────── ${testcase}"
echo "│ [Vagrant] Making VM up..."
vboxname=gosseract-test-${testcase}
VAGRANT_VAGRANTFILE=${runtime} VIRTUALBOX_NAME=${vboxname} vagrant up --provision --provider virtualbox # | sed "s/^/│ /"
TESTRESULT="${?}"
if [ "${TESTRESULT}" != "0" ]; then
echo "│ [Vagrant] An error detected while upping VM"
fi
echo "│ [Vagrant] Stopping VM..."
VAGRANT_VAGRANTFILE=${runtime} vagrant halt # | sed "s/^/│ /"
if [ -n "${REMOVE}" ]; then
echo "│ [Vagrant] Removing VM..."
VAGRANT_VAGRANTFILE=${runtime} vagrant destroy -f # | sed "s/^/│ /"
fi
if [ "${TESTRESULT}" != "0" ]; then
printf "${BOLD_RED}RUNTIME TEST FAILED! ${testcase}${RESET}\n"
printf "└───────────── ${testcase} ${BOLD_RED}[NG]${RESET}\n"
exit 1
fi
printf "└───────────── ${testcase} ${BOLD_GREEN}[OK]${RESET}\n"
done
}
# function test_vagrant_runtimes() {
# if [ -n "${LIST}" ]; then
# echo "Available runtimes (vagrant):"
# for runtime in `ls ${PROJDIR}/test/runtimes/*.Vagrantfile`; do
# testcase=`basename ${runtime} | sed -e s/\.Vagrantfile$//`
# echo " ${testcase}"
# done
# return 0
# fi
#
# for runtime in `ls ${PROJDIR}/test/runtimes/*.Vagrantfile`; do
# testcase=`basename ${runtime} | sed -e s/\.Vagrantfile$//`
# if [ -n "${MATCH}" ]; then
# if [[ "${testcase}" != *${MATCH}* ]]; then continue; fi
# fi
# echo "┌───────────── ${testcase}"
# echo "│ [Vagrant] Making VM up..."
# vboxname=gosseract-test-${testcase}
# VAGRANT_VAGRANTFILE=${runtime} VIRTUALBOX_NAME=${vboxname} vagrant up ${VAGRANT_DEBUG} --provision --provider virtualbox # | sed "s/^/│ /"
# TESTRESULT="${?}"
# echo "[DEBUG] VAGRANT_VAGRANTFILE: " ${runtime}
# echo "[DEBUG] VIRTUALBOX_NAME: " ${vboxname}
# VAGRANT_VAGRANTFILE=${runtime} VIRTUALBOX_NAME=${vboxname} vagrant ssh-config
# echo "[DEBUG] ssh"
# VAGRANT_VAGRANTFILE=${runtime} VIRTUALBOX_NAME=${vboxname} vagrant ssh -c "echo 'Hello, world!'"
# echo "[DEBUG] /end"
# if [ "${TESTRESULT}" != "0" ]; then
# echo "│ [Vagrant] An error detected while upping VM"
# fi
# echo "│ [Vagrant] Stopping VM..."
# VAGRANT_VAGRANTFILE=${runtime} vagrant halt # | sed "s/^/│ /"
# if [ -n "${REMOVE}" ]; then
# echo "│ [Vagrant] Removing VM..."
# VAGRANT_VAGRANTFILE=${runtime} vagrant destroy -f # | sed "s/^/│ /"
# fi
# if [ "${TESTRESULT}" != "0" ]; then
# printf "│ ${BOLD_RED}RUNTIME TEST FAILED! ${testcase}${RESET}\n"
# printf "└───────────── ${testcase} ${BOLD_RED}[NG]${RESET}\n"
# exit 1
# fi
# printf "└───────────── ${testcase} ${BOLD_GREEN}[OK]${RESET}\n"
# done
# }
# }}}

# {{{ Main procedure
Expand All @@ -204,12 +210,12 @@ function __main__() {
docker)
test_docker_runtimes
;;
vagrant)
test_vagrant_runtimes
;;
# vagrant)
# test_vagrant_runtimes
# ;;
*)
test_docker_runtimes
test_vagrant_runtimes
# test_vagrant_runtimes
;;
esac
}
Expand Down
33 changes: 0 additions & 33 deletions test/runtimes/freebsd.Vagrantfile

This file was deleted.

0 comments on commit a10f3d9

Please sign in to comment.