Skip to content

Refactor: viem-first mintWithRouter lib + unified tests; remove legacy code #27

Refactor: viem-first mintWithRouter lib + unified tests; remove legacy code

Refactor: viem-first mintWithRouter lib + unified tests; remove legacy code #27

name: Integration (Tenderly VirtualNet)
on:
workflow_dispatch:
pull_request:
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/integration-tenderly-vnet.yml'
permissions:
contents: read
concurrency:
group: integration-tenderly-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.55.0-noble
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install system deps (unzip + jq)
run: |
apt-get update
apt-get install -y unzip jq
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install deps
run: bun install --frozen-lockfile
- name: Create Tenderly VirtualNet
shell: bash
id: vnet
env:
TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }}
TENDERLY_TOKEN: ${{ secrets.TENDERLY_TOKEN }}
TENDERLY_ACCOUNT: ${{ secrets.TENDERLY_ACCOUNT }}
TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }}
TENDERLY_VNET_MODE: ${{ vars.TENDERLY_VNET_MODE }}
TENDERLY_VNET_TEMPLATE: ${{ vars.TENDERLY_VNET_TEMPLATE }}
TENDERLY_FORK_NETWORK_ID: ${{ vars.TENDERLY_FORK_NETWORK_ID }}
TENDERLY_VNET_BLOCK: ${{ vars.TENDERLY_VNET_BLOCK }}
TENDERLY_VNET_CREATE_JSON: ${{ secrets.TENDERLY_VNET_CREATE_JSON }}
run: |
set -euo pipefail
if [ -z "${TENDERLY_ACCESS_KEY:-}" ] || [ -z "${TENDERLY_ACCOUNT:-}" ] || [ -z "${TENDERLY_PROJECT:-}" ]; then
echo "Tenderly secrets not configured (TENDERLY_ACCESS_KEY, TENDERLY_ACCOUNT, TENDERLY_PROJECT)." >&2
exit 1
fi
# Create VirtualNet (support both template and fork modes, or full JSON override)
CREATE_BODY="${TENDERLY_VNET_CREATE_JSON:-}"
if [ -z "$CREATE_BODY" ]; then
MODE=${TENDERLY_VNET_MODE:-fork}
NID=${TENDERLY_FORK_NETWORK_ID:-8453}
BLOCK=${TENDERLY_VNET_BLOCK:-latest}
# Convert decimal block to hex if needed
if [[ "$BLOCK" != latest && "$BLOCK" != 0x* ]]; then
BLOCK=$(printf "0x%x" "$BLOCK")
fi
SLUG="ci-${{ github.run_id }}"
CREATE_BODY=$(jq -n \
--arg slug "$SLUG" \
--arg name "$SLUG" \
--argjson nid "$NID" \
--arg block "$BLOCK" \
'{slug: $slug, display_name: $name, fork_config: {network_id: $nid, block_number: $block}, virtual_network_config: {chain_config: {chain_id: $nid}}, sync_state_config: {enabled: false}, explorer_page_config: {enabled: false, verification_visibility: "bytecode"}}')
fi
echo "Create body:"; echo "$CREATE_BODY" | jq .
# Auth header (Access-Key or Bearer)
if [ -n "${TENDERLY_TOKEN:-}" ]; then AUTH_HEADER="Authorization: Bearer $TENDERLY_TOKEN"; else AUTH_HEADER="X-Access-Key: $TENDERLY_ACCESS_KEY"; fi
resp=$(curl -sS -X POST \
"https://api.tenderly.co/api/v1/account/$TENDERLY_ACCOUNT/project/$TENDERLY_PROJECT/vnets" \
-H "Content-Type: application/json" \
-H "$AUTH_HEADER" \
-d "$CREATE_BODY")
echo "$resp" | jq .
id=$(echo "$resp" | jq -r .id)
rpc_url=$(echo "$resp" | jq -r '.rpcs[] | select(.name == "Admin RPC") | .url')
if [ -z "$id" ] || [ "$id" = "null" ] || [ -z "$rpc_url" ] || [ "$rpc_url" = "null" ]; then
echo "Failed to create VirtualNet; response:" >&2
echo "$resp" >&2
exit 1
fi
echo "id=$id" >> "$GITHUB_OUTPUT"
echo "rpc_url=$rpc_url" >> "$GITHUB_OUTPUT"
- name: Run integration tests (Tenderly VirtualNet)
env:
TEST_RPC_KIND: tenderly
TEST_RPC_URL: ${{ steps.vnet.outputs.rpc_url }}
run: bun run test:integration
- name: Run E2E tests (same VirtualNet)
env:
TEST_RPC_KIND: tenderly
TEST_RPC_URL: ${{ steps.vnet.outputs.rpc_url }}
run: bun run test:e2e
- name: Cleanup VirtualNet
shell: bash
if: always()
env:
TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }}
TENDERLY_TOKEN: ${{ secrets.TENDERLY_TOKEN }}
TENDERLY_ACCOUNT: ${{ secrets.TENDERLY_ACCOUNT }}
TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }}
VNET_ID: ${{ steps.vnet.outputs.id }}
run: |
if [ -n "${VNET_ID:-}" ]; then
if [ -n "${TENDERLY_TOKEN:-}" ]; then AUTH_HEADER="Authorization: Bearer $TENDERLY_TOKEN"; else AUTH_HEADER="X-Access-Key: $TENDERLY_ACCESS_KEY"; fi
curl -sS -X DELETE \
"https://api.tenderly.co/api/v1/account/$TENDERLY_ACCOUNT/project/$TENDERLY_PROJECT/vnets/$VNET_ID" \
-H "$AUTH_HEADER" \
-o /dev/null -w "HTTP %{http_code}\n"
else
echo "No VNet ID to delete"
fi