LEGO Er Ganske Oppdelt
We use GitHub issues and project boards for simple project management.
docker-compose. Services like Postgres, Redis,
Elasticsearch, Thumbor and Minio run inside docker.
$ git clone email@example.com:webkom/lego.git && cd lego/ $ python3 -m venv venv $ source venv/bin/activate $ echo "from .development import *" > lego/settings/local.py $ pip install -r requirements/dev.txt $ docker-compose up -d $ python manage.py initialize_development $ python manage.py runserver
If you get an error while installing requirements, you might be missing some dependencies on your system.
$ apt-get install libpq-dev python3-dev
If you get an error while running initialize_development mentioning
elasticsearch, you probably need run the following code, and then start over from
docker-compose up -d. Read why and how to make it permanent on Elasticsearch docs.
$ sysctl -w vm.max_map_count=262144
If you get ld: library not found for -lssl
When changing the user fixtures one must load new fixtures
./manage.py load_fixtures --generate
This codebase uses the PEP 8 code style. We enforce this with isort, yapf & flake8.
In addition to the standards outlined in PEP 8, we have a few guidelines
setup.cfg for more info):
- Line-length can exceed 79 characters, to 100, when convenient.
- Always use single-quoted strings (e.g. 'lego'), unless a single-quote occurs within the string.
$ isort -rc lego # Sort imports $ yapf -ir lego # Format with yapf
To check if it is formatted properly, run:
$ tox -e isort -e flake8 -e yapf
If you want to run a specific test class you can run
$ ./manage.py test lego.apps.[APP] --keepdb
By adding the
--keepdb the next time it will go a lot faster to run the tests multiple times.
If you want to check your test coverage, you can do the following
# Install the packages needed $ pip install -r requirments/coverage.txt # Run a full test run with coverage. This will run all tests in LEGO. $ coverage run --source=lego ./manage.py test # Then you can output the full coverage report $ coverage report # or a small one that only contains the things you are interested in $ coverage report | grep [some string]
Lego runs in Kubernetes and deploys are managed by Drone and Spinnaker.
How to deploy:
- Make sure the changes is pushed to master and the test passes.
- Have you added some new settings in
settings/? If so make sure the Spinnaker deployment reflects these changes.
- We run migrations automatically, make sure they work!
- Push to the
prodbranch. From master:
git push origin master:prod
Spinnaker now starts the deployment. This takes some time, tests must pass and we have to build a docker image.
We recommend Pycharm for development, use your @stud.ntnu.no email to register a free professional account.