- Install Python 3.7 and poetry (a Python dependency manager).
- Clone this repository.
poetry installto install all dependencies into virtual environment.
poetry shellto enter the virtual environment.
python website/manage.py migrateto initialise the database.
python website/manage.py createsuperuserto create an admin account.
python website/manage.py runserverto 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
If you want to run the tests locally, please look up the relevant test command in the CI workflow file.
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.
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 a few Bash scripts (e.g. for deployment). These are checked using
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
python website/manage.py createfixtures --help
for more information.
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
443 to enable SSH, HTTP and HTTPS respectively.
OS: Ubuntu 18.04
Whenever a commit is merged into
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.yamland the database initialization file (
- Creates all necessary directories and files on the production server.
- Restarts the running docker containers using the new images.
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.
- Add the SSH public keys of engineers to the authorized keys of the
- Disable SSH password login.
- Place the general
nginx.conf), the domain specific
letsencryptand request a certificate using the