Skip to content

Commit 675dc91

Browse files
committed
run pytest in CI, remove standalone manage container
- run pytest in CI - scrap the standalone manage container - run console commands against app container - update docs
1 parent f6eddc6 commit 675dc91

File tree

3 files changed

+15
-32
lines changed

3 files changed

+15
-32
lines changed

.github/workflows/test.yml

+3-11
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,10 @@ jobs:
1717
- name: Run application
1818
run: docker-compose up -d web
1919

20-
- name: Test Resources
21-
run: docker-compose run --rm manage test resources
22-
if: always()
23-
24-
- name: Test Users
25-
run: docker-compose run --rm manage test users
26-
if: always()
27-
28-
- name: Test UserAuth
29-
run: docker-compose run --rm manage test userauth
20+
- name: Run test suite
21+
run: docker-compose run -T --rm app pytest -v
3022
if: always()
3123

3224
- name: Check Migrations are up-to-date
33-
run: docker-compose run --rm manage makemigrations --check
25+
run: docker-compose run -T --rm app ./manage.py makemigrations --check
3426
if: always()

README.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ To stop the application and remove all containers, run the following.
5959
docker-compose down
6060
```
6161

62-
5. Create a superuser so that you can log into http://localhost:8000/admin by running the following in your terminal: `$ docker-compose run --rm manage createsuperuser`
62+
5. Create a superuser so that you can log into http://localhost:8000/admin by running the following in your terminal: `$ docker-compose run --rm app ./manage.py createsuperuser`
6363

6464
## Editing Code
6565

@@ -89,17 +89,22 @@ If you would like to tail the logs in the console then you remove the detach fla
8989

9090
The following are examples of some common Django management commands that you may need to run.
9191

92-
* Make Migrations: `docker-compose run --rm manage makemigrations`
93-
* Merge Migrations: `docker-compose run --rm manage makemigrations --merge`
94-
* Run Migrations: `docker-compose run --rm manage`
95-
* Test: `docker-compose run --rm manage test`
92+
* Make Migrations: `docker-compose run --rm app ./manage.py makemigrations`
93+
* Merge Migrations: `docker-compose run --rm app ./manage.py makemigrations --merge`
94+
* Run Migrations: `docker-compose run --rm app ./manage.py`
9695

9796
To see the full list of management commands use `help`.
9897

9998
```plain
100-
docker-compose run --rm manage help
99+
docker-compose run --rm app ./manage.py help
101100
```
102101

102+
### Automated Tests
103+
104+
* We use [pytest](https://docs.pytest.org/en/latest/contents.html) with the [pytest-django](https://pytest-django.readthedocs.io/en/latest/) plugin for running tests.
105+
* Please add tests for your code when contributing.
106+
* Run the test suite using `docker-compose run --rm app pytest`
107+
103108
### Import Postman collection
104109
Postman is a free interactive tool for verifying the APIs of your project. You can download it at postman.com/downloads.
105110

docker-compose.yaml

+1-15
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ services:
3333
sh -c "python /opt/codebuddies/manage.py collectstatic --clear --no-input &&
3434
python /opt/codebuddies/manage.py migrate &&
3535
uwsgi --ini /opt/codebuddies/uwsgi.ini"
36+
working_dir: /opt/codebuddies
3637
volumes:
3738
- ./project:/opt/codebuddies
3839
environment:
@@ -76,18 +77,3 @@ services:
7677
restart: on-failure
7778
ports:
7879
- 8025:8025
79-
80-
# Manager allows you to run Django management tasks on the application.
81-
manage:
82-
container_name: manage
83-
restart: on-failure
84-
build: ./project
85-
command: shell
86-
entrypoint: /usr/local/bin/python3 /opt/codebuddies/manage.py
87-
volumes:
88-
- ./project:/opt/codebuddies
89-
environment:
90-
- DATABASE_URL=postgres://babyyoda:mysecretpassword@db:5432/codebuddies
91-
- EMAIL_HOST=mailhog
92-
depends_on:
93-
- db

0 commit comments

Comments
 (0)