Skip to content

Fix tests - Subgraph stopped resolving some names (#511) #309

Fix tests - Subgraph stopped resolving some names (#511)

Fix tests - Subgraph stopped resolving some names (#511) #309

name: NameGuard - End-to-End Tests
on:
push:
branches:
- main
- staging
paths:
- "packages/nameguard-sdk/**"
- "packages/nameguard-python/**"
- ".github/workflows/nameguard-end-to-end-tests.yml"
pull_request:
branches:
- main
- staging
paths:
- "packages/nameguard-sdk/**"
- "packages/nameguard-python/**"
- ".github/workflows/nameguard-end-to-end-tests.yml"
jobs:
check_changes:
runs-on: ubuntu-latest
outputs:
api_changed: ${{ steps.check.outputs.api_changed }}
sdk_changed: ${{ steps.check.outputs.sdk_changed }}
steps:
- name: Checkout NameKit repo
uses: actions/checkout@v4
- name: Check for changes
id: check
run: |
git fetch origin ${{ github.base_ref }}
API_CHANGED=$(git diff --name-only origin/${{ github.base_ref }} HEAD | grep "^packages/nameguard-python/" | wc -l)
SDK_CHANGED=$(git diff --name-only origin/${{ github.base_ref }} HEAD | grep "^packages/nameguard-sdk/" | wc -l)
echo "api_changed=$API_CHANGED" >> $GITHUB_OUTPUT
echo "sdk_changed=$SDK_CHANGED" >> $GITHUB_OUTPUT
test:
needs: check_changes
if: needs.check_changes.outputs.api_changed > 0 || needs.check_changes.outputs.sdk_changed > 0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "pnpm"
- name: Install npm dependencies
run: pnpm install --frozen-lockfile
- name: Install poetry
if: needs.check_changes.outputs.api_changed > 0
run: pipx install poetry
- name: Set up Python
if: needs.check_changes.outputs.api_changed > 0
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: "poetry"
- name: Install dependencies
if: needs.check_changes.outputs.api_changed > 0
working-directory: ./packages/nameguard-python
run: poetry install --with dev
- name: Build the SDK
run: pnpm build
- name: Setup local nameguard api
if: needs.check_changes.outputs.api_changed > 0
working-directory: ./packages/nameguard-python
env:
PROVIDER_URI_MAINNET: ${{ secrets.PROVIDER_URI_MAINNET }}
PROVIDER_URI_SEPOLIA: ${{ secrets.PROVIDER_URI_SEPOLIA }}
ALCHEMY_URI_MAINNET: ${{ secrets.ALCHEMY_URI_MAINNET }}
ALCHEMY_URI_SEPOLIA: ${{ secrets.ALCHEMY_URI_SEPOLIA }}
ENS_SUBGRAPH_URL_MAINNET: ${{ secrets.ENS_SUBGRAPH_URL_MAINNET }}
ENS_SUBGRAPH_URL_SEPOLIA: ${{ secrets.ENS_SUBGRAPH_URL_SEPOLIA }}
run: |
poetry run uvicorn nameguard.web_api:app --host 0.0.0.0 --port 8000 &
sleep 5
- name: Local api healthcheck
if: needs.check_changes.outputs.api_changed > 0
run: curl http://0.0.0.0:8000/inspect-name/mainnet/test.eth
- name: Set NAMEGUARD_API_URI
id: set_api_uri
env:
PRODUCTION_NAMEGUARD_API_URI: ${{ vars.PRODUCTION_NAMEGUARD_API_URI }}
run: |
if [ "${{ needs.check_changes.outputs.api_changed }}" -gt 0 ]; then
echo "NAMEGUARD_API_URI=http://0.0.0.0:8000" >> $GITHUB_ENV
else
echo "NAMEGUARD_API_URI=$PRODUCTION_NAMEGUARD_API_URI" >> $GITHUB_ENV
fi
- name: Run tests
env:
PROVIDER_URI_MAINNET: ${{ secrets.PROVIDER_URI_MAINNET }}
PROVIDER_URI_SEPOLIA: ${{ secrets.PROVIDER_URI_SEPOLIA }}
run: pnpm test --filter ./packages/nameguard-sdk