Skip to content

Akablockchain2/qf ge ci #1

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

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Build Hasura Binary

on:
push:
tags:
- "*"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0

- name: Extract Tag Version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Set CURRENT_VERSION
run: echo "$VERSION" > server/CURRENT_VERSION

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21'

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install System Dependencies
run: |
sudo apt update
sudo apt install -y gcc make musl-dev curl unixodbc-dev

- name: Setup Haskell (GHC & Cabal)
uses: haskell/actions/setup@v2
with:
ghc-version: '9.2'
cabal-version: '3.12'

- name: Cache Cabal Dependencies
uses: actions/cache@v3
with:
path: |
~/.cabal/store
dist-newstyle
server/dist-newstyle
key: ${{ runner.os }}-cabal-${{ hashFiles('cabal.project.freeze') }}
restore-keys: |
${{ runner.os }}-cabal-

- name: Install Haskell Dependencies
run: |
cabal update
cabal build all --only-dependencies

- name: Build GraphQL Engine
run: cabal build exe:graphql-engine

- name: Copy README.md to server/
run: cp README.md server/

- name: Build Executable Binary
run: |
mkdir -p artifacts
cabal install exe:graphql-engine --installdir=artifacts
mv artifacts/graphql-engine artifacts/graphql-engine-$VERSION

- name: Upload Binary Artifact
uses: actions/upload-artifact@v4
with:
name: graphql-engine
path: artifacts/graphql-engine-*

build_docker:
name: Build and Publish Docker Image
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PAT }}

- name: Download Built Binary
uses: actions/download-artifact@v4
with:
name: graphql-engine
path: artifacts/

- name: Rename and Make Binary Executable
run: |
mv artifacts/graphql-engine-* artifacts/graphql-engine
chmod +x artifacts/graphql-engine

- name: List Downloaded Artifacts
run: ls -l artifacts/

- name: Check server/Dockerfile
run: ls -l server/

- name: Build and Tag Docker Image
run: |
ls -l
pwd
docker build -t graphql-engine:${{ github.ref_name }} -f server/Dockerfile .
docker tag graphql-engine:${{ github.ref_name }} qfnetwork/graphql-engine:${{ github.ref_name }}
docker tag graphql-engine:${{ github.ref_name }} qfnetwork/graphql-engine:latest

- name: Push Docker Image to Docker Hub
run: |
docker push qfnetwork/graphql-engine:${{ github.ref_name }}
docker push qfnetwork/graphql-engine:latest
50 changes: 50 additions & 0 deletions easy-run/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Create new table
curl -X POST http://localhost:8080/v1/query \
-H "Content-Type: application/json" \
-H "x-hasura-admin-secret: mysecretkey" \
--data '{
"type": "run_sql",
"args": {
"source": "default",
"sql": "CREATE TABLE public.hello_world (id SERIAL PRIMARY KEY, name TEXT);"
}
}'

# Add table to hasura
curl -X POST http://localhost:8080/v1/metadata \
-H "Content-Type: application/json" \
-H "x-hasura-admin-secret: mysecretkey" \
--data '{
"type": "pg_track_table",
"args": {
"source": "default",
"table": {
"schema": "public",
"name": "hello_world"
}
}
}'

# Check tracked tables
curl -X POST http://localhost:8080/v1/graphql \
-H "Content-Type: application/json" \
-H "x-hasura-admin-secret: mysecretkey" \
--data '{"query":"{ __type(name: \"query_root\") { fields { name } } }"}'

# Add new record
curl -X POST http://localhost:8080/v1/query \
-H "Content-Type: application/json" \
-H "x-hasura-admin-secret: mysecretkey" \
--data '{
"type": "run_sql",
"args": {
"source": "default",
"sql": "INSERT INTO public.hello_world (name) VALUES (E'\''test'\'');"
}
}'

# Return all records
curl -X POST http://localhost:8080/v1/graphql \
-H "Content-Type: application/json" \
-H "x-hasura-admin-secret: mysecretkey" \
--data '{"query":"{ hello_world { id, name } }"}'
68 changes: 68 additions & 0 deletions easy-run/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
services:
postgres:
extends:
file: docker-compose/databases.yaml
service: postgres
ports:
- "65002:5432"
environment:
POSTGRES_USER: "hasura"
POSTGRES_PASSWORD: "hasura"
POSTGRES_DB: "hasura"
volumes:
- postgres-data:/var/lib/postgresql/data
- ./docker-compose/postgres/init.sh:/docker-entrypoint-initdb.d/init-hasura.sh:ro

graphql-engine:
image: "${DOCKER_HUB_USERNAME}/qf-node:latest"
depends_on:
- postgres
ports:
- "8080:8080"
restart: always
environment:
HASURA_GRAPHQL_DATABASE_URL: "postgres://hasura:hasura@postgres:5432/hasura"
HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ADMIN_SECRET: "mysecretkey"

citus:
extends:
file: docker-compose/databases.yaml
service: citus
ports:
- "65004:5432"
environment:
POSTGRES_USER: "hasura"
POSTGRES_PASSWORD: "hasura"
POSTGRES_DB: "hasura"
volumes:
- citus-data:/var/lib/postgresql/data
- ./docker-compose/postgres/init.sh:/docker-entrypoint-initdb.d/init-hasura.sh:ro

cockroach:
extends:
file: docker-compose/databases.yaml
service: cockroach
ports:
- "65008:26257"
environment:
COCKROACH_USER: "root"
COCKROACH_DATABASE: "hasura"
volumes:
- cockroach-data:/cockroach/cockroach-data

sqlserver:
extends:
file: docker-compose/databases.yaml
service: sqlserver
ports:
- "65003:1433"
volumes:
- mssql-data:/var/opt/mssql

volumes:
citus-data:
cockroach-data:
mssql-data:
postgres-data:
Loading
Loading