Skip to content

Development Environment Setup

Simon Riedener edited this page Sep 2, 2017 · 3 revisions

Local development setup

Install required tools

  1. Go to https://www.jetbrains.com/idea/download/#section=windows, download latest IntelliJ IDEA and install it
  2. Go to https://www.python.org/downloads/, download latest Python version and install it (incl. pip)
  3. Go to https://git-scm.com/downloads, download latest GIT version and install it
  4. Add path to Python and pip to User variables --> PATH (This allows you to access both from everywhere in the command line tool)
    1. E.g. C:\Python\Python36-32\ (for Python)
    2. E.g. C:\Python\Python36-32\Scripts\ (for pip)

Set up koalixCRM in IntelliJ

  1. Start IntelliJ open Configure --> Settings
    1. Version Control --> Git --> Point 'Path to Git executable' to the Git installation directory (git.exe)
    2. Plugins --> Browse repositories... --> search for Python and install it
    3. Editor --> General --> Auto Import --> Python --> select 'Show import popup' and 'from import '
  2. Close Settings and check out koalixCRM from GitHub:
    1. Click on Check out from Version Control --> GitHub (do not import repository it direcectly when you asked to do it)
    2. Click on Import Project --> choose root directory of checked out project --> OK --> Create project from existing sources --> Next --> Next --> Next --> choose Python SDK (python.exe) from the Python installation target directory --> Next --> select Django framework --> Finish
  3. Connect to SQLite Database
    1. Open 'Database' tool window: Go to View --> Tool Windows --> Database
    2. Connect to SQLite DB from the opened database tool window: Click green plus icon --> Data Source --> Sqlite (Xerial) and enter path to db.sqlite3 file in te input field 'File'. This file will be generated at the following path: <>/sandbox/db.sqlite3
  4. Run koalixCRM locally by execution of the folling commands in the IntelliJ terminal
    1. pip install -r requirements.txt
    2. python setup.py install
    3. python manage.py collectstatic --noinput
    4. python manage.py makemigrations
    5. python manage.py migrate
    6. python manage.py createsuperuser (you will be asked to set credentials for the new administator user for koalixCRM)
    7. python manage.py runserver
    8. Open koalixCRM (http://127.0.0.1:8000/admin) in the web browser

Travis CI

Build project with Travis CI

The continious build is realized with Travis CI (https://travis-ci.org/). GitHub provides an app in the Marketplace to set up the connection between GitHub and Travis. Travis builds can be configured by .travis.yml file which has to be located in the root directory of your project.

Step by step guide

  1. Add Travis to your GitHub account.
    1. Log in to your GitHub account.
    2. Go to Marketplace (accessible from the header menu bar).
    3. Search for Travis CI app and install the open source version.
  2. Create a Travis build job for your desired repository
    1. Go to https://travis-ci.org/ sign in with GitHub
    2. In the left side bar, you can see the already added repository to Travis services. Click on '+'-icon and enable the repository which you want to build with Travis in the list of repositories (toggle button).
    3. Go back to the previous page. Here you should see now the new repository you've added in the left side bar. The job isn't running yet since this is triggered by the commits on your repository.
  3. Create configuration file for Travis builds Travis builds require a configuration file '.travis.yml' in the root directory of your project. KoalixCrm already has this configuration file included in the project. If you want to set up a new project with Travis CI build you have to create this file.

Travis configuration in .travis.yml file for build step

To get the Travis build running, the following minimum configuration has to be defined:

language: python
python:
    - '3.4'
install: pip install -r requirements.txt
script: pytest

For further information about the configuration of Travis, have a look at the Travis documentation page: https://docs.travis-ci.com/user/customizing-the-build/

Deploy project with Travis CI on Heroku

Connect Travis to Heroku

Travis has to set up an connection to Heroku to be able to deploy the application.

  1. Get Heroku API Key
    1. Login to your Heroku account
    2. Go to Account settings, scroll down to 'API Key' and click 'Reveal' --> Your API Key will be displayed
    3. Copy this API Key to your clipboard
  2. Configure Heroku API Key in Travis
    1. Login to your Travis account
    2. Select the repository which you want to deploy on Heroku
    3. Go to More options --> Settings, scroll down to 'Environment Variables' and add a new variable with:
      • Name: HEROKU_API_KEY
      • Value: the Heroku API Key from step 1
      • Display value in build log: disabled

Travis configuration in .travis.yml

The deployment of the application has to be configured in .travis.yml file too. For koalixCRM the following code has to be added to .travis.yml:

deploy:
  provider: heroku
  api_key:
    secure: $HEROKU_API_KEY
  app: koalix-crm
  on:
    repo: scaphilo/koalixcrm

Explanations:

  • provider: Defines the target provider name where you want to deploy the application
  • api_key: Is defined by the placeholder $HEROKU_API_KEY. The key will be replaced by the environment variable which is set in the Travis repository settings (see chapter 'Connect Travis to Heroku').
  • app: Defines the name of the project on Heroku
  • repo: Defines the repository where the application code is located.