Merge pull request #1 from pamelafox/workflow
Browse files- .coverage +0 -0
- .github/workflows/check.yaml +43 -0
- README.md +10 -2
- requirements-dev.txt +3 -2
.coverage
ADDED
|
Binary file (53.2 kB). View file
|
|
|
.github/workflows/check.yaml
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Python checks
|
| 2 |
+
on: [push, pull_request]
|
| 3 |
+
|
| 4 |
+
jobs:
|
| 5 |
+
build:
|
| 6 |
+
runs-on: ubuntu-latest
|
| 7 |
+
services:
|
| 8 |
+
postgres:
|
| 9 |
+
image: postgres:11
|
| 10 |
+
env:
|
| 11 |
+
POSTGRES_PASSWORD: postgres
|
| 12 |
+
ports:
|
| 13 |
+
- 5432:5432
|
| 14 |
+
# needed because the postgres container does not provide a healthcheck
|
| 15 |
+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
| 16 |
+
steps:
|
| 17 |
+
- uses: actions/checkout@v3
|
| 18 |
+
- name: Set up Python 3
|
| 19 |
+
uses: actions/setup-python@v3
|
| 20 |
+
with:
|
| 21 |
+
python-version: 3.9
|
| 22 |
+
- name: Install dependencies
|
| 23 |
+
run: |
|
| 24 |
+
python -m pip install --upgrade pip
|
| 25 |
+
pip install -r requirements-dev.txt
|
| 26 |
+
- name: Lint with flake8
|
| 27 |
+
run: |
|
| 28 |
+
# stop the build if there are Python syntax errors or undefined names
|
| 29 |
+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
| 30 |
+
# exit-zero treats all errors as warnings.
|
| 31 |
+
flake8 . --count --exit-zero --statistics
|
| 32 |
+
- name: Check formatting with black
|
| 33 |
+
uses: psf/black@stable
|
| 34 |
+
with:
|
| 35 |
+
src: ". quizsite/ quizzes/"
|
| 36 |
+
options: "--check --verbose"
|
| 37 |
+
- name: Run unit tests
|
| 38 |
+
env:
|
| 39 |
+
DBUSER: postgres
|
| 40 |
+
DBPASS: postgres
|
| 41 |
+
run: |
|
| 42 |
+
coverage run --source='.' manage.py test quizzes
|
| 43 |
+
coverage report
|
README.md
CHANGED
|
@@ -12,10 +12,11 @@ https://django-example-quizsite.azurewebsites.net/quizzes/
|
|
| 12 |
|
| 13 |
## Local development
|
| 14 |
|
| 15 |
-
Install the requirements:
|
| 16 |
|
| 17 |
```
|
| 18 |
pip install -r requirements-dev.txt
|
|
|
|
| 19 |
```
|
| 20 |
|
| 21 |
Create a local PostGreSQL database called "quizsite"
|
|
@@ -33,6 +34,13 @@ Run the local server:
|
|
| 33 |
python manage.py runserver
|
| 34 |
```
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
## Deployment
|
| 37 |
|
| 38 |
The app is currently hosted on Microsoft Azure. Specifically:
|
|
@@ -42,4 +50,4 @@ The app is currently hosted on Microsoft Azure. Specifically:
|
|
| 42 |
|
| 43 |
To deploy your own instance, follow the [tutorial for Django app + PostGreSQL deployment](https://docs.microsoft.com/en-us/azure/app-service/tutorial-python-postgresql-app?tabs=django%2Cwindows%2Cvscode-aztools%2Cterminal-bash%2Cazure-portal-access%2Cvscode-aztools-deploy%2Cdeploy-instructions-azportal%2Cdeploy-instructions--zip-azcli%2Cdeploy-instructions-curl-bash) but using this app instead of the sample app.
|
| 44 |
|
| 45 |
-
Make sure you specify the following environment variables in the App Service configuration: `DBHOST`, `DBNAME`, `DBPASS`, `DBUSER`. The previously linked tutorial shows how to set these.
|
|
|
|
| 12 |
|
| 13 |
## Local development
|
| 14 |
|
| 15 |
+
Install the requirements and Git hooks:
|
| 16 |
|
| 17 |
```
|
| 18 |
pip install -r requirements-dev.txt
|
| 19 |
+
pre-commit install
|
| 20 |
```
|
| 21 |
|
| 22 |
Create a local PostGreSQL database called "quizsite"
|
|
|
|
| 34 |
python manage.py runserver
|
| 35 |
```
|
| 36 |
|
| 37 |
+
Run tests:
|
| 38 |
+
|
| 39 |
+
```
|
| 40 |
+
coverage run --source='.' manage.py test quizzes
|
| 41 |
+
coverage report
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
## Deployment
|
| 45 |
|
| 46 |
The app is currently hosted on Microsoft Azure. Specifically:
|
|
|
|
| 50 |
|
| 51 |
To deploy your own instance, follow the [tutorial for Django app + PostGreSQL deployment](https://docs.microsoft.com/en-us/azure/app-service/tutorial-python-postgresql-app?tabs=django%2Cwindows%2Cvscode-aztools%2Cterminal-bash%2Cazure-portal-access%2Cvscode-aztools-deploy%2Cdeploy-instructions-azportal%2Cdeploy-instructions--zip-azcli%2Cdeploy-instructions-curl-bash) but using this app instead of the sample app.
|
| 52 |
|
| 53 |
+
Make sure you specify the following environment variables in the App Service configuration: `DBHOST`, `DBNAME`, `DBPASS`, `DBUSER`. The previously linked tutorial shows how to set these.
|
requirements-dev.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
-r requirements.txt
|
| 2 |
-
black
|
| 3 |
pre-commit
|
| 4 |
-
flake8
|
|
|
|
|
|
| 1 |
-r requirements.txt
|
| 2 |
+
black
|
| 3 |
pre-commit
|
| 4 |
+
flake8
|
| 5 |
+
coverage
|