Skip to content
GiPHouse website based on Django Framework
Python CSS HTML JavaScript Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
resources
website
.dockerignore
.gitignore
COPYING
Dockerfile
README.md
poetry.lock
pyproject.toml

README.md

GiPHouse website

Code style: black

This is the code for the website of GiPHouse powered by Django.

Getting Started

  1. Install Python 3.7 and poetry (a Python dependency manager).
  2. Clone this repository.
  3. Run poetry install to install all dependencies into virtual environment.
  4. Run poetry shell to enter the virtual environment.
  5. Run python website/manage.py migrate to initialise the database.
  6. Run python website/manage.py createsuperuser to create an admin account.
  7. Run python website/manage.py runserver to start the local testing server.

Testing, Linting and Continuous Integration

To test our code we use multiple testing methods. All of these tests are automatically run by Github Actions when a new pull request is made. All of these tests need to pass, before a pull request is allowed to be merged into the master branch.

If you want to run the tests locally, please look up the relevant test command in the CI workflow file.

Tests

The test suite can be run with the manage.py command. The following command can be executed to quickly run all the tests:

poetry run website/manage.py test

Every Django app has its own tests (located in the tests directory inside the app root). We enforce 100% statement and 100% branch coverage in our tests, to make sure that every line of code and branch is run at least once during testing. We use coverage to run and analyse these tests.

Built-in Django tests

The CI runs built-in Django tests. These tests include checking if there are any database migrations needed but not created yet and checking for common problems.

Linting

We use multiple to perform static analyis on our code. The most important one is flake8, a Python linter that checks whether code is formatted according to PEP8. In addition we also use the flake8-import-order to make sure the imports are neatly ordered. We enforce the code style of Black.

We also use pydocstyle to enforce that every method, function and class is documented and that documentation is formatted according to PEP 257.

We also use a few Bash scripts (e.g. for deployment). These are checked using shellcheck.

Loading Fixtures

To make manual testing easier, we have the createfixtures command to automatically create test data. We also test if that command works correctly.

You can create and load fixtures with the manage.py createfixtures command. The fixtures dynamically generated using the faker package.

Then you can load the courses testdata fixture with this command:

python website/manage.py createfixtures

See

python website/manage.py createfixtures --help

for more information.

Serverconfig

The GiPHouse website runs on an AWS EC2 instance. This server can be reached via SSH (only with publickey).

Some basic information about the server can be configured in the Lightsail dashboard. This includes the firewall. We opened ports 22, 80 and 443 to enable SSH, HTTP and HTTPS respectively.

Server Info

OS: Ubuntu 18.04 user: ubuntu

Continuous Deployment

Whenever a commit is merged into master, deploy.sh is executed. This scripts runs on a Github Actions runner and gets secrets through the secrets settings of this repository.

This script does the following:

  • Builds a new version of the Docker image and pushes it to the Docker Hub Registry.
  • Puts the right secrets into docker-compose.yaml and the database initialization file (setup.sql).
  • Creates all necessary directories and files on the production server.
  • Restarts the running docker containers using the new images.

Setup steps

Some manual steps are taken to setup the server. These steps are not done in the deployment script, because these steps are only necessary once.

  1. Add the SSH public keys of engineers to the authorized keys of the ubuntu user.
  2. Disable SSH password login.
  3. Install docker.
  4. Install nginx.
  5. Place the general nginx config (nginx.conf), the domain specific nginx config (giphouse.conf) and dhparam.pem.
  6. Install letsencrypt and request a certificate using the cerbot nginx module.
You can’t perform that action at this time.