Development¶
Local environment¶
Installing dependencies¶
Backend¶
Requirements when using SQLite database:
pip install -r requirements.txt -r requirements-dev.txt
Requirements when using PostgreSQL database:
pip install -r requirements.txt -r requirements-dev.txt -r requirements-postgres.txt
If You want to develop using other database, please check SQLAlchemy supported dialects.
Frontend¶
- Requirements:
- Node.js
- Yarn
To install frontend requirements run:
cd frontend && yarn install
Running application¶
Web Server¶
Running app with SQLite database:
rfhub2
Running app with PostgreSQL database:
RFHUB_DB_URI=postgresql://postgres:postgres@localhost:5432/postgres rfhub2
CLI¶
Populating application running on localhost:
rfhub2-cli ../your_repo ../your_other_repo
Populating application running on another host, with non-default credentials:
rfhub2-cli -a http://your_host:8000 -u user -p password ../your_repo ../your_other_repo
Populating app but skipping loading RFWK installed libraries:
rfhub2-cli --no-installed-keywords ../your_repo ../your_other_repo
Preserving already loaded collections and adding new ones:
rfhub2-cli -l append ../your_repo ../your_other_repo
Flushing the database and populating app with collections from provided paths:
rfhub2-cli --load-mode=insert ../your_repo ../your_other_repo
Frontend¶
To run frontend development server execute:
cd frontend && yarn start
To create frontend build run:
yarn build
To create frontend build and add its files to rfhub2 package static files directory execute:
./build_ui.sh
Running tests¶
Unit tests¶
To run unit tests simply run:
python -m unittest tests
To run unit tests, collect coverage data and create html report from it run:
python -m coverage run --source rfhub2 -m unittest -b tests && coverage html
Formatting¶
Black is used for code formatting. Checking it is included in CI pipeline. To reformat code after edit, execute:
black -t py36 rfhub2 tests
You can consider adding a git hook or integrating it with your IDE for automated execution.
Database migrations¶
To create migration file execute:
PYTHONPATH=. alembic -c rfhub2/alembic.ini revision --autogenerate -m "Your revision name"
Before committing, inspect generated file to make sure that revision contains only relevant changes to the schema.
Creating sphinx documentation¶
Application is connected with Read The Docs which are updated with every release with documentation from rfhub2/docs/source.
To create documentation on local environment, run:
cd docs && make html
Documentation will be built in rfhub2/docs/_build/html. Opening index.html will show its content in browser.
Docker¶
Building application¶
Building with SQLite database:
docker build -f docker/Dockerfile -t rfhub2 .
Building with PostgreSQL database:
docker build -f docker/Dockerfile-postgres -t rfhub2:postgres .
Running application¶
To run application with SQlite database execute:
docker run -it -p 8000:8000 rfhub2
To run application with postgreSQL database execute:
docker run -it -p 8000:8000 --network=host -e RFHUB_DB_URI="postgresql://postgres:postgres@localhost:5432/postgres" rfhub2:postgres
Rfhub2-cli limitation with Docker¶
While running web server using docker is really easy and advised, running rfhub2-cli is cumbersome. CLI is using internal robotframework tool called LibDoc, which requires each library to be installed, in order to create documentation and, later, populating app.