You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Set env variables for development](#set-env-variables-for-development)
14
+
-[Configure postgres and run the dispatcher service](#configure-postgres-and-run-the-dispatcher-service)
14
15
-[Configure and run the application](#configure-and-run-the-application)
15
16
-[Updating dependencies](#updating-dependencies)
16
-
-[Running tests, linters, and code checks](#running-tests-linters-and-code-checks)
17
+
-[Running linters and code checks](#running-linters-and-code-checks)
18
+
-[Running tests](#running-tests)
17
19
18
20
## Things to know prior to submitting code
19
21
20
22
- All code submissions are done through pull requests against the `main` branch.
21
23
- Take care to make sure no merge commits are in the submission, and use `git rebase` vs `git merge` for this reason.
22
24
- If collaborating with someone else on the same branch, consider using `--force-with-lease` instead of `--force`. This will prevent you from accidentally overwriting commits pushed by someone else. For more information, see [git push docs](https://git-scm.com/docs/git-push#git-push---force-with-leaseltrefnamegt).
23
25
- We ask all of our community members and contributors to adhere to the [Ansible code of conduct](http://docs.ansible.com/ansible/latest/community/code_of_conduct.html). If you have questions, or need assistance, please reach out to our community team at [[email protected]](mailto:[email protected])
24
-
- This repository uses a`pre-commit`, configuration, so ensure that you install pre-commit globally for your user, or by using pipx.
25
26
26
27
## Build and Run the Development Environment
27
28
@@ -47,6 +48,8 @@ Install required python modules for development
For standalone development tools written in Python, such as `pre-commit` and `pip-tools`, we recommend using your system package manager, `pipx` tool or `pip` user install mode (`pip install --user`), in decreasing order of preference.
52
+
50
53
### Set env variables for development
51
54
52
55
Either create a .env file in the project root containing the following env variables, or export them to your shell env:
@@ -55,8 +58,29 @@ Either create a .env file in the project root containing the following env varia
55
58
PATTERN_SERVICE_MODE=development
56
59
```
57
60
61
+
### Configure postgres and run the dispatcher service
62
+
63
+
Several endpoints in the pattern service rely on asynchronous tasks that are handled by a separate running service, the dispatcher service. This uses [PostgreSQL's](https://www.postgresql.org/)`pg_notify` ability to send asyncronous tasks from the django application to the dispatcher service. For more details, see the [dispatcherd documentation](https://github.com/ansible/dispatcherd/blob/main/README.md).
64
+
65
+
To make use of the dispatcher, you will need to ensure that both postgres and the dispatcher service are running. _The easiest way to do this is via [docker-compose](./tools/container/README.md)_, however it is also possible to do this manually as follows:
66
+
67
+
- Install postgres locally and create a database for the service.
68
+
- Update your local .env file to reference your postgres server and database details (these can also be exported to your shell env):
69
+
70
+
```bash
71
+
PATTERN_SERVICE_DB_NAME=<your database name>
72
+
PATTERN_SERVICE_DB_USER=<your database user>
73
+
PATTERN_SERVICE_DB_PASSWORD=<your database user password>
74
+
PATTERN_SERVICE_DB_HOST=localhost
75
+
PATTERN_SERVICE_DB_PORT="5432 (or your postgres port)"
76
+
```
77
+
78
+
- Run the dispatcherd service from the root pattern service directory with `python manage.py worker`
The application can be reached in your browser at `https://localhost:8000/`. The Django admin UI is accessible at `https://localhost:8000/admin` and the available API endpoints will be listed in the 404 information at `http://localhost:8000/api/pattern-service/v1/`.
@@ -67,13 +91,22 @@ Project dependencies for all environments are specified in the [pyproject.toml f
67
91
68
92
To add a new dependency:
69
93
70
-
1. Add the package to the appropriate project or optional dependencies section of the pyproject.toml file, using dependency specifiers to constrain versions.
71
-
2. Update the requirements files with the command `make requirements`. This should update the relevant requirements.txt files in the project's requirements directory.
94
+
1. Ensure you have `pip-tools` installed by running either `pipx install pip-tools` or `pip install -u pip-tools`.
95
+
2. Add the package to the appropriate project or optional dependencies section of the pyproject.toml file, using dependency specifiers to constrain versions.
96
+
3. Update the requirements files with the command `make requirements`. This should update the relevant requirements.txt files in the project's requirements directory.
97
+
98
+
## Running linters and code checks
99
+
100
+
Linters, type checks, and other checks can all be run via `tox`. To see the available `tox` commands for this project, run `tox list`.
72
101
73
-
## Running tests, linters, and code checks
102
+
To run an individual tox command use the `-e` flag to specify the environment, for example: `tox -e lint` to run the linters.
74
103
75
-
Unit tests, linters, type checks, and other checks can all be run via `tox`. To see the available `tox` commands for this project, run `tox list`.
104
+
To run all checks, simply run `tox` with no options.
76
105
77
-
To run an individual tox command use the `-e` flag to specify the environment, for example: `tox -e test` to run tests with all supported python versions.
78
-
s
79
-
To run all tests and checks, simply run `tox` with no options.
106
+
## Running tests
107
+
108
+
Running the tests requires a postgres connection. The easiest way to do this is with the [test compose file](./tools/podman/compose-test.yaml), and there is a `make` command to simplify starting the postgres container and running the tests:
0 commit comments