Skip to content
Merged
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
150 changes: 148 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,86 @@
cache: 'yarn'
- run: yarn --immutable
- run: yarn lint

setup-chopsticks-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'yarn'
- run: yarn --immutable

- name: Initialize Chopsticks DBs
run: |
# Source block numbers
source KNOWN_GOOD_BLOCK_NUMBERS_POLKADOT.env
source KNOWN_GOOD_BLOCK_NUMBERS_KUSAMA.env

# Start PAH chopsticks with DB
npx @acala-network/chopsticks@latest \
--endpoint=wss://sys.ibp.network/asset-hub-polkadot \
--block=$ASSETHUBPOLKADOT_BLOCK_NUMBER \
--db=/tmp/pah.db \
--port=8001 > /tmp/pah.log 2>&1 &
PAH_PID=$!

# Start KAH chopsticks with DB
npx @acala-network/chopsticks@latest \
--endpoint=wss://sys.ibp.network/asset-hub-kusama \
--block=$ASSETHUBKUSAMA_BLOCK_NUMBER \
--db=/tmp/kah.db \
--port=8002 > /tmp/kah.log 2>&1 &
KAH_PID=$!

# Wait for both servers to be ready
timeout=180
for port in 8001 8002; do
elapsed=0
while [ $elapsed -lt $timeout ]; do
if nc -z localhost $port 2>/dev/null; then
echo "Chopsticks on port $port ready"
break
fi
sleep 2
elapsed=$((elapsed + 2))
done
if [ $elapsed -ge $timeout ]; then
echo "Timeout waiting for chopsticks on port $port"
cat /tmp/*.log
exit 1
fi
done

# Kill servers after initialization
kill $PAH_PID $KAH_PID || true
sleep 2

# Verify DBs were created and are non-empty
for db in /tmp/pah.db /tmp/kah.db; do
if [ ! -f "$db" ]; then
echo "Error: $db not found"
exit 1
fi
size=$(stat -f%z "$db" 2>/dev/null || stat -c%s "$db" 2>/dev/null)
if [ "$size" -eq 0 ]; then
echo "Error: $db is empty"
exit 1
fi
echo "✓ $db created successfully (${size} bytes)"
done

- name: Cache Chopsticks DBs
uses: actions/cache/save@v4
with:
path: |
/tmp/pah.db
/tmp/kah.db
key: chopsticks-db-${{ hashFiles('KNOWN_GOOD_BLOCK_NUMBERS_*.env') }}

define-matrix:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.tests.outputs.tests }}
Expand All @@ -32,24 +111,91 @@
id: tests
run: |
echo tests=$(cd packages && ls */src/*.test.ts | jq -R -s -c 'split("\n")[:-1]') >> "$GITHUB_OUTPUT"

tests:
needs: define-matrix
needs: [define-matrix, setup-chopsticks-cache]
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
tests: ${{ fromJSON(needs.define-matrix.outputs.tests) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: setup node env
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'yarn'
- run: yarn --immutable
- run: yarn test packages/${{ matrix.tests }}

- name: Install Chopsticks
run: npm install -g @acala-network/chopsticks@latest

- name: Restore Chopsticks DBs
uses: actions/cache/restore@v4
with:
path: |
/tmp/pah.db
/tmp/kah.db
key: chopsticks-db-${{ hashFiles('KNOWN_GOOD_BLOCK_NUMBERS_*.env') }}
fail-on-cache-miss: true

- name: Start Chopsticks if needed
run: |
if echo "${{ matrix.tests }}" | grep -qi "assetHubPolkadot"; then
echo "Starting PAH chopsticks"
chopsticks \
--endpoint=wss://sys.ibp.network/asset-hub-polkadot \
--db=/tmp/pah.db \
--port=8001 > /tmp/chopsticks.log 2>&1 &
echo $! > /tmp/chopsticks.pid
PORT=8001
ENDPOINT_VAR="ASSETHUBPOLKADOT_ENDPOINT"
elif echo "${{ matrix.tests }}" | grep -qi "assetHubKusama"; then
echo "Starting KAH chopsticks"
chopsticks \
--endpoint=wss://sys.ibp.network/asset-hub-kusama \
--db=/tmp/kah.db \
--port=8002 > /tmp/chopsticks.log 2>&1 &
echo $! > /tmp/chopsticks.pid
PORT=8002
ENDPOINT_VAR="ASSETHUBKUSAMA_ENDPOINT"
else
echo "No chopsticks needed for this test"
exit 0
fi

# Wait for server
timeout=60
elapsed=0
while [ $elapsed -lt $timeout ]; do
if nc -z localhost $PORT 2>/dev/null; then
echo "Chopsticks ready on port $PORT"
echo "${ENDPOINT_VAR}=ws://localhost:${PORT}" >> $GITHUB_ENV
break
fi
sleep 2
elapsed=$((elapsed + 2))
done

if [ $elapsed -ge $timeout ]; then
echo "Timeout waiting for chopsticks"
cat /tmp/chopsticks.log
exit 1
fi

- name: Run Test
run: yarn test packages/${{ matrix.tests }}

- name: Cleanup
if: always()
run: |
if [ -f /tmp/chopsticks.pid ]; then
kill $(cat /tmp/chopsticks.pid) || true
fi

all-passed:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
runs-on: ubuntu-latest
needs: tests
if: always()
Expand Down
143 changes: 141 additions & 2 deletions .github/workflows/update-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,87 @@ env:
GH_TOKEN: ${{ github.token }}

jobs:
setup-chopsticks-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'yarn'
- run: yarn --immutable
- run: yarn update-known-good

- name: Initialize Chopsticks DBs
run: |
# Source block numbers
source KNOWN_GOOD_BLOCK_NUMBERS_POLKADOT.env
source KNOWN_GOOD_BLOCK_NUMBERS_KUSAMA.env

# Start PAH chopsticks with DB
npx @acala-network/chopsticks@latest \
--endpoint=wss://sys.ibp.network/asset-hub-polkadot \
--block=$ASSETHUBPOLKADOT_BLOCK_NUMBER \
--db=/tmp/pah.db \
--port=8001 > /tmp/pah.log 2>&1 &
PAH_PID=$!

# Start KAH chopsticks with DB
npx @acala-network/chopsticks@latest \
--endpoint=wss://sys.ibp.network/asset-hub-kusama \
--block=$ASSETHUBKUSAMA_BLOCK_NUMBER \
--db=/tmp/kah.db \
--port=8002 > /tmp/kah.log 2>&1 &
KAH_PID=$!

# Wait for both servers to be ready
timeout=180
for port in 8001 8002; do
elapsed=0
while [ $elapsed -lt $timeout ]; do
if nc -z localhost $port 2>/dev/null; then
echo "Chopsticks on port $port ready"
break
fi
sleep 2
elapsed=$((elapsed + 2))
done
if [ $elapsed -ge $timeout ]; then
echo "Timeout waiting for chopsticks on port $port"
cat /tmp/*.log
exit 1
fi
done

# Kill servers after initialization
kill $PAH_PID $KAH_PID || true
sleep 2

# Verify DBs were created and are non-empty
for db in /tmp/pah.db /tmp/kah.db; do
if [ ! -f "$db" ]; then
echo "Error: $db not found"
exit 1
fi
size=$(stat -f%z "$db" 2>/dev/null || stat -c%s "$db" 2>/dev/null)
if [ "$size" -eq 0 ]; then
echo "Error: $db is empty"
exit 1
fi
echo "✓ $db created successfully (${size} bytes)"
done

- name: Cache Chopsticks DBs
uses: actions/cache/save@v4
with:
path: |
/tmp/pah.db
/tmp/kah.db
key: chopsticks-db-${{ github.run_id }}

update:
needs: setup-chopsticks-cache
runs-on: ubuntu-latest
timeout-minutes: 240
strategy:
Expand All @@ -26,8 +106,67 @@ jobs:
node-version: 22.x
cache: 'yarn'
- run: yarn --immutable
- run: yarn update-known-good
- run: yarn test:${{ matrix.network }} -u

- name: Install Chopsticks
run: npm install -g @acala-network/chopsticks@latest

- name: Restore Chopsticks DBs
uses: actions/cache/restore@v4
with:
path: |
/tmp/pah.db
/tmp/kah.db
key: chopsticks-db-${{ github.run_id }}
fail-on-cache-miss: true

- name: Start Chopsticks
run: |
if [ "${{ matrix.network }}" = "polkadot" ]; then
chopsticks \
--endpoint=wss://sys.ibp.network/asset-hub-polkadot \
--db=/tmp/pah.db \
--port=8001 > /tmp/chopsticks.log 2>&1 &
echo $! > /tmp/chopsticks.pid
PORT=8001
ENDPOINT_VAR="ASSETHUBPOLKADOT_ENDPOINT"
else
chopsticks \
--endpoint=wss://sys.ibp.network/asset-hub-kusama \
--db=/tmp/kah.db \
--port=8002 > /tmp/chopsticks.log 2>&1 &
echo $! > /tmp/chopsticks.pid
PORT=8002
ENDPOINT_VAR="ASSETHUBKUSAMA_ENDPOINT"
fi

# Wait for server to be ready
timeout=120
elapsed=0
while [ $elapsed -lt $timeout ]; do
if nc -z localhost $PORT 2>/dev/null; then
echo "Chopsticks server ready on port $PORT"
break
fi
sleep 2
elapsed=$((elapsed + 2))
done

if [ $elapsed -ge $timeout ]; then
echo "Timeout waiting for chopsticks"
cat /tmp/chopsticks.log
exit 1
fi

# Export endpoint for tests
echo "${ENDPOINT_VAR}=ws://localhost:${PORT}" >> $GITHUB_ENV
- name: Run Tests
run: yarn test:${{ matrix.network }} -u
- name: Cleanup
if: always()
run: |
if [ -f /tmp/chopsticks.pid ]; then
kill $(cat /tmp/chopsticks.pid) || true
fi
- name: Commit and Create PR
uses: actions/github-script@v6
with:
Expand Down
20 changes: 10 additions & 10 deletions KNOWN_GOOD_BLOCK_NUMBERS_KUSAMA.env
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
ASSETHUBKUSAMA_BLOCK_NUMBER=12792874
BASILISK_BLOCK_NUMBER=12909953
BRIDGEHUBKUSAMA_BLOCK_NUMBER=7419039
CORETIMEKUSAMA_BLOCK_NUMBER=4353209
ENCOINTERKUSAMA_BLOCK_NUMBER=12255934
KARURA_BLOCK_NUMBER=10794731
KUSAMA_BLOCK_NUMBER=31925684
MOONRIVER_BLOCK_NUMBER=14821033
PEOPLEKUSAMA_BLOCK_NUMBER=7485670
SHIDEN_BLOCK_NUMBER=13432313
ASSETHUBKUSAMA_BLOCK_NUMBER=12903234
BASILISK_BLOCK_NUMBER=13028022
BRIDGEHUBKUSAMA_BLOCK_NUMBER=7483348
CORETIMEKUSAMA_BLOCK_NUMBER=4417124
ENCOINTERKUSAMA_BLOCK_NUMBER=12374016
KARURA_BLOCK_NUMBER=10856850
KUSAMA_BLOCK_NUMBER=32055132
MOONRIVER_BLOCK_NUMBER=14942860
PEOPLEKUSAMA_BLOCK_NUMBER=7613631
SHIDEN_BLOCK_NUMBER=13550308
20 changes: 10 additions & 10 deletions KNOWN_GOOD_BLOCK_NUMBERS_POLKADOT.env
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
ACALA_BLOCK_NUMBER=10230485
ASSETHUBPOLKADOT_BLOCK_NUMBER=11322985
ASTAR_BLOCK_NUMBER=11983100
BRIDGEHUBPOLKADOT_BLOCK_NUMBER=6860782
COLLECTIVESPOLKADOT_BLOCK_NUMBER=8059510
CORETIMEPOLKADOT_BLOCK_NUMBER=3452814
HYDRATION_BLOCK_NUMBER=11036597
MOONBEAM_BLOCK_NUMBER=14171137
PEOPLEPOLKADOT_BLOCK_NUMBER=3792580
POLKADOT_BLOCK_NUMBER=29609476
ACALA_BLOCK_NUMBER=10393601
ASSETHUBPOLKADOT_BLOCK_NUMBER=11520919
ASTAR_BLOCK_NUMBER=12098616
BRIDGEHUBPOLKADOT_BLOCK_NUMBER=6925195
COLLECTIVESPOLKADOT_BLOCK_NUMBER=8124894
CORETIMEPOLKADOT_BLOCK_NUMBER=3516994
HYDRATION_BLOCK_NUMBER=11165203
MOONBEAM_BLOCK_NUMBER=14287804
PEOPLEPOLKADOT_BLOCK_NUMBER=3857569
POLKADOT_BLOCK_NUMBER=29740698
Loading
Loading