2018-06-28 09:05:34 +03:00
# Contributing
2018-06-28 08:40:18 +03:00
2018-10-11 10:19:10 +03:00
Thanks for your interest in Hasura GraphQL Engine CLI.
2018-07-11 07:57:03 +03:00
2019-01-22 09:40:59 +03:00
The CLI is written in [Go ](https://golang.org/ ) using the popular
package [`spf13/cobra` ](https://github.com/spf13/cobra ).
All CLI related issues are labelled as [`c/cli` ](https://github.com/hasura/graphql-engine/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3Ac%2Fcli+ ) which stands for
component/cli. If you're new to the CLI codebase, you can checkout the
[`good-first-issue` ](https://github.com/hasura/graphql-engine/issues?q=is%3Aissue+is%3Aopen+label%3Ac%2Fcli+label%3A%22good+first+issue%22 ) label for issues that
are fairly easy to implement.
2018-07-11 07:57:03 +03:00
2021-03-17 18:09:03 +03:00
If you are a first-time contributor, feel free to post your doubts/questions in `#contrib` channel on [hasura discord server ](https://discord.com/invite/hasura ).
2019-01-22 09:40:59 +03:00
## Pre-requisites
2018-07-11 07:57:03 +03:00
2021-03-17 18:09:03 +03:00
- [Go >= 1.16 ](https://golang.org/doc/install )
- [Node.js >= 10.19.0 and npm >= 6.14.4 ](https://nodejs.org/en/download/ )
2019-01-22 09:40:59 +03:00
- [GNU Make ](https://www.gnu.org/software/make/ ) (optional)
2018-07-11 07:57:03 +03:00
2018-06-28 08:40:18 +03:00
You can follow your existing Golang workflow to fork, work on a branch and
submit PR. If you're new to forking and working on Golang repositories, please
2018-07-11 07:57:03 +03:00
follow the instructions below to make sure the import paths are correct:
2018-06-28 08:40:18 +03:00
2018-07-11 07:57:03 +03:00
- Fork the repo on GitHub
2018-06-28 08:40:18 +03:00
- `git clone https://github.com/<your-username>/graphql-engine`
2019-04-11 06:45:18 +03:00
- `cd graphql-engine/cli`
2018-06-28 09:05:34 +03:00
- `git remote add upstream https://github.com/hasura/graphql-engine`
2018-06-28 08:40:18 +03:00
- `git checkout -b <branch-name>`
2018-07-11 07:57:03 +03:00
- `make deps`
2021-03-17 18:09:03 +03:00
- `make build-cli-ext`
2018-06-28 08:40:18 +03:00
- Work on the feature/fix
2018-07-11 07:57:03 +03:00
- If you modify files in `assets/` , run `make assets`
2018-07-17 16:02:33 +03:00
- Add tests and ensure all tests are passing (check [Tests ](#tests ) section below)
2018-06-28 08:40:18 +03:00
- Commit, push and submit PR
2018-06-28 09:05:34 +03:00
## Development workflow
2020-04-14 06:12:53 +03:00
For faster development workflow, you may use tools that watch the directory for changes and rebuilds the cli whenever a new change happens. [realize ](https://github.com/oxequa/realize ) and [watchrun ](https://github.com/loov/watchrun ) are two such examples. The configuration file for `realize` is already included in the repo at `.realize/realize.yaml` .
2018-07-11 07:57:03 +03:00
## Tests
2018-09-13 12:33:13 +03:00
When you're adding a new feature, it is encouraged to add integration tests
2018-11-08 09:32:57 +03:00
(unit tests also if possible) for the functions/api. You should run all the tests
2018-09-13 12:33:13 +03:00
and make sure everything passes before submitting the PR.
The tests expect a GraphQL Engine server instance to be running. You can point
the tests to any GraphQL Engine server but please note that **the database
2018-10-11 10:19:10 +03:00
should be empty**. The easiest way to do this is to run Postgres and GraphQL
2018-09-13 12:33:13 +03:00
Engine using [Docker
2020-02-19 14:43:08 +03:00
Compose](https://github.com/hasura/graphql-engine/tree/stable/install-manifests).
2018-09-13 12:33:13 +03:00
Once the server is running, you can run the tests by executing the make command:
2018-07-11 07:57:03 +03:00
```bash
2021-07-16 08:26:00 +03:00
HASURA_TEST_CLI_HGE_DOCKER_IMAGE="hasura/graphql-engine:v2.0.1" HASURA_GRAPHQL_TEST_ENDPOINT=http://localhost:8080 VERSION=dev make test
2018-07-11 07:57:03 +03:00
```
## Builds
To build a binary, execute the following command:
```bash
# make deps to install all go packages
make build
```
2018-07-17 16:02:33 +03:00
This will output cross-platform binaries to `_output` directory.