Skip to content

wip: ci

wip: ci #8

name: Run Solana Unit Tests
on:
push:
branches:
- solana
workflow_dispatch:
jobs:
networks-solana:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository 📝
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "yarn"
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Build Project
run: yarn build
- name: Set Up Starship Infrastructure
id: starship-infra
uses: hyperweb-io/starship-action@0.5.9
with:
config: networks/solana/starship/configs/config.yaml
- name: Port-forward and run Solana unit tests
run: |
set -euxo pipefail
# Discover namespace
NS="${{ steps.starship-infra.outputs.namespace }}"
if [ -z "${NS}" ]; then
NS=$(kubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}{" "}{.metadata.name}{"\n"}{end}' | awk '/solana-genesis/{print $1; exit}' || true)
fi
echo "Using namespace: ${NS:-<unknown>}"
echo "Checking pods status..."
kubectl get pods -A -o wide || true
if [ -n "${NS}" ]; then
kubectl get pods -n "$NS" -o wide || true
(kubectl wait --for=condition=Ready pod -l app=solana-genesis -n "$NS" --timeout=300s || \
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=solana-genesis -n "$NS" --timeout=300s) || true
fi
# Start port-forward and keep this step alive while tests run
if [ -n "${NS}" ]; then
NS="$NS" bash networks/solana/starship/port-forward.sh &
PF_SUPERVISOR_PID=$!
# Clean up on exit
trap 'echo "Stopping port-forward"; kill -9 ${PF_SUPERVISOR_PID} >/dev/null 2>&1 || true; pkill -f "kubectl -n ${NS} port-forward" || true' EXIT
else
echo "Could not determine namespace for port-forward" >&2
fi
echo "Waiting for RPC health on 127.0.0.1:8899 ..."
ok=0
for i in $(seq 1 60); do
if curl -fsS http://127.0.0.1:8899/health | grep -qi ok; then
ok=1; break
fi
sleep 5
done
if [ "$ok" -ne 1 ]; then
echo "RPC not healthy; dumping diagnostics" >&2
kubectl get pods -A -o wide || true
if [ -n "${NS}" ]; then kubectl describe pods -n "$NS" || true; fi
exit 1
fi
echo "Waiting for WS port on 127.0.0.1:8900 ..."
ws_ok=0
for i in $(seq 1 60); do
if command -v nc >/dev/null 2>&1; then
if nc -z 127.0.0.1 8900 >/dev/null 2>&1; then ws_ok=1; break; fi
else
if (exec 3<>/dev/tcp/127.0.0.1/8900) 2>/dev/null; then exec 3>&- 3<&-; ws_ok=1; break; fi
fi
sleep 2
done
if [ "$ws_ok" -ne 1 ]; then
echo "WebSocket port 8900 not reachable; dumping diagnostics" >&2
if command -v ss >/dev/null 2>&1; then ss -ltnp || true; fi
if command -v lsof >/dev/null 2>&1; then lsof -iTCP -sTCP:LISTEN || true; fi
kubectl get svc -A -o wide || true
if [ -n "${NS}" ]; then
kubectl get pods -n "$NS" -o wide || true
(kubectl describe pods -l app=solana-genesis -n "$NS" || \
kubectl describe pods -l app.kubernetes.io/name=solana-genesis -n "$NS") || true
fi
exit 1
fi
cd ./networks/solana
yarn test --runInBand