sfbrigade / intentional-walk-server

12 stars 8 forks source link

Intentional Walk Server

Coverage Status

API

See Wiki

Docker-based Development Setup

  1. Install Docker Desktop: https://www.docker.com/products/docker-desktop

    1. If you have Windows Home Edition, you will need to install Docker Toolbox instead. See the troubleshooting notes below.
  2. Copy example.env to .env and edit the Docker environment variables as needed.

  3. Open a command-line shell, change into your repo directory, and execute this command:

    $ docker-compose up

    It will take a while the first time you run this command to download and build the images to run the web application code in a Docker "container". In addition, random database data is generated during this process.

  4. Now you should be able to open the web app in your browser at: http://localhost:8000/

    1. If you had to install Docker Toolbox, then replace "localhost" with the IP address of the Docker Virtual Machine.
  5. To stop the server, press CONTROL-C in the window with the running server. If it is successful, you will see something like this:

    Killing intentional-walk-server_db_1           ... done
    Killing intentional-walk-server_server_1       ... done

    If it is not successful, you may see something like this:

    ERROR: Aborting.

    If you get an error, the server may still be running on your computer. To force it to stop, run the following command and wait for the output to report DONE:

    $ docker-compose stop
    Stopping intentional-walk-server_db_1          ... done
    Stopping intentional-walk-server_server_1      ... done

Server management commands

Note: see the instructions in the next quick reference section to start/log in to a running server container and perform the following actions within the container CLI.

Testing

This project uses pytest for testing. Tests are located in the tests directory.

To run tests, invoke the following command in a docker terminal connected to the container:

make test

To generate a code coverage report to see which parts of the code are covered by the tests. This is done with the following command:

make coverage

This runs the tests, generates a coverage report and displays a nice HTML direcotry htmlcov. You can view this report on http://localhost:8001/. Be sure to manually refresh the page each time you run make coverage.

Heroku deployment info

Docker Command Quick Reference

Docker Troubleshooting

Requirements

The Heroku buildpack for python requires the existence of a requirements.txt file. However, we use poetry (and its associated requirements file, pyproject.toml) to run coverage tests in TravisCI. Keeping the two package lists in sync is difficult to manage manually; instead we export a requirements.txt file from poetry with:

poetry add {NEW_PACKAGE}
poetry export -f requirements.txt --without-hashes > requirements.txt