Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GO 63 Update Hasura Version #43

Merged
merged 10 commits into from
Apr 25, 2023
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@ lint:
golangci-lint run

test:
go test ./...
go test ./...

integration-test:
#docker volume prune -f
docker-compose -f docker-compose.test.yml up -d --build
sleep 42;
cd cmd/metadata && INTEGRATION=true HASURA_HOST=127.0.0.1 HASURA_PORT=8080 bash -c 'go1.19 test -v -timeout=15s -run TestIntegration_HasuraMetadata' || true
docker-compose -f docker-compose.test.yml down -v
32 changes: 32 additions & 0 deletions build/expected_metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
tables:
-
name: contract_metadata
columns:
- id
- created_at
- updated_at
- update_id
- network
- contract
- link
- status
- retry_count
- metadata
- error

-
name: token_metadata
columns:
- id
- created_at
- updated_at
- update_id
- token_id
- network
- contract
- link
- metadata
- retry_count
- status
- image_processed
- error
18 changes: 18 additions & 0 deletions cmd/metadata/hasura_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"github.com/dipdup-net/go-lib/hasura"
"os"
"testing"
)

func TestIntegration_HasuraMetadata(t *testing.T) {
if os.Getenv("INTEGRATION") == "" {
t.Skip("Skipping testing in CI environment")
}

configPath := "../../build/dipdup.yml" // todo: Fix paths
expectedMetadataPath := "../../build/expected_metadata.yml" // todo: Fix paths

hasura.TestExpectedMetadataWithActual(t, configPath, expectedMetadataPath)
}
56 changes: 56 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: "3.6"

services:
indexer:
image: dipdup/metadata:latest
command: "-c dipdup.yml"
build:
dockerfile: build/metadata/Dockerfile
context: .
depends_on:
- db
env_file:
- .env
restart: always
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-changeme}
- ADMIN_SECRET=${ADMIN_SECRET:-changeme}
- IPFS_NODE_URI=${IPFS_NODE_URI:-https://ipfs.io}
volumes:
- ipfs:/etc/metadata/ipfs

db:
image: postgres:13
restart: always
volumes:
- db:/var/lib/postgres/data
ports:
- "127.0.0.1:5432:5432"
environment:
- POSTGRES_USER=dipdup
- POSTGRES_DB=dipdup
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-changeme}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U dipdup"]
interval: 10s
timeout: 5s
retries: 5

hasura:
image: hasura/graphql-engine:v2.23.0
ports:
- "127.0.0.1:8080:8080"
depends_on:
- db
restart: always
environment:
- HASURA_GRAPHQL_DATABASE_URL=postgres://dipdup:${POSTGRES_PASSWORD:-changeme}@db:5432/dipdup
- HASURA_GRAPHQL_ENABLE_CONSOLE=true
- HASURA_GRAPHQL_DEV_MODE=true
- HASURA_GRAPHQL_ENABLED_LOG_TYPES=startup, http-log, webhook-log, websocket-log, query-log
- HASURA_GRAPHQL_ADMIN_SECRET=${ADMIN_SECRET:-changeme}
- HASURA_GRAPHQL_UNAUTHORIZED_ROLE=user

volumes:
db:
ipfs:
16 changes: 10 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ services:
indexer:
image: dipdup/metadata:latest
build:
dockerfile: build/metadata/Dockerfile
context: .
dockerfile: build/metadata/Dockerfile
context: .
depends_on:
- db
env_file:
- .env
restart: always
Expand All @@ -22,8 +24,8 @@ services:
volumes:
- db:/var/lib/postgres/data
ports:
- 127.0.0.1:5432:5432
environment:
- "127.0.0.1:5432:5432"
environment:
- POSTGRES_USER=dipdup
- POSTGRES_DB=dipdup
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-changeme}
Expand All @@ -34,9 +36,11 @@ services:
retries: 5

hasura:
image: hasura/graphql-engine:v2.0.8
image: hasura/graphql-engine:v2.23.0
ports:
- 127.0.0.1:8080:8080
- "127.0.0.1:8080:8080"
depends_on:
- db
restart: always
environment:
- HASURA_GRAPHQL_DATABASE_URL=postgres://dipdup:${POSTGRES_PASSWORD:-changeme}@db:5432/dipdup
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/aws/aws-sdk-go v1.43.31
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/dipdup-net/go-lib v0.2.30
github.com/dipdup-net/go-lib v0.2.32
github.com/disintegration/imaging v1.6.2
github.com/elastic/go-elasticsearch/v8 v8.1.0
github.com/go-pg/pg/v10 v10.10.6
Expand Down Expand Up @@ -80,7 +80,6 @@ require (
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/huin/goupnp v1.0.3 // indirect
github.com/iancoleman/strcase v0.2.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/ipfs/bbloom v0.0.4 // indirect
github.com/ipfs/go-bitfield v1.1.0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dipdup-net/go-lib v0.2.30 h1:pFGXdGOCvO375uPFU8a+hO4KztyjAszCje3j7vrU0Ec=
github.com/dipdup-net/go-lib v0.2.30/go.mod h1:oXILRskGR7bXvuFyc6B8prCKOjGJdDc76kMcf65EvcE=
github.com/dipdup-net/go-lib v0.2.32 h1:gG86VgAig11z8e2fi7ErgA+R/NuqriRUEXp3fI02ZdE=
github.com/dipdup-net/go-lib v0.2.32/go.mod h1:oXILRskGR7bXvuFyc6B8prCKOjGJdDc76kMcf65EvcE=
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
Expand Down Expand Up @@ -457,8 +457,6 @@ github.com/huin/goupnp v1.0.2/go.mod h1:0dxJBVBHqTMjIUMkESDTNgOOx/Mw5wYIfyFmdzSa
github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ=
github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y=
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
Expand Down