diff --git a/.github/workflows/runtime-vagrant.yml b/.github/workflows/runtime-vagrant.yml deleted file mode 100644 index e51c112..0000000 --- a/.github/workflows/runtime-vagrant.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Vagrant Test - -on: - workflow_dispatch: - schedule: - - cron: '0 0 * * 5' - push: - branches: [main, develop, vagrant/*] - pull_request: - branches: [main, develop] - -jobs: - vagrant-test: - runs-on: macos-12 - # runs-on: macos-latest - # @see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software - # @see https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md - strategy: - matrix: - runtime: - - freebsd - name: Vagrant ${{ matrix.runtime }} - steps: - - name: checkout - uses: actions/checkout@v4 - - name: ${{ matrix.runtime }} - run: bash ./test/runtime --driver vagrant --build --run ${{ matrix.runtime }} diff --git a/.github/workflows/runtime-vmactions.yml b/.github/workflows/runtime-vmactions.yml new file mode 100644 index 0000000..7f6d1c8 --- /dev/null +++ b/.github/workflows/runtime-vmactions.yml @@ -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 ./... diff --git a/test/runtime b/test/runtime index 0b8f3e0..c873174 100755 --- a/test/runtime +++ b/test/runtime @@ -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). @@ -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 @@ -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 } diff --git a/test/runtimes/freebsd.Vagrantfile b/test/runtimes/freebsd.Vagrantfile deleted file mode 100644 index 4b69bb0..0000000 --- a/test/runtimes/freebsd.Vagrantfile +++ /dev/null @@ -1,33 +0,0 @@ -Vagrant.configure("2") do |config| - # https://developer.hashicorp.com/vagrant/docs/synced-folders/basic_usage#disabling - config.vm.synced_folder ".", "/vagrant", disabled: true - - config.vm.guest = :freebsd - config.vm.box = "freebsd/FreeBSD-12.2-STABLE" - config.vm.base_mac = "080027D14C66" - config.ssh.shell = "sh" - # config.ssh.username = "vagrant" - # config.ssh.password = "vagrant" - - config.vm.provider :virtualbox do |vb| - vb.name = ENV["VIRTUALBOX_NAME"] - end - - # {{{ FIXME: This is ugly. - config.vm.provision :shell, :inline => 'rm -rf /home/vagrant/go/src/github.com/otiai10/gosseract' - config.vm.provision :file, source: "./", destination: "/home/vagrant/go/src/github.com/otiai10/gosseract" - # }}} - - config.vm.provision :shell, :inline => ' - pkg install -y tesseract tesseract-data git go - cd $GOPATH/src/github.com/otiai10/gosseract - go test -v -cover ./... - exit $? - ', :env => { - "GOPATH" => "/home/vagrant/go", - "TESSDATA_PREFIX" => "/usr/local/share/tessdata", - "CPATH" => "/usr/local/include", - # "LIBRARY_PATH" => "/usr/local/lib", - # "LD_LIBRARY_PATH" => "/usr/local/lib", - } -end