Skip to content

Commit

Permalink
Merge branch 'dev' into gda-perm
Browse files Browse the repository at this point in the history
  • Loading branch information
hellwolf committed Aug 30, 2024
2 parents 1aac2f2 + 9a4abaf commit 6b5bf76
Show file tree
Hide file tree
Showing 44 changed files with 4,243 additions and 3,341 deletions.
89 changes: 40 additions & 49 deletions .github/workflows/call.deploy-subgraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
inputs:
vendor:
required: true
description: "Where to deploy subgraph to; superfluid, goldsky, graph or airstack"
description: "Where to deploy subgraph to; superfluid, goldsky, or graph"
type: string
deployment_env:
required: true
Expand All @@ -24,7 +24,7 @@ on:
description: "Satsuma deploy key"
required: false
THE_GRAPH_ACCESS_TOKEN:
description: "The Graph (hosted service) access token for deploying subgraphs"
description: "The Graph access token for deploying subgraphs"
required: false
GOLDSKY_API_KEY:
description: "Goldsky API key for deploying subgraphs"
Expand Down Expand Up @@ -55,12 +55,38 @@ jobs:
echo github.head_ref: "$HEAD_REF"
echo github.base_ref: ${{ github.base_ref }}
determine-networks:
name: Determine Networks
runs-on: ubuntu-latest
outputs:
networks: ${{ steps.determine.outputs.networks }}
steps:
- uses: actions/checkout@v4

- name: "Determine vendors for the network"
id: determine
run: |
networks=$(jq -r --arg vendor "${{ inputs.vendor }}" --arg network "${{ inputs.network }}" '
if $network == "all" then
.[$vendor] | @json
else
[$network] | @json
end' packages/subgraph/tasks/vendorNetworkMap.json)
if [ -z "$networks" ] || [ "$networks" == "null" ]; then
echo "Unsupported vendor or network: ${{ inputs.vendor }} / ${{ inputs.network }}"
exit 1
fi
echo "networks=$networks" >> "$GITHUB_OUTPUT"
deploy-subgraph:
name: Build and Deploy Subgraph

runs-on: ubuntu-latest
env:
subgraph-working-directory: ./packages/subgraph
needs: determine-networks
strategy:
matrix:
network: ${{ fromJson(needs.determine-networks.outputs.networks) }}
fail-fast: false

defaults:
run:
Expand All @@ -69,7 +95,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: DeterminateSystems/nix-installer-action@v13
- uses: cachix/install-nix-action@v19
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: "Install dependencies"
run: yarn install --frozen-lockfile
Expand All @@ -78,57 +106,20 @@ jobs:
run: yarn build
working-directory: ./packages/ethereum-contracts

- name: "Get ABI"
run: node scripts/getAbi.js
working-directory: ${{ env.subgraph-working-directory }}

- name: "Prepare subgraph manifest"
# This step is required for generating a preliminary subgraph.yaml
# and addresses.ts file for the yarn codegen step below
# using a mock.json networks file.
run: ./tasks/prepare-manifest.sh mock
working-directory: ${{ env.subgraph-working-directory }}

- name: "Generate meta.ignore.ts file"
# Collects metadata like the git branch and commit hash
run: "yarn generate-sf-meta"
working-directory: ${{ env.subgraph-working-directory }}
env:
COMMIT_HASH: ${{ github.sha }}
CONFIGURATION: ${{ inputs.deployment_env }}

- name: "Generate AssemblyScript types"
run: "yarn codegen"
working-directory: ${{ env.subgraph-working-directory }}

- name: Get Hosted Service Networks from metadata
run: npx ts-node ./scripts/getHostedServiceNetworks.ts
working-directory: ${{ env.subgraph-working-directory }}

# - name: Ensure deployment_env property is passed
# run: |
# if [ "${{ inputs.deployment_env }}" == "" ];then
# echo "You must pass in the deployment_env at a minimum."
# exit 1
# fi

# If tagged, get subgraph tag name that starts with subgraph@. Outputs $GIT_TAG_NAME
- uses: olegtarasov/[email protected]
id: "getSubgraphTag"
with:
tagRegex: "subgraph@(.*)"

# Version is the git tag or revision
# Version is from subgraph@<version> git tag if exists, else short git commit revision
- name: "Deploy to a node"
run: |
shortRev=$(git rev-parse --short ${{ github.sha }})
versionLabel="${GIT_TAG_NAME:-$shortRev}"
./tasks/deploy.sh -o ${{ inputs.vendor }} -n ${{ inputs.network }} -r ${{ inputs.deployment_env }} -v $versionLabel
working-directory: ${{ env.subgraph-working-directory }}
versionTag=$(git tag --contains ${{ github.sha }} | grep "^subgraph@" | sed 's/^subgraph@//')
versionLabel="${versionTag:-$shortRev}"
./tasks/deploy.sh -o ${{ inputs.vendor }} -n ${{ matrix.network }} -r ${{ inputs.deployment_env }} -v $versionLabel
working-directory: ./packages/subgraph
env:
SUBGRAPH_URL_TEMPLATE: ${{ secrets.SUBGRAPH_URL_TEMPLATE }}
SUPERFLUID_IPFS_API: ${{ secrets.SUPERFLUID_IPFS_API }}
THE_GRAPH_ACCESS_TOKEN: ${{ secrets.THE_GRAPH_ACCESS_TOKEN }}
SATSUMA_DEPLOY_KEY: ${{ secrets.SATSUMA_DEPLOY_KEY }}
GOLDSKY_API_KEY: ${{ secrets.GOLDSKY_API_KEY }}
AIRSTACK_API_KEY: ${{ secrets.AIRSTACK_API_KEY }}
COMMIT_HASH: ${{ github.sha }}
CONFIGURATION: ${{ inputs.deployment_env }}
10 changes: 5 additions & 5 deletions .github/workflows/call.test-ethereum-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
id: set-matrix
run: |
if [ "${{ inputs.run-coverage-tests }}" == "true" ];then
echo "matrix={\"node-version\": [20]}" >> "$GITHUB_OUTPUT"
echo "matrix={\"node-version\": [22]}" >> "$GITHUB_OUTPUT"
else
echo "matrix={\"node-version\": [18, 20]}" >> "$GITHUB_OUTPUT"
echo "matrix={\"node-version\": [18, 20, 22]}" >> "$GITHUB_OUTPUT"
fi
test-ethereum-contracts:
Expand All @@ -40,6 +40,7 @@ jobs:

strategy:
matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }}
fail-fast: false

env:
DEV_SHELL_NAME: ci-node${{ matrix.node-version }}
Expand All @@ -56,11 +57,10 @@ jobs:
- name: Set cache key prefix
id: set-cache-key-prefix
run: |
node_version=${{ matrix.node-version }}
if [ "${{ inputs.run-coverage-tests }}" == false ]; then
v=ethereum-contracts-test-${node_version}-
v=ethereum-contracts-${{ env.DEV_SHELL_NAME }}-test-
else
v=ethereum-contracts-coverage-${node_version}-
v=ethereum-contracts-${{ env.DEV_SHELL_NAME }}-coverage-
fi
echo "cache_key_prefix=$v" >> "$GITHUB_OUTPUT"
shell: bash
Expand Down
47 changes: 18 additions & 29 deletions .github/workflows/call.test-local-subgraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ on:
workflow_call:

env:
# FIXME: subgraph test fails with node20
DEV_SHELL_NAME: ci-node18
DEV_SHELL_NAME: ci-node22
ethereum-contracts-working-directory: ./packages/ethereum-contracts
sdk-core-working-directory: ./packages/sdk-core
subgraph-working-directory: ./packages/subgraph

jobs:
subgraph-unit-tests:
name: Run subgraph unit tests
runs-on: ubuntu-latest

env:
subgraph-working-directory: ./packages/subgraph

defaults:
run:
shell: nix develop .#${{ env.DEV_SHELL_NAME }} -c bash -xe {0}
Expand All @@ -27,7 +26,7 @@ jobs:
uses: ./.github/actions/setup-workflow-base
with:
package-name: subgraph
cache-key-prefix: subgraph-unit-tests-
cache-key-prefix: subgraph-${{ env.DEV_SHELL_NAME }}-unit-tests-
dev-shell-name: ${{ env.DEV_SHELL_NAME }}

- name: Install dependencies
Expand All @@ -42,7 +41,7 @@ jobs:
run: |
yarn lint
yarn build
working-directory: ./packages/ethereum-contracts
working-directory: ${{ env.ethereum-contracts-working-directory }}

- name: Run unit tests
if: steps.base.outputs.cache-hit != 'true'
Expand All @@ -54,10 +53,6 @@ jobs:

runs-on: ubuntu-latest

env:
subgraph-working-directory: ./packages/subgraph
sdk-core-working-directory: ./packages/sdk-core

defaults:
run:
shell: nix develop .#${{ env.DEV_SHELL_NAME }} -c bash -xe {0}
Expand All @@ -70,7 +65,7 @@ jobs:
uses: ./.github/actions/setup-workflow-base
with:
package-name: subgraph
cache-key-prefix: subgraph-integration-tests-
cache-key-prefix: subgraph-${{ env.DEV_SHELL_NAME }}-integration-tests-
dev-shell-name: ${{ env.DEV_SHELL_NAME }}

- name: Install dependencies
Expand All @@ -80,41 +75,35 @@ jobs:
- name: Build contracts
if: steps.base.outputs.cache-hit != 'true'
run: yarn build
working-directory: ./packages/ethereum-contracts

- name: Start hardhat node
if: steps.base.outputs.cache-hit != 'true'
run: ./tasks/startHardhatNode.sh start
working-directory: ${{ env.sdk-core-working-directory }}
working-directory: ${{ env.ethereum-contracts-working-directory }}

- name: Build SDK core
if: steps.base.outputs.cache-hit != 'true'
# build sdk-core because subgraph tests use sdk-core
run: yarn build
working-directory: ${{ env.sdk-core-working-directory }}

- name: Start hardhat node
if: steps.base.outputs.cache-hit != 'true'
run: ./tasks/startHardhatNode.sh start
working-directory: ${{ env.sdk-core-working-directory }}

- name: Deploy framework and tokens
if: steps.base.outputs.cache-hit != 'true'
run: npx hardhat run dev-scripts/run-deploy-contracts-and-token.js --network localhost
working-directory: ./packages/ethereum-contracts
working-directory: ${{ env.ethereum-contracts-working-directory }}

- name: Prepare files for local testing
if: steps.base.outputs.cache-hit != 'true'
run: yarn prepare-local
working-directory: ${{ env.subgraph-working-directory }}

- name: Run setup-graph-node
if: steps.base.outputs.cache-hit != 'true'
run: |
chmod +x ./tasks/setup-graph-node.sh
./tasks/setup-graph-node.sh
working-directory: ${{ env.subgraph-working-directory }}

- name: Docker compose
- name: Setup graph node
if: steps.base.outputs.cache-hit != 'true'
run: |
docker rm subgraph_graph-node_1 || true
docker compose up &
./tasks/setup-graph-node.sh &
# wait for it to warm up
sleep 15
working-directory: ${{ env.subgraph-working-directory }}

- name: Run subgraph integration test suite
Expand Down
45 changes: 18 additions & 27 deletions .github/workflows/call.test-sdk-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ jobs:
id: set-matrix
run: |
if [ "${{ inputs.run-coverage-tests }}" == "true" ];then
echo "matrix={\"node-version\": [18]}" >> "$GITHUB_OUTPUT"
echo "matrix={\"node-version\": [22]}" >> "$GITHUB_OUTPUT"
else
# FIXME: subgraph test fails with node20
echo "matrix={\"node-version\": [18]}" >> "$GITHUB_OUTPUT"
echo "matrix={\"node-version\": [18, 20, 22]}" >> "$GITHUB_OUTPUT"
fi
test-sdk-core:
Expand All @@ -44,6 +43,7 @@ jobs:

strategy:
matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }}
fail-fast: false

env:
DEV_SHELL_NAME: ci-node${{ matrix.node-version }}
Expand All @@ -63,11 +63,10 @@ jobs:
- name: Set cache key prefix
id: set-cache-key-prefix
run: |
node_version=${{ matrix.node-version }}
if [ "${{ inputs.run-coverage-tests }}" == false ]; then
v=sdk-core-test-${node_version}-
v=sdk-core-${{ env.DEV_SHELL_NAME }}-test-
else
v=sdk-core-coverage-${node_version}-
v=sdk-core-${{ env.DEV_SHELL_NAME }}-coverage-
fi
echo "cache_key_prefix=$v" >> "$GITHUB_OUTPUT"
shell: bash
Expand All @@ -87,19 +86,12 @@ jobs:
npx tsc --version
npx hardhat --version
- name: Lint and build essentials
- name: Build contracts
if: steps.base.outputs.cache-hit != 'true'
run: |
yarn lint
yarn build
working-directory: ${{ env.ethereum-contracts-working-directory }}

- name: Start hardhat node
if: steps.base.outputs.cache-hit != 'true'
run: |
./tasks/startHardhatNode.sh start
working-directory: ${{ env.sdk-core-working-directory }}

- name: Build SDK Core
if: steps.base.outputs.cache-hit != 'true'
# build sdk-core because of auto linking to dependency
Expand All @@ -108,7 +100,12 @@ jobs:
yarn build
working-directory: ${{ env.sdk-core-working-directory }}

- name: Deploy Framework and Tokens
- name: Start hardhat node
if: steps.base.outputs.cache-hit != 'true'
run: ./tasks/startHardhatNode.sh start
working-directory: ${{ env.sdk-core-working-directory }}

- name: Deploy framework and tokens
if: steps.base.outputs.cache-hit != 'true'
run: npx hardhat run dev-scripts/run-deploy-contracts-and-token.js --network localhost
working-directory: ${{ env.ethereum-contracts-working-directory }}
Expand All @@ -118,26 +115,20 @@ jobs:
run: yarn prepare-local
working-directory: ${{ env.subgraph-working-directory }}

- name: Run setup-graph-node
if: steps.base.outputs.cache-hit != 'true'
run: |
chmod +x ./tasks/setup-graph-node.sh
./tasks/setup-graph-node.sh
working-directory: ${{ env.subgraph-working-directory }}

- name: Docker compose
- name: Setup graph node
if: steps.base.outputs.cache-hit != 'true'
run: |
docker rm subgraph_graph-node_1 || true
docker compose up &
./tasks/setup-graph-node.sh &
# wait for it to warm up
sleep 15
working-directory: ${{ env.subgraph-working-directory }}

- name: Build and deploy local subgraph
if: steps.base.outputs.cache-hit != 'true'
run: |
yarn build-and-deploy-local
# artificial slow down to give the subgraph time to sync
sleep 30
# wait for it to sync
sleep 15
working-directory: ${{ env.subgraph-working-directory }}

- name: Run test suite
Expand Down
Loading

0 comments on commit 6b5bf76

Please sign in to comment.