Skip to content
Closed
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
141 changes: 141 additions & 0 deletions .github/actions/old_anvil_and_api/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: "Start Anvil forks, fund wallet, and launch API"
description: "Starts Ethereum, Arbitrum, and Base Anvil forks, funds a wallet, clones mono repo, and runs the API."

inputs:
ethereum_rpc_url:
description: "Ethereum Mainnet RPC URL"
required: true
arbitrum_rpc_url:
description: "Arbitrum Mainnet RPC URL"
required: true
base_rpc_url:
description: "Base Mainnet RPC URL"
required: true
private_key:
description: "Private key of the wallet to fund"
required: true
mono_app_id:
description: "GitHub App ID for mono repo"
required: true
mono_app_private_key:
description: "Private key for the GitHub App for mono repo"
required: true
fund_amount_eth:
description: "ETH amount to fund the wallet with"
default: "10"

outputs:
ethereum_local_url:
description: "Localhost RPC URL for Ethereum Anvil instance"
arbitrum_local_url:
description: "Localhost RPC URL for Arbitrum Anvil instance"
base_local_url:
description: "Localhost RPC URL for Base Anvil instance"

runs:
using: "composite"
steps:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
cache: false

- name: Start Anvil Fork Ethereum
shell: bash
run: |
anvil \
--block-time 0.05 \
--hardfork prague \
--host 0.0.0.0 \
--fork-url "${{ inputs.ethereum_rpc_url }}" \
--port 8545 \
--chain-id 1 \
--no-rate-limit &
echo "ethereum_local_url=http://localhost:8545" >> $GITHUB_OUTPUT

- name: Start Anvil Fork Arbitrum
shell: bash
run: |
anvil \
--block-time 0.05 \
--hardfork prague \
--host 0.0.0.0 \
--fork-url "${{ inputs.arbitrum_rpc_url }}" \
--port 8547 \
--chain-id 42161 \
--no-rate-limit &
echo "arbitrum_local_url=http://localhost:8547" >> $GITHUB_OUTPUT

- name: Start Anvil Fork Base
shell: bash
run: |
anvil \
--block-time 0.05 \
--hardfork prague \
--host 0.0.0.0 \
--fork-url "${{ inputs.base_rpc_url }}" \
--port 8546 \
--chain-id 8453 \
--no-rate-limit &
sleep 5
echo "base_local_url=http://localhost:8546" >> $GITHUB_OUTPUT

- name: Fund Wallet
shell: bash
run: |
WALLET_ADDRESS=$(cast wallet address --private-key "${{ inputs.private_key }}")
echo "Funding wallet: $WALLET_ADDRESS"
WEI_AMOUNT=$(cast to-wei "${{ inputs.fund_amount_eth }}" ether)
cast rpc anvil_setBalance $WALLET_ADDRESS $WEI_AMOUNT --rpc-url http://localhost:8545
cast rpc anvil_setBalance $WALLET_ADDRESS $WEI_AMOUNT --rpc-url http://localhost:8546
cast rpc anvil_setBalance $WALLET_ADDRESS $WEI_AMOUNT --rpc-url http://localhost:8547

# - name: Verify Wallet Balance
# shell: bash
# run: |
# WALLET_ADDRESS=$(cast wallet address --private-key "${{ inputs.private_key }}")
# BALANCE=$(cast balance $WALLET_ADDRESS --rpc-url http://localhost:8547)
# BALANCE_ETH=$(cast from-wei $BALANCE ether)
# echo "Wallet balance: $BALANCE_ETH ETH"
# if [ "$(echo "$BALANCE_ETH >= ${{ inputs.fund_amount_eth }}" | bc)" -ne 1 ]; then
# echo "Balance verification failed: Wallet has less ETH than expected"
# exit 1
# fi

- name: Generate GitHub App Token
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ inputs.mono_app_id }}
private_key: ${{ inputs.mono_app_private_key }}

- name: Checkout mono repo
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.generate_token.outputs.token }}
repository: "CompassLabs/mono"
path: "mono"

- name: Install uv
shell: bash
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Start API
shell: bash
working-directory: mono/api
env:
ETHEREUM_MAINNET_RPC_URL: http://localhost:8545
ARBITRUM_MAINNET_RPC_URL: http://localhost:8547
BASE_MAINNET_RPC_URL: http://localhost:8546
PENDLE_API_URL: https://api-v2.pendle.finance
MORPHO_GRAPHQL_API_URL: https://blue-api.morpho.org/graphql
THE_GRAPH_URL_AAVE_ARBITRUM: https://gateway.thegraph.com/api/subgraphs/id/notvalid
THE_GRAPH_URL_AAVE_ETHEREUM: https://gateway.thegraph.com/api/subgraphs/id/notvalid
THE_GRAPH_URL_AAVE_BASE: https://gateway.thegraph.com/api/subgraphs/id/notvalid
THE_GRAPH_API_KEY: notvalid
ENV: "production"
run: |
make install && make run &
until curl -s http://localhost:8000/health >/dev/null; do sleep 1; done
echo "API is running"
156 changes: 156 additions & 0 deletions .github/workflows/EXPERIMENT.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: FAILING_TEST

on:
schedule:
# Runs at 00:00 UTC every day
- cron: "0 0 * * *"
push:
branches:
- main
#- fix-failing-tests
workflow_dispatch:
inputs:
environment:
description: "Environment to test"
required: true
type: string

workflow_call:
inputs:
environment:
description: "Environment to test"
required: true
type: string

permissions:
id-token: write
contents: write

env:
AWS_ECR_STS_ROLE: arn:aws:iam::688567264391:role/DojoApiCIRole

jobs:
validate-environment:
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.validate.outputs.environment }}
steps:
- name: Validate environment input
id: validate
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" || "${{ github.event_name }}" == "workflow_call" ]]; then
ENVIRONMENT="${{ inputs.environment }}"
else
ENVIRONMENT="local"
fi
if [[ "$ENVIRONMENT" != "staging" && "$ENVIRONMENT" != "prod" && "$ENVIRONMENT" != "local" ]]; then
echo "❌ Error: Invalid environment '$ENVIRONMENT'. Must be 'staging' or 'prod' or 'local'."
exit 1
fi
echo "✅ Environment '$ENVIRONMENT' is valid"
echo "environment=staging" >> $GITHUB_OUTPUT

set-versions:
needs: [validate-environment]
runs-on: ubuntu-latest
outputs:
npm_package_version: ${{ steps.set-versions.outputs.npm_package_version }}
uv_package_version: ${{ steps.set-versions.outputs.uv_package_version }}
steps:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"

- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Set versions
id: set-versions
run: |
if [[ "${{ needs.validate-environment.outputs.environment }}" == "staging" ]]; then
NPM_PACKAGE_VERSION=$(npm view @compass-labs/api-sdk versions --json | jq -r '.[]' | grep -E 'rc|alpha|beta' | sort -V | tail -1)
UV_PACKAGE_VERSION="$(curl -s https://pypi.org/pypi/compass-api-sdk/json | jq -r '.releases | keys | .[]' | grep -E 'rc|a|b|dev' | sort -V | tail -1)"
else
NPM_PACKAGE_VERSION="latest"
UV_PACKAGE_VERSION="latest"
fi

echo "npm_package_version=$NPM_PACKAGE_VERSION" >> $GITHUB_OUTPUT
echo "uv_package_version=$UV_PACKAGE_VERSION" >> $GITHUB_OUTPUT


print-context:
needs: [validate-environment, set-versions]
runs-on: ubuntu-latest
steps:
- name: Show resolved values
run: |
echo "environment: ${{ needs.validate-environment.outputs.environment }}"
echo "uv_package_version: ${{ needs.set-versions.outputs.uv_package_version }}"



run-python----basic-examples-deposit-on-morpho: #
needs: [validate-environment, set-versions]

runs-on: ubuntu-latest
env:
COMPASS_API_KEY: ${{ secrets.COMPASS_API_KEY }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
BASE_RPC_URL: http://localhost:8546
#BASE_RPC_URL: ${{ secrets.BASE_MAINNET_RPC_URL }}
SERVER_URL: http://localhost:80
#SERVER_URL: https://api.compasslabs.ai # uncomment this to test against staging api
NPM_PACKAGE_VERSION: ${{ needs.set-versions.outputs.npm_package_version }}
UV_PACKAGE_VERSION: ${{ needs.set-versions.outputs.uv_package_version }}
#API_KEY:

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Start up full local API and anvil
uses: ./.github/actions/local_anvil_and_api
id: local_anvil_and_api
with:
ethereum_rpc_url: ${{ secrets.ETHEREUM_MAINNET_RPC_URL }}
arbitrum_rpc_url: ${{ secrets.ARBITRUM_MAINNET_RPC_URL }}
base_rpc_url: ${{ secrets.BASE_MAINNET_RPC_URL }}
private_key: ${{ secrets.PRIVATE_KEY }}
mono_app_id: ${{ secrets.MONOREPOAPP_ID }}
mono_app_private_key: ${{ secrets.MONOREPOAPP_PRIVATE_KEY }}
fund_amount_eth: "10"
environment: ${{ needs.validate-environment.outputs.environment }}
aws_ecr_sts_role: ${{ env.AWS_ECR_STS_ROLE }}
ecr_image_uri: 688567264391.dkr.ecr.eu-west-2.amazonaws.com/dojo_api

- name: Install dependencies
working-directory: v1/basic_examples/deposit_on_morpho/python
run: |
if [[ "$UV_PACKAGE_VERSION" != "latest" ]]; then
echo "Installing compass-api-sdk==$UV_PACKAGE_VERSION"
uv add compass-api-sdk==$UV_PACKAGE_VERSION
fi
uv sync
uv pip freeze

- name: Show pyproject.toml
working-directory: v1/basic_examples/deposit_on_morpho/python
run: cat pyproject.toml

- name: Show compass-api-sdk version
working-directory: v1/basic_examples/deposit_on_morpho/python
run: uv pip show compass-api-sdk || echo "compass-api-sdk not installed"

- name: Run example
working-directory: v1/basic_examples/deposit_on_morpho/python
run: ./.venv/bin/python main.py #src/main.py #





Loading