Skip to content
This repository was archived by the owner on May 17, 2026. It is now read-only.

HykuAddons: Local Development

Paul Danelli edited this page Feb 18, 2022 · 3 revisions

Refer to this wiki for a guide to setting up HykuAddons and setting up the multitenancy: https://github.com/ubiquitypress/hyku_addons/wiki/Hyku:-Setup-HykuAddons

Check out the repository then initialize the internal test hyku application (if you have any issues, check out the issues section at the bottom of this article):

git submodule init
git submodule update --remote
bundle install
bundle exec rails g hyku_addons:install

# Start the containers
docker-compose up --build

# If you are using Docker, you will need to do the `hyku_addons:install` within the container
docker-compose exec web bundle exec rails g hyku_addons:install

Docker

Running a docker development environment is possible by running:

docker-compose up --build

Attaching to the hyku container to run commands can be done by running:

docker-compose exec web /bin/bash

Debugging

Byebug is installed and can be used in tests and the running rails server. You will need to start your web containers in 'detached' mode and then attach to the container to interact with byebug:

docker-compose up -d
docker attach hyku_addons_web_1

Docker Runner

Normally Rails commands like rails console and rspec are run by connecting to the main web container with a bash shell. This has several problems however, for example, if you were running your slow tests and accidentally stopped the web container, your tests would also be closed as the connection to the web container was unavailable. Another issue is that when you need to bundle install, you would normally be required to start the web container, connect to it via bash and then run bundle install, before closing the container and restarting it.

Hyku Addons docker setup has a Runner in development that allows you to run commands without the need for the main web container to be running, or worry about the process being killed part way though.

The basics of the runner are that it can be safety removed after a single command has been executed:

docker-compose run --rm runner <command>

So to run the specs you could do the following:

docker-compose run --rm runner rspec

Or if you wanted to run a long running rake task, then you could do the following:

docker-compose run --rm runner rails hyku_addons:long_running_task

Bash alias

To shorten the long command you could add the following to your ~/.bashrc:

alias dcr="docker-compose run --rm runner"

Now you can use the Runner to run the specs with the following shortened syntax:

dcr rspec

Fish function

If you use Fish shell, you can add the following to your ~/.config/fish/config.fish:

function dcr
	docker-compose run --rm runner $argv
end

Sidekiq

The easiest way to ensure sidekiq is working for your local tenant is to add queues to the sidekiq.yml in the internal_test_hyku. For a tenant called demo add the following lines to the yaml:

:queues:
  - default
  - import
  - export
  - demo_import_import
  - demo_import_default

Development Environments

If you are a using some kind of development tool, Vim, VS Code etc, because of the dependency on an older version of Rubocop, you will need to use an older version of the Ruby Language Server Solargraph:

gem install solargraph -v 0.39.17

Possible issues

If you see an error where by Zookeeper cannot be installed via Bundler, the following should work:

CFLAGS=-Wno-error=format-overflow gem install zookeeper -v '1.4.11' --source 'https://rubygems.org/'

If you get the following Postgres error "Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers", you may need to install Postgres, which on Ubuntu/Debian linux can be done with the following:

sudo apt install postgresql-server-dev-all

You can then install Postgress natively:

gem install pg -v '1.2.3' --source 'https://rubygems.org/'

Clone this wiki locally