Skip to content

Contribute

Korkmatik edited this page Nov 7, 2020 · 4 revisions

Setting up a development environment

First of all clone the repository:

git clone https://github.com/Korkmatik/SanPlan.git

Next build the docker images:

docker-compose up --build

After the build has finished you should create the database tables. For this run the following command:

docker-compose run web sh -c "python manage.py makemigrations && python manage.py migrate"

Now you can navigate to the localhost:8000 and you should see the web page.

To create a Python virtualenv you should have pipenv installed. Go into the web directory inside the SanPlan project:

cd web

Now run the following pipenv command:

pipenv install

This will create a virtualenvironment and install all the requirements inside the requirements.txt

Creating an admin user

To create an admin user you should be in the web folder of the SanPlan project:

cd web

Now you can run the following command:

docker-compose run web python manage.py createsuperuser

After that the dialog will guide you through the creation of the admin user. With this user you can log into the web app and you can also log into the Djano admin page which is under /admin

Testing

Running tests

To run the tests you can run the following command:

docker-compose run web sh -c "python manage.py makemigrations && python manage.py migrate && python manage.py test"

This command will run all tests. If you only want to run tests for a specific app then run the following command:

docker-compose run web sh -c "python manage.py makemigrations && python manage.py migrate && python manage.py test APP_NAME"

For example:

docker-compose run web sh -c "python manage.py makemigrations && python manage.py migrate && python manage.py test vehicles"

If you are developing on windows, there is a Script in the root of the repository. This Script is called runTests.bat. This Script will run all tests.

It is mandatory that all tests pass before code changes will be merged into master!

Running coverage

To run coverage and tests you have to run the following command:

docker-compose run web sh -c "python manage.py makemigrations && python manage.py migrate && coverage erase && coverage run manage.py test && coverage report"

This command will run all tets and if all tests pass this command will show the coverage report. If you are developing on Windows you can use the runCoverage.bat Script. This Script runs the above command.

It is mandatory that the test coverage is not below 100%. Otherwise it won't be able to merge the changes to master.

Running Style Checks

To run the style checks, run the following command:

docker-compose run web sh -c "flake8 ."

This will display lines and files where the code does not following code style conventions. If you are developing on Windows you can run runStyleChecks.bat Script. This Script runs the above command.

It is mandatory that the code follows code style conventions. Otherwise it won't be possible to merge into master.

Pipeline

The CI Pipeline runs tests, coverage and style checks against the code. If you want to run all these steps locally you can use the runPipeline.bat Script.