Skip to main content

No project description provided

Project description

pypi travis codecov

sarscov2x

This is a sample Django application for use in a talk on how to configure your python project to use TravisCI. The production Django app for this simple Coronavirus KAP tool (Knowledge, Attitudes, and Practice) is available at sarscov2. The tool is currently being administered in Tanzania.

Installing the sample Django application

If you want, you can install the Django app. When installed you can easily inspect the .travis.yml and tox.ini and perhaps run the tests locally.

To do so, follow the steps below to create a python environment, install the dependencies, prepare the Django apps DB, create a user account, and loads a local test web server.

First, set up a python environment.

I use miniconda to build and manage my python environments. You will need to install miniconda so go to the the miniconda docs and select the installer for your OS.

After the installing miniconda, open a terminal and create a new python environment using the conda command:

conda create -n edc python=3.8

Your new python env is named “edc” and runs python 3.8.

Next, activate your new environment:

conda activate edc

Next, clone the repo into a folder, for example, projects:

mkdir ~/projects
cd  ~/projects
git clone https://github.com/erikvw/sarscov2x.git

Navigate into the repo and install the requirements:

cd ~/projects/sarscov2x
pip install -U -r requirements.txt

This is a simple Django application that uses sqlite as the DB. To create the database:

python manage.py migrate

Next, create your user account:

# run and follow the prompts
python manage.py createsuperuser

Next, start up the test webserver:

python manage.py runserver

Lastly, open your browser and navigate to:

http://localhost:8000

PEP8, tests, tox and TravisCI, code coverage

TravisCI is just part of what can be used to simplify checking your code (flake8), running all your tests against multiple environments (tox and travis) while finally checking that your test coverage is still where you want it to be.

Together with TravisCI

Integration with GitHub

https://docs.travis-ci.com/user/tutorial/#to-get-started-with-travis-ci-using-github

Configuration

The config files involved:

  • .travis.yml: read by TravisCI. Sets up OS, environment, pre-test commands, tests, post-test commands

  • tox.ini: easy way to run your tests in a fresh environment locallay and to run a matrix of environments remotely on TravisCI

  • setup.cfg: specify flake8 config. Flake8 (PEP8 rules) is good to run before your tests. Less important if you use a formatter like black.

The flow is:

  • –> git push to GitHub repo

  • –> repo change triggers TravisCI

  • –> on TravisCI all tests pass (you hope)

  • –> TravisCI hands over to CodeCov

And if all goes well, your badges turn green!

References:

https://docs.travis-ci.com/user/tutorial/

https://docs.travis-ci.com/user/tutorial/#to-get-started-with-travis-ci-using-github

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

sarscov2x-0.2.0-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

Details for the file sarscov2x-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: sarscov2x-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 33.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for sarscov2x-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7eaf16ed003c9292ea79a22b2e45e04d63d8b807ddeb88b5bf57c554c8b8766
MD5 b53de950c801f9f4c19bdf28aaf2af42
BLAKE2b-256 c3100f064dced4cf6518da66811613a0e52a1f0d52bd1e2e1e0c72bdcaec7a8d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page