2018-07-11 07:57:03 +03:00
|
|
|
# Contributing
|
|
|
|
|
2018-10-19 19:59:18 +03:00
|
|
|
This guide explains how to set up the graphql-engine server for development on your
|
|
|
|
own machine and how to contribute.
|
2018-07-11 13:34:29 +03:00
|
|
|
|
|
|
|
## Pre-requisites
|
|
|
|
|
|
|
|
- [stack](https://docs.haskellstack.org/en/stable/README/#how-to-install)
|
2018-10-04 17:25:46 +03:00
|
|
|
- A Postgres server (Recommended: Use docker to run a local postgres instance)
|
2018-07-11 13:34:29 +03:00
|
|
|
- GNU Make (optional)
|
2019-03-19 08:12:50 +03:00
|
|
|
- [Node.js](https://nodejs.org/en/) (v8.9+)
|
2019-02-14 08:16:14 +03:00
|
|
|
- libpq-dev
|
2019-03-19 08:12:50 +03:00
|
|
|
- psql
|
|
|
|
- python >= 3.7 with pip3
|
|
|
|
|
|
|
|
## Upgrading npm
|
|
|
|
|
|
|
|
If your npm is too old (< 5.7),
|
|
|
|
|
|
|
|
npm install -g npm@latest
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
sudo npm install -g npm@latest
|
|
|
|
|
|
|
|
or update your nodejs
|
|
|
|
|
|
|
|
## Getting pip3
|
|
|
|
|
|
|
|
sudo apt install python3-pip
|
2018-07-11 13:34:29 +03:00
|
|
|
|
|
|
|
## Development workflow
|
|
|
|
|
|
|
|
### Fork and clone
|
|
|
|
- Fork the repo on GitHub
|
|
|
|
- Clone your forked repo: `git clone https://github.com/<your-username>/graphql-engine`
|
2019-02-14 08:16:14 +03:00
|
|
|
- `cd graphql-engine`
|
2018-07-11 13:34:29 +03:00
|
|
|
|
|
|
|
### Compile
|
2019-02-14 08:16:14 +03:00
|
|
|
- compile console assets
|
|
|
|
```
|
|
|
|
cd console
|
|
|
|
npm ci
|
|
|
|
cd ..
|
|
|
|
```
|
|
|
|
- compile the server
|
|
|
|
```
|
|
|
|
cd server
|
|
|
|
stack build --fast --flag graphql-engine:local-console
|
|
|
|
```
|
2018-07-11 13:34:29 +03:00
|
|
|
|
|
|
|
### Run
|
2019-02-14 08:16:14 +03:00
|
|
|
- Make sure postgres is running (Postgres >= 9.5)
|
2018-07-11 13:34:29 +03:00
|
|
|
- Create a database on postgres
|
2018-11-04 05:41:06 +03:00
|
|
|
- Run the binary: `stack exec graphql-engine -- --database-url=<database-url> serve`
|
2018-07-11 13:34:29 +03:00
|
|
|
|
2019-03-19 08:12:50 +03:00
|
|
|
database url looks like: `postgres://<username>:<password>@<host>:<port>/<dbname>`
|
|
|
|
|
|
|
|
### Running Postgres
|
|
|
|
|
|
|
|
The easiest way is to run docker in a container
|
|
|
|
|
|
|
|
````
|
|
|
|
docker run -p 5432:5432 -d postgres:11.1
|
|
|
|
````
|
|
|
|
|
|
|
|
Test if it's running by
|
|
|
|
|
|
|
|
telnet localhost 5432
|
|
|
|
|
|
|
|
### psql
|
|
|
|
|
|
|
|
You will need psql or another client
|
|
|
|
|
|
|
|
````
|
|
|
|
sudo apt install postgresql-client
|
|
|
|
````
|
|
|
|
|
|
|
|
|
2018-07-11 13:34:29 +03:00
|
|
|
### Work
|
|
|
|
- Work on the feature/fix
|
2018-10-04 17:25:46 +03:00
|
|
|
- Add test cases if relevant
|
2018-07-11 13:34:29 +03:00
|
|
|
|
|
|
|
### Test
|
2019-01-20 12:49:56 +03:00
|
|
|
- Install the py-test dependencies:
|
|
|
|
|
|
|
|
```
|
|
|
|
pip3 install -r tests-py/requirements.txt
|
|
|
|
```
|
|
|
|
|
|
|
|
- Make sure postgres is running
|
|
|
|
- Run the graphql-engine:
|
|
|
|
|
|
|
|
```
|
2019-02-14 08:17:27 +03:00
|
|
|
stack exec graphql-engine -- --database-url=<database-url> serve --enable-console
|
2019-01-20 12:49:56 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
- Set the environmental variables for event-trigger tests
|
|
|
|
|
|
|
|
```
|
|
|
|
export EVENT_WEBHOOK_HEADER="MyEnvValue"
|
|
|
|
export WEBHOOK_FROM_ENV="http://127.0.0.1:5592"
|
|
|
|
```
|
|
|
|
|
|
|
|
- Run tests:
|
|
|
|
|
|
|
|
```
|
|
|
|
cd tests-py
|
2019-04-08 10:22:38 +03:00
|
|
|
pytest --hge-urls http://127.0.0.1:8080 --pg-urls <database_url> -vv
|
2019-01-20 12:49:56 +03:00
|
|
|
```
|
2018-07-11 13:34:29 +03:00
|
|
|
|
|
|
|
### Create Pull Request
|
|
|
|
- Make sure your commit messages meet the [guidelines](../CONTRIBUTING.md).
|
|
|
|
- Create a pull request from your forked repo to the main repo.
|
|
|
|
- Every pull request will automatically build and run the tests.
|
|
|
|
|
|
|
|
## Code conventions
|
|
|
|
|
|
|
|
This helps enforce a uniform style for all committers.
|
|
|
|
|
|
|
|
- Compiler warnings are turned on, make sure your code has no warnings.
|
|
|
|
- Use [hlint](https://github.com/ndmitchell/hlint) to make sure your code has no warnings.
|
|
|
|
- Use [stylish-haskell](https://github.com/jaspervdj/stylish-haskell) to format your code.
|