- Python
- Django, Django Rest Framework
- PostgreSQL
- Docker, Docker Compose
- PyTest (with coverage)
- Deploy to remote Linux machine
- GitHub Actions for:
- Build and push image to DockerHub
- Run PyTest and show coverage results
Task statement: ./Task.md
- Activate venv
pip install -r requirements.txt
coverage run -m pytest
coverage report
orcoverage html
(for generating report in HTML)- Remove
coverage-badge.svg
file and runcoverage-badge -o coverage.svg
pip install -r requirements.txt
- Run server in Docker (see below how to run in docker) or in usual way (also see below)
python unit_test.py
- Activate venv
pip install -r requirements.txt
- Change
DOCKER
field inconfig.json
tofalse
python manage.py migrate
python manage.py runserver 0.0.0.0:80
(or other port, for example 3000)
(sudo) docker-compose up -d --build
(sudo) docker-compose exec web python manage.py migrate
- [optional]
(sudo) docker-compose exec web python manage.py createsuperuser
(sudo) docker-compose up
// to see logs
- Set
docker
field totrue
/false
(depending on if you're going to run in Docker) - Push changes to GitHub repository
git add <...>
,git commit -m <...>
,git push
- Connect to remote machine (via SSH)
ssh login@ip
. Following actions are done from remote machine git clone <this_repo_url>
cd rest-api-test-task
- For non-Docker run:
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
python3 manage.py makemigrations
python3 manage.py migrate
- For Docker-run:
docker-compose up -d --build
docker-compose exec web python manage.py makemigrations --noinput
docker-compose exec web python manage.py migrate --noinput
- [optional]
docker-compose exec web python manage.py createsuperuser
- Auto running in container:
sudo touch /etc/systemd/system/test-script.service
sudo chmod 664 /etc/systemd/system/test-script.service
sudo nano /etc/systemd/system/test-script.service
- Write file
- Write entry-point SH executor (for running with or without Docker)
sudo systemctl enable test-script.service