The Complaint Manager is an open source tool meant to aid civilian police oversight agencies in generating complaint data. PDM is designed to be fully integrated into the workflows of these oversight agencies, enabling cities to enhance the capacity of citizens to hold public institutions accountable. Read more here.
This README is aimed at getting new users set up to run Complaint Manager on their local machines. You will need the appropriate permissions for the app and its tests to run successfully.
If you are a city looking to adopt Complaint Manager as a tool for Complaint Intake, you can check out the guide to set up a new city instance.
If you are looking to contribute to this repo, take a look at our contributor guidelines.
[!CAUTION] This is a public repository, so please do not include PII (personally identifiable information) for real people in commits to the repository.
Go to top • Tasks • Testing • Troubleshooting
[!NOTE] The default developer platform for our team is MacOS. On other platforms (Linux, Windows) the code should compile and run, but this isn't something that's been tested.
If you plan to perform administrative tasks on Heroku deployments, manually or by local script, you will need to install the Heroku CLI.
For Mac, you can download Docker here.
[!NOTE] This is only required if you are running tests outside of the containers OR if you want to run database migrations.
server
tests in our IDE and also for running up/down migrations locallyworker
testsUsing your text editor of choice, edit /etc/hosts
file to add the following lines after the first localhost
:
127.0.0.1 db
127.0.0.1 redis
We use a tool called mkcert
to manage self-signed certificates for the local environment.
Run these commands to install a signing certificate authority and certificates on your local machine:
brew install mkcert
# installs the local CA
mkcert -install
# makes directories to store certs
cd <root of project>
mkdir .cert/
mkdir data/
# generates the local certificates signed by local CA
mkcert -cert-file .cert/client.crt -key-file .cert/client.key localhost
# local certificiates for exporting audits
mkcert -cert-file data/server.test.pem.crt -key-file data/server.test.pem.key host.docker.internal
Navigate into the data folder and create a file named server.test.pem
Add (or replace if it already exists) the contents in the server.test.pem
file with the contents of the newly generated .key
and .crt
files.
[!IMPORTANT] The
.key
should be at the top and the.crt
on the bottom.
If Docker is already set up, run docker compose down
then docker compose up app
for changes to take effect.
docker compose up
yet.In .zshrc
set the CERT_DIR
environment variable to the directory in which the root cert lives. You can find this directory by running mkcert -CAROOT
.
[!TIP] The directory path will look something like
/Users/<username>/Library/Application\ Support/mkcert
brew install nss
.[!TIP] Make sure you have the export keyword in front of CERT_DIR and REACT_APP_INSTANCE_FILES_DIR in your zshrc.
If you run into issues like
ERROR: failed to read the CA key: open /Users/<username>/Library/Application Support/mkcert/rootCA-key.pem: permission denied
You can solve this using:
sudo chown <username> /Users/<username>/Library/Application\ Support/mkcert/rootCA-key.pem
You only need this if you want to bypass LocalStack and test things using real AWS services like S3 and SecretsManager.
USE_CLOUD_SERVICES
and REACT_APP_USE_CLOUD_SERVICES
from false
to true
in docker-compose.yml
.AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
in your environment variables so PDM can connect to AWS.To install dependencies on your machine (as opposed to in the Docker container), run:
yarn install
Go to top • Setup • Testing • Troubleshooting
Log in to Docker using credentials provided by the Core Team with the following command: test
docker login
Run the following command:
./scripts/docker-compose-build.sh
Run the following command:
docker compose up app
Wait for both the back and front end to initialize.
Application is listening on port 1234
Please visit http://localhost:1234
Compiled with warnings.
Navigate to https://localhost
to view the app.
Run the following command:
docker compose down
It's all well and good to run these commands and watch Docker spin up with a lot of command line outputs, but what's actually happening?
docker-compose-build.sh
builds the Docker containers worker
, app-e2e
, and app
so that they can then be spun up to run locally. The diagram below shows the steps and indicates where those steps are configured:
docker-compose up app
runs the app container (which includes the client and server and pulls in the database, worker, and elasticsearch) so that you can use it locally. The diagram below shows the steps it takes and indicates where those steps are configured:
By default, local builds will pull publicdataworks/instance-files-noipm:latest
.
To create a new versioned instance-files-noipm
image (e.g. publicdataworks/instance-files-noipm:1.0.0
), execute the following commands from your private instance files repository (instance_files_noipm
):
docker login $DOCKER_USERNAME $DOCKER_PASSWORD
docker build -t publicdataworks/instance-files-noipm:your-tag .
docker push publicdataworks/instance-files-noipm:your-tag
In ~/.zshrc
:
Change the line beginning with export REACT_APP_INSTANCE_FILES_DIR=
to point to the instance files directory of the organization you want to point to.
In docker-compose.yml
:
Change the line beginning with ORG=
to the organization you want to point to (e.g. HAWAII
or NOIPM
).
Go to top • Setup • Tasks • Troubleshooting
[!IMPORTANT] The following must be performed before pushing any code.
Run the following command:
docker compose run --rm security-checks
To run all tests in src/client
in parallel, run the following command:
yarn test:client
[!NOTE] Like other tests, client tests can be run in Docker. However, since they don't require the test database, they can be run outside of Docker, which is faster.
Set up a test database and run all tests in src/server
sequentially with the following command:
docker-compose run --rm app yarn test:server
Set up a test DB and run all tests in src/worker
sequentially with the following command:
docker-compose run --rm app yarn test:worker
Tips for when you want to run a specific test suite in the terminal for either client, server, or worker tests:
Enter
key and then the P
keyEnter
[!IMPORTANT] Client Pact tests must come before server Pact tests.
Run client Pact tests with the following command:
yarn test:pact:client
Run server Pact tests with the following command:
docker compose run --rm app yarn test:pact:server
[!TIP] See more information on Pact here.
Go to top • Setup • Tasks • Testing
We currently see the following warnings from pdfjs
. This is a known issue where pdfjs
is not compatible with webpack 4.2.
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
pdf.worker.js
file to our build directory in a postbuild script.pdfjs
.There is a warning about duplicate props on the PhoneNumberField
. These are actually two different props that have the same name, but different capitalization: inputProps
and InputProps
. They are needed.
You may see the following warning when running tests:
Cannot find module 'pg-native' from 'client.js'
However, Jest was able to find:
'./client.js'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'].
See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string
You can safely ignore this warning. The tests will still pass.
This project has a prettierrc.js
file that dictates formatting. To set this up to work automatically in VSCode first add the prettier extension, then go to Code > Preferences > Settings and turn on the setting "Format on Save" (you can do Format on Paste too if you want) and set the "Default Formatter" to prettier.