Developing Hive locally requires you to have the following software installed locally:
- Node.js 21 (or
nvm
orfnm
) - pnpm v9
- Docker version 26.1.1 or later(previous versions will not work correctly on arm64)
- make sure these ports are free: 5432, 6379, 9000, 9001, 8123, 9092, 8081, 8082, 9644, 3567, 7043
- Clone the repository locally
- Make sure to install the recommended VSCode extensions (defined in
.vscode/extensions.json
) - In the root of the repo, run
nvm use
to use the same version of node as mentioned - Create
.env
file in the root, and use the following:
ENVIRONMENT=local
- Run
pnpm i
at the root to install all the dependencies and run the hooks - Run
pnpm local:setup
to run Docker compose dependencies, create databases and migrate database - Run
pnpm generate
to generate the typings from the graphql files (usepnpm graphql:generate
if you only need to run GraphQL Codegen) - Run
pnpm build
to build all services - Click on
Start Hive
in the bottom bar of VSCode - Open the UI (
http://localhost:3000
by default) and Sign in with any of the identity provider - Once this is done, you should be able to log in and use the project
- Once you generate the token against your organization/personal account in hive, the same can be
added locally to
hive.json
withinpackages/libraries/cli
which can be used to interact via the hive cli with the registry (Usehttp://localhost:3001/graphql
as theregistry.endpoint
value inhive.json
) - Now you can use Hive locally. All other steps in this document are optional and only necessary if you work on specific features.
We have a script to feed your local instance of Hive with initial seed data. This step is optional.
- Use
Start Hive
to run your local Hive instance - Make sure
usage
andusage-ingestor
are running as well (withpnpm dev
) - Open Hive app, create a project and a target, then create a token
- Run the seed script:
TOKEN="MY_TOKEN_HERE" pnpm seed
- This should report a dummy schema and some dummy usage data to your local instance of Hive, allowing you to test features e2e
Note: You can set
STAGING=1
in order to target staging env and seed a target there. Same for development env, you can useDEV=1
Note: You can set
FEDERATION=1
in order to publish multiple subgraphs.
To send more operations and test heavy load on Hive instance, you can also set
OPERATIONS
(amount of operations in each interval round, default is1
) andINTERVAL
(frequency of sending operations, default:1000
ms). For example, usingINTERVAL=1000 OPERATIONS=1000
will send 1000 requests per second.
We recommend the following flow if you are having issues with running Hive locally:
- Stop all Docker containers:
docker kill $(docker ps -q)
- Clear all local Docker environment:
docker system prune --all --force --volumes
- Delete all generated local
.env
files:find . -name '.env' | xargs rm
- Delete local
docker/.hive
anddocker/.hive-dev
dir used by Docker volumes. - Reinstall dependencies using
pnpm install
- Force-generate new
.env
files:pnpm env:sync --force
-
Start Hive locally
-
Create a project and a target
-
Create a token from that target
-
Go to
packages/libraries/cli
and runpnpm build
-
Inside
packages/libraries/cli
, run:pnpm start schema:publish --registry.accessToken "YOUR_TOKEN_HERE" --registry.endpoint "http://localhost:3001/graphql" examples/single.graphql
The registry endpoint is the GraphQL endpoint of your local
server
service. You can also edit thehive.json
file in thecli
package to avoid passing theaccessToken
andendpoint
every time.
- Download Loophole CLI (same as ngrok but supports non-random urls)
- Log in to Loophole
$ loophole account login
- Start the proxy by running
$ loophole http 3000 --hostname hive-<your-name>
(@kamilkisiela I usehive-kamil
). It createshttps://hive-<your-name>.loophole.site
endpoint. - Message @kamilkisiela and send him the url (He will update the list of accepted redirect urls in Slack App).
- Update
APP_BASE_URL
inpackages/web/app/.env
to the proxy URL (e.g.https://hive-<your-name>.loophole.site
) - Run
packages/web/app
and openhttps://hive-<your-name>.loophole.site
.
We have a special Slack channel called
#hive-tests
to not spam people :)
- Follow first two steps from
Setting up Slack App for developing
(download loophole and log in). - Start web app proxy:
$ loophole http 3000 --hostname hive-<your-name>
- Start server proxy:
$ loophole http 3001 --hostname hive-<your-name>
- Go to
Settings
->Developer settings
->GitHub Apps
, and click on theNew GitHub App
button. - Provide a name for your app, and set the
Homepage URL
tohttps://hive-<your-name>.loophole.site
. Then set the callback URL tohttps://hive-<your-name>.loophole.site/api/github/callback
, and post installation's callback URL tohttps://hive-<your-name>.loophole.site/api/github/setup-callback
. - Click on
Create GitHub App
.
-
Server: Set the following env variables in
packages/services/server/.env
:INTEGRATION_GITHUB=1 INTEGRATION_GITHUB_GITHUB_APP_ID=<your-github-app-id>
You'll find the GitHub App ID and private key in the
General
tab of your GitHub App.Store the Github private key next to the
.env
file with the namegithub-app.pem
(packages/services/server/github-app.pem
) -
Web App: Set the following in
packages/web/app/.env
:INTEGRATION_GITHUB_APP_NAME=<your-github-app-name>
Open Hive UI and go to your organization's settings page. Find Integrations
section and click on
Connect GitHub
. You should be redirected to GitHub where you can grant repository access. After
installing the app, you should be redirected back to Hive.
- Create a project and a target.
- Create a token from that target.
- Setup a GitHub repo with CI/CD actions like this one: https://github.com/n1ru4l/hive-federation-subgraph/.
- Add the token to the repo's secrets as
HIVE_TOKEN
. - Add Hive endpoint to the repo's secrets as
HIVE_ENDPOINT
(https://hive-<your-name>.loophole.site/graphql
). - Make sure your GitHub app is installed on that repo.
- Push a commit to the repo and check if the CI/CD action is triggered.
The docker-compose.dev.yml
files includes a mock OIDC server that can be used for testing the OIDC
login/logout flow locally. The server tuns on port 7043
.
Please make sure to set the AUTH_ORGANIZATION_OIDC
environment variables for the server
and
app
to "1"
.
You can use the following values for connecting an integration to an OIDC provider.
# Token Endpoint
http://localhost:7043/connect/token
# User Info Endpoint
http://localhost:7043/connect/userinfo
# Authorization Endpoint
http://localhost:7043/connect/authorize
# Client ID
implicit-mock-client
# Client Secret
client-credentials-mock-client-secret
For login use the following credentials.
# Username
test-user
# Password
password
- Click on Start Hive in the bottom bar of VSCode
- Open the UI (
http://localhost:3000
by default) and register any email and password - Sending e-mails is mocked out during local development, so in order to verify the account find
the verification link by visiting the email server's
/_history
endpoint -http://localhost:6260/_history
by default.- Searching for
token
should help you find the link.
- Searching for