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

GitHub Actions for subgraph #871

Merged
merged 13 commits into from
May 21, 2024
77 changes: 77 additions & 0 deletions .github/workflows/ci.subgraph-basin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Subgraph Basin

on:
pull_request:
types: [opened, synchronize]
paths:
- "projects/subgraph-basin/**"

jobs:
compile:
runs-on: ubuntu-latest
name: Compile
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Cache Node Modules
id: node-modules-cache
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install The Graph CLI
run: npm install -g @graphprotocol/graph-cli
- name: Install Dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: projects/subgraph-basin

# Generate code and check for uncommitted changes
# https://github.com/marketplace/actions/check-uncommitted-changes
- name: Generate Subgraph Code
run: yarn codegen
working-directory: projects/subgraph-basin
- name: Check for uncommitted changes
id: check-changes
uses: mskri/[email protected]
- name: Evaluate if there are changes
if: steps.check-changes.outputs.outcome == failure()
run: echo "There are uncommitted changes - execute 'yarn codegen' locally and commit the generated files!"

- name: Build Subgraph
run: yarn build
working-directory: projects/subgraph-basin
test:
runs-on: ubuntu-latest
name: Test
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Cache Node Modules
id: node-modules-cache
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install The Graph CLI
run: npm install -g @graphprotocol/graph-cli
- name: Install Dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: projects/subgraph-basin

- name: Generate Subgraph Code
run: yarn codegen
working-directory: projects/subgraph-basin

- name: Run Tests
run: yarn test
working-directory: projects/subgraph-basin
37 changes: 32 additions & 5 deletions .github/workflows/ci.subgraph-bean.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
- name: Cache Node Modules
id: node-modules-cache
uses: actions/cache@v3
Expand All @@ -28,6 +28,7 @@ jobs:
- name: Install Dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: projects/subgraph-bean

# Generate code and check for uncommitted changes
# https://github.com/marketplace/actions/check-uncommitted-changes
Expand All @@ -44,7 +45,33 @@ jobs:
- name: Build Subgraph
run: yarn build
working-directory: projects/subgraph-bean
# TODO: add matchstick test suite
#- name: Run Tests
# run: yarn test
# working-directory: "${{ matrix.value }}"
test:
runs-on: ubuntu-latest
name: Test
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Cache Node Modules
id: node-modules-cache
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install The Graph CLI
run: npm install -g @graphprotocol/graph-cli
- name: Install Dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: projects/subgraph-bean

- name: Generate Subgraph Code
run: yarn codegen
working-directory: projects/subgraph-bean

- name: Run Tests
run: yarn test
working-directory: projects/subgraph-bean
77 changes: 77 additions & 0 deletions .github/workflows/ci.subgraph-beanft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Subgraph BeaNFT

on:
pull_request:
types: [opened, synchronize]
paths:
- "projects/subgraph-beanft/**"

jobs:
compile:
runs-on: ubuntu-latest
name: Compile
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Cache Node Modules
id: node-modules-cache
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install The Graph CLI
run: npm install -g @graphprotocol/graph-cli
- name: Install Dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: projects/subgraph-beanft

# Generate code and check for uncommitted changes
# https://github.com/marketplace/actions/check-uncommitted-changes
- name: Generate Subgraph Code
run: yarn codegen
working-directory: projects/subgraph-beanft
- name: Check for uncommitted changes
id: check-changes
uses: mskri/[email protected]
- name: Evaluate if there are changes
if: steps.check-changes.outputs.outcome == failure()
run: echo "There are uncommitted changes - execute 'yarn codegen' locally and commit the generated files!"

- name: Build Subgraph
run: yarn build
working-directory: projects/subgraph-beanft
test:
runs-on: ubuntu-latest
name: Test
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Cache Node Modules
id: node-modules-cache
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install The Graph CLI
run: npm install -g @graphprotocol/graph-cli
- name: Install Dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: projects/subgraph-beanft

- name: Generate Subgraph Code
run: yarn codegen
working-directory: projects/subgraph-beanft

- name: Run Tests
run: yarn test
working-directory: projects/subgraph-beanft
37 changes: 32 additions & 5 deletions .github/workflows/ci.subgraph-beanstalk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
- name: Cache Node Modules
id: node-modules-cache
uses: actions/cache@v3
Expand All @@ -28,6 +28,7 @@ jobs:
- name: Install Dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: projects/subgraph-beanstalk

# Generate code and check for uncommitted changes
# https://github.com/marketplace/actions/check-uncommitted-changes
Expand All @@ -44,7 +45,33 @@ jobs:
- name: Build Subgraph
run: yarn build
working-directory: projects/subgraph-beanstalk
# TODO: add matchstick test suite
#- name: Run Tests
# run: yarn test
# working-directory: "${{ matrix.value }}"
test:
runs-on: ubuntu-latest
name: Test
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Cache Node Modules
id: node-modules-cache
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install The Graph CLI
run: npm install -g @graphprotocol/graph-cli
- name: Install Dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: projects/subgraph-beanstalk

- name: Generate Subgraph Code
run: yarn codegen
working-directory: projects/subgraph-beanstalk

- name: Run Tests
run: yarn test
working-directory: projects/subgraph-beanstalk
43 changes: 43 additions & 0 deletions .github/workflows/deploy.subgraph.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Deploy Subgraph

on:
workflow_dispatch:
inputs:
environment:
description: "Deployment environment (prod/dev/testing)"
required: true
subgraph:
description: "Subgraph name (beanstalk/bean/basin/beanft)"
required: true
branch:
description: "Branch name"
required: true

jobs:
validation:
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.check_env.outputs.environment }}
steps:
- name: Validate environment input
id: check_env
run: |
# Check if the environment is either 'prod' or 'dev' or 'testing'
if [[ "${{ github.event.inputs.environment }}" != "prod" && "${{ github.event.inputs.environment }}" != "dev" && "${{ github.event.inputs.environment }}" != "testing" ]]; then
echo "Error: Environment must be one of 'prod', 'dev', 'testing'."
exit 1
fi

deploy:
needs: validation
runs-on: ubuntu-latest
steps:
- name: Install SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.GRAPH_SERVER_SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H ${{ secrets.GRAPH_SERVER_HOST }} >> ~/.ssh/known_hosts

- name: Execute Remote Deployment Script
run: ssh -i ~/.ssh/id_ed25519 github@${{ secrets.GRAPH_SERVER_HOST }} "bash /home/github/deploy.sh ${{ github.event.inputs.branch }} ${{ github.event.inputs.subgraph }} ${{ github.event.inputs.environment }}"
21 changes: 7 additions & 14 deletions projects/subgraph-basin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,16 @@
"test": "graph test",
"testd": "docker run -it --rm --mount type=bind,source=\"$(pwd)\"/matchstick.yaml.docker,target=/matchstick/matchstick.yaml --mount type=bind,source=\"$(pwd)\"/../../,target=/matchstick/repo-mounted/ matchstick",
"testd-named": "../subgraph-core/tests/scripts/docker-run-named.sh",
"deploy": "yarn codegen && graph deploy --node https://api.studio.thegraph.com/deploy/ basin",
"create-local": "graph create --node http://127.0.0.1:8020/ basin",
"deploy-local": "yarn codegen && graph deploy --node http://127.0.0.1:8020/ --ipfs http://127.0.0.1:5001 basin",
"create-hosted": "graph create --node http://graph.node.bean.money:8020/ basin",
"remove-hosted": "graph remove --node http://graph.node.bean.money:8020/ basin",
"deploy-hosted": "yarn codegen && graph deploy --node http://graph.node.bean.money:8020/ --ipfs http://graph.node.bean.money:5001 basin",
"create-hosted-staging": "graph create --node http://graph.node.bean.money:8020/ basin-staging",
"remove-hosted-staging": "graph remove --node http://graph.node.bean.money:8020/ basin-staging",
"deploy-hosted-staging": "yarn codegen && graph deploy --node http://graph.node.bean.money:8020/ --ipfs http://graph.node.bean.money:5001 basin-staging",
"create-hosted-dev": "graph create --node http://graph.node.bean.money:8020/ basin-dev",
"remove-hosted-dev": "graph remove --node http://graph.node.bean.money:8020/ basin-dev",
"deploy-hosted-dev": "yarn codegen && graph deploy --node http://graph.node.bean.money:8020/ --ipfs http://graph.node.bean.money:5001 basin-dev"
"remove-local": "graph remove --node http://127.0.0.1:8020/ basin",
"deploy-local": "yarn codegen && graph deploy --node http://127.0.0.1:8020/ --ipfs http://127.0.0.1:5001 basin"
},
"dependencies": {
"@graphprotocol/graph-cli": "0.56.0",
"@graphprotocol/graph-ts": "0.31.0",
"matchstick-as": "^0.5.0"
"@graphprotocol/graph-cli": "0.69.0",
"@graphprotocol/graph-ts": "0.34.0"
},
"devDependencies": {
"matchstick-as": "^0.6.0"
},
"private": true
}
4 changes: 2 additions & 2 deletions projects/subgraph-basin/tests/helpers/Functions.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts";
import { createMockedFunction } from "matchstick-as";
import { BEAN_3CRV, BEAN_ERC20, BEAN_WETH_CP2_WELL, CRV3_POOL_V1, WETH } from "../../../subgraph-core/utils/Constants";
import { BEAN_3CRV, BEAN_ERC20, BEAN_WETH_CP2_WELL, CRV3_TOKEN, WETH } from "../../../subgraph-core/utils/Constants";
import { BEAN_USD_PRICE, WELL } from "./Constants";
import { setMockCurvePrice, setMockWellPrice } from "../../../subgraph-core/tests/event-mocking/Price";

export function createContractCallMocks(): void {
setMockCurvePrice({
contract: BEAN_3CRV,
tokens: [BEAN_ERC20, CRV3_POOL_V1],
tokens: [BEAN_ERC20, CRV3_TOKEN],
balances: [BigInt.fromString("14306013160240"), BigInt.fromString("12306817594155799426763734")],
price: BEAN_USD_PRICE,
liquidity: BigInt.fromString("26025239751318"),
Expand Down
20 changes: 6 additions & 14 deletions projects/subgraph-bean/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,16 @@
"test": "graph test",
"testd": "docker run -it --rm --mount type=bind,source=\"$(pwd)\"/matchstick-docker.yaml,target=/matchstick/matchstick.yaml --mount type=bind,source=\"$(pwd)\"/../../,target=/matchstick/repo-mounted/ matchstick",
"testd-named": "../subgraph-core/tests/scripts/docker-run-named.sh",
"deploy": "graph deploy --node https://api.studio.thegraph.com/deploy/ bean",
"create-local": "graph create --node http://127.0.0.1:8020/ bean",
"remove-local": "graph remove --node http://127.0.0.1:8020/ bean",
"deploy-local": "graph deploy --node http://127.0.0.1:8020/ --ipfs http://127.0.0.1:5001 bean",
"create-hosted": "graph create --node http://graph.node.bean.money:8020/ bean",
"remove-hosted": "graph remove --node http://graph.node.bean.money:8020/ bean",
"deploy-hosted": "graph deploy --node http://graph.node.bean.money:8020/ --ipfs http://graph.node.bean.money:5001 bean",
"create-hosted-dev": "graph create --node http://graph.node.bean.money:8020/ bean-dev",
"remove-hosted-dev": "graph remove --node http://graph.node.bean.money:8020/ bean-dev",
"deploy-hosted-dev": "graph deploy --node http://graph.node.bean.money:8020/ --ipfs http://graph.node.bean.money:5001 bean-dev",
"create-hosted-test": "graph create --node http://graph.node.bean.money:8020/ bean-testing",
"remove-hosted-test": "graph remove --node http://graph.node.bean.money:8020/ bean-testing",
"deploy-hosted-test": "graph deploy --node http://graph.node.bean.money:8020/ --ipfs http://graph.node.bean.money:5001 bean-testing"
"deploy-local": "graph deploy --node http://127.0.0.1:8020/ --ipfs http://127.0.0.1:5001 bean"
},
"dependencies": {
"@graphprotocol/graph-cli": "0.56.0",
"@graphprotocol/graph-ts": "0.31.0",
"matchstick-as": "^0.5.0"
"@graphprotocol/graph-cli": "0.69.0",
"@graphprotocol/graph-ts": "0.34.0"
},
"devDependencies": {
"matchstick-as": "^0.6.0"
},
"private": true
}
Loading
Loading