Skip to content

Commit

Permalink
Merge branch 'dev' into optimize-subgraph-indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparkallas authored Sep 12, 2024
2 parents 4314ffd + 2b2fe84 commit b480356
Show file tree
Hide file tree
Showing 294 changed files with 11,444 additions and 9,510 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
// 3. if you want to use nix further, do "nix develop"
"postCreateCommand": [
"curl -L https://foundry.paradigm.xyz | bash",
"source /home/node/.bashrc && foundryup",
"source /home/vscode/.bashrc && foundryup",
"yarn global add npm-run-all",
"yarn install && yarn build",
"sudo apt-get install libpq5", // for subgraph's matchstick
"./tasks/fix-devcontainer.sh && nix develop . -c bash <(echo \"yarn install && yarn build\")"
"./tasks/fix-devcontainer.sh && yarn shell . -c bash <(echo \"yarn install && yarn build\")"
]
// Configure tool-specific properties.
// "customizations": {},
Expand Down
52 changes: 52 additions & 0 deletions .github/actions/setup-workflow-base/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Setup Workflow Base
description: >
This sets up the base for a workflow, where:
- nix is installed,
- cache is looked up,
- and nix dev shell is setup if cache is missed.
inputs:
package-name:
description: Name of the package where input files are from
required: true
cache-key-prefix:
description: Cache key prefix to attach to the calculated input files hash
required: true
dev-shell-name:
description: Default shell to be used

outputs:
cache-hit:
value: ${{ steps.cache.outputs.cache-hit }}

runs:
using: composite
steps:
- uses: DeterminateSystems/nix-installer-action@v13

- name: Load the half-board nix module
id: hb
run: |
./tasks/mk-cache-key.sh ./packages/${{ inputs.package-name }} > cache.json
jq . cache.json
key_prefix="${{ inputs.cache-key-prefix }}"
path=$(jq '.outputs | join("\n")' cache.json)
hash=$(jq -r .hash cache.json)
echo "path=$path" >> "$GITHUB_OUTPUT"
echo "key=${key_prefix}${hash}" >> "$GITHUB_OUTPUT"
shell: nix develop .#mk-cache-key -c bash -xe {0}

- name: Lookup cache
id: cache
uses: actions/cache@v4
with:
path: ${{ fromJSON(steps.hb.outputs.path) }}
key: ${{ steps.hb.outputs.key }}

- name: Initialize nix dev shell
if: steps.cache.outputs.cache-hit != 'true'
run: |
node --version
yarn --version
shell: nix develop .#${{ inputs.dev-shell-name }} -c bash -xe {0}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ jobs:

defaults:
run:
shell: nix develop -c bash -xe {0}
shell: nix develop .#ci-default -c bash -xe {0}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

- name: "Install dependencies"
run: yarn install --frozen-lockfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/call.deploy-dry-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
ethereum-contracts-working-directory: ./packages/ethereum-contracts

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install and Build
run: |
Expand Down
89 changes: 39 additions & 50 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, graph, satsuma, goldsky 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,19 +55,45 @@ 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:
shell: nix develop -c bash {0}
shell: nix develop .#ci-default -c bash {0}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: cachix/install-nix-action@v19
with:
Expand All @@ -80,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 }}
35 changes: 22 additions & 13 deletions .github/workflows/call.test-automation-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,44 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18, 20]

defaults:
run:
shell: nix develop .#ci-node${{ matrix.node-version }} -c bash -xe {0}
shell: nix develop .#ci-default -c bash -xe {0}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: cachix/install-nix-action@v19
- name: Setup workflow base
id: base
uses: ./.github/actions/setup-workflow-base
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
package-name: automation-contracts
cache-key-prefix: automation-contracts-
dev-shell-name: ci-default

- name: Install, lint and build
- name: Install dependencies
if: steps.base.outputs.cache-hit != 'true'
run: |
yarn install --frozen-lockfile
solc --version
forge --version
- name: Lint and build
if: steps.base.outputs.cache-hit != 'true'
run: |
yarn lint
yarn build
- name: Test automation-contracts-scheduler
if: steps.base.outputs.cache-hit != 'true'
run: |
echo "FOUNDRY_PROFILE=ci" >> $GITHUB_ENV
echo "FOUNDRY_SOLC_VERSION=$SOLC" >> $GITHUB_ENV
yarn workspace scheduler test
env:
FOUNDRY_PROFILE: ci

- name: Test automation-contracts-autowrap
if: steps.base.outputs.cache-hit != 'true'
run: |
echo "FOUNDRY_PROFILE=ci" >> $GITHUB_ENV
echo "FOUNDRY_SOLC_VERSION=$SOLC" >> $GITHUB_ENV
yarn workspace autowrap test
env:
FOUNDRY_PROFILE: ci
Loading

0 comments on commit b480356

Please sign in to comment.