Plugin registry github and Smart contract management #50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: E2E Tests | |
permissions: | |
contents: read | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
paths-ignore: | |
- '**/*.md' | |
- 'docs/**' | |
jobs: | |
build: | |
name: Build Application and UI | |
runs-on: ubuntu-latest | |
services: | |
mailhog: | |
image: mailhog/mailhog | |
ports: | |
- 1025:1025 | |
- 8025:8025 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23.4' | |
cache: true | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v2 | |
- name: Build UI | |
run: | | |
cd web | |
bun install | |
export API_URL="/api" | |
bun run build | |
- name: Install dependencies | |
run: | | |
go mod download | |
sudo apt-get update | |
sudo apt-get install -y build-essential | |
- name: Cache Go modules | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Cache built binary | |
id: cache-binary | |
uses: actions/cache@v4 | |
with: | |
path: chainlaunch | |
key: ${{ runner.os }}-chainlaunch-bin-${{ hashFiles('**/*.go', '**/go.sum', '**/go.mod') }} | |
- name: Build the application | |
if: steps.cache-binary.outputs.cache-hit != 'true' | |
run: | | |
go build -v -o chainlaunch ./main.go | |
chmod +x chainlaunch | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifacts | |
path: | | |
chainlaunch | |
web/dist | |
testnet-besu: | |
name: Create Besu Testnet | |
runs-on: ubuntu-latest | |
needs: build | |
env: | |
CHAINLAUNCH_USER: admin | |
CHAINLAUNCH_PASSWORD: admin123 | |
CHAINLAUNCH_DATA: ${{ github.workspace }}/test-data | |
CHAINLAUNCH_API_URL: http://localhost:8100/api/v1 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
- name: Start the application and verify API is available | |
run: | | |
echo "CHAINLAUNCH_DATA: $CHAINLAUNCH_DATA" | |
chmod +x chainlaunch | |
./chainlaunch serve --data=$CHAINLAUNCH_DATA --port=8100 --db data.db & | |
# Wait for port 8100 to be available (60 seconds timeout) | |
timeout=60 | |
while ! curl -s http://localhost:8100 > /dev/null; do | |
if [ $timeout -le 0 ]; then | |
echo "Timeout waiting for API to become available" | |
exit 1 | |
fi | |
echo "Waiting for API to become available... ($timeout seconds remaining)" | |
sleep 1 | |
timeout=$((timeout - 1)) | |
done | |
- name: Create and verify Besu testnet | |
run: | | |
# Create a new Besu testnet | |
./chainlaunch testnet besu --name mynet --nodes 4 --prefix besu-test --mode=docker | |
# Wait for port 8545 to be available (60 seconds timeout) | |
timeout=60 | |
while ! curl -s http://localhost:8545 > /dev/null; do | |
if [ $timeout -le 0 ]; then | |
echo "Timeout waiting for Besu node to become available" | |
exit 1 | |
fi | |
echo "Waiting for Besu node to become available... ($timeout seconds remaining)" | |
sleep 1 | |
timeout=$((timeout - 1)) | |
done | |
# Wait for nodes to start producing blocks (up to 90 seconds) | |
for i in {1..90}; do | |
# Make the curl request and capture both stdout and stderr | |
if ! resp=$(curl -s -f -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' http://localhost:8545 2>&1); then | |
curl_status=$? | |
case $curl_status in | |
56) | |
echo "Connection refused to node (status: $curl_status). Retrying..." | |
;; | |
7) | |
echo "Failed to connect to host (status: $curl_status). Retrying..." | |
;; | |
28) | |
echo "Operation timed out (status: $curl_status). Retrying..." | |
;; | |
22) | |
echo "HTTP response code indicated error (status: $curl_status). Retrying..." | |
;; | |
*) | |
echo "Curl failed with status $curl_status: $resp. Retrying..." | |
;; | |
esac | |
sleep 1 | |
continue | |
fi | |
# Check for empty response | |
if [ -z "$resp" ]; then | |
echo "Empty response received from node" | |
sleep 1 | |
continue | |
fi | |
# Parse the response with error handling | |
if ! block_hex=$(echo "$resp" | jq -r .result 2>/dev/null); then | |
echo "Failed to parse JSON response: $resp" | |
sleep 1 | |
continue | |
fi | |
# Check for JSON-RPC errors | |
if error=$(echo "$resp" | jq -r .error 2>/dev/null) && [ "$error" != "null" ]; then | |
echo "JSON-RPC error received: $error" | |
sleep 1 | |
continue | |
fi | |
if [ "$block_hex" = "null" ] || [ -z "$block_hex" ]; then | |
echo "Invalid block number received" | |
sleep 1 | |
continue | |
fi | |
# Validate hex format | |
if [[ ! "$block_hex" =~ ^0x[0-9a-fA-F]+$ ]]; then | |
echo "Invalid hex format received: $block_hex" | |
sleep 1 | |
continue | |
fi | |
# Convert hex to decimal with error handling | |
if ! block_num=$((16#${block_hex:2})) 2>/dev/null; then | |
echo "Failed to convert block number from hex: $block_hex" | |
sleep 1 | |
continue | |
fi | |
echo "Current block: $block_num" | |
if [ "$block_num" -ge 5 ]; then | |
echo "Besu node has reached block >= 5" | |
exit 0 | |
fi | |
sleep 1 | |
done | |
echo "Timeout waiting for blocks to be produced" | |
exit 1 | |
- name: Show Besu containers and logs (always) | |
if: always() | |
run: | | |
echo "==== besu list nodes ====" | |
./chainlaunch besu list | |
echo "==== docker ps ====" | |
docker ps -a || true | |
echo "==== docker logs (besu containers) ====" | |
for cid in $(docker ps -a --filter "name=besu-test" --format "{{.ID}}" ); do | |
echo "--- Logs for container $cid ---" | |
docker logs $cid || true | |
done | |
testnet-fabric: | |
name: Create Fabric Testnet | |
runs-on: ubuntu-latest | |
needs: build | |
env: | |
CHAINLAUNCH_USER: admin | |
CHAINLAUNCH_PASSWORD: admin123 | |
CHAINLAUNCH_DATA: ${{ github.workspace }}/test-data | |
CHAINLAUNCH_API_URL: http://localhost:8100/api/v1 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
- name: Start the application and verify API is available | |
run: | | |
echo "CHAINLAUNCH_DATA: $CHAINLAUNCH_DATA" | |
chmod +x chainlaunch | |
./chainlaunch serve --data=$CHAINLAUNCH_DATA --port=8100 --db data.db & | |
# Wait for port 8100 to be available (60 seconds timeout) | |
timeout=60 | |
while ! curl -s http://localhost:8100 > /dev/null; do | |
if [ $timeout -le 0 ]; then | |
echo "Timeout waiting for API to become available" | |
exit 1 | |
fi | |
echo "Waiting for API to become available... ($timeout seconds remaining)" | |
sleep 1 | |
timeout=$((timeout - 1)) | |
done | |
- name: Create Fabric testnet | |
run: | | |
./chainlaunch testnet fabric --name mynet --org "Org1MSP123" --peerOrgs "Org1MSP123" --ordererOrgs "OrdererOrg123" --channels mychannel --peerCounts "Org1MSP123=2" --ordererCounts "OrdererOrg123=3" --mode=docker | |
- name: Test get a block from the channel | |
run: | | |
export NETWORK_ID=$(./chainlaunch networks fabric list --output=json | jq -r '.networks[0].id') | |
response=$(curl -s -w "%{http_code}" -X 'GET' \ | |
"http://localhost:8100/api/v1/networks/fabric/$NETWORK_ID/blocks/0" \ | |
-H 'accept: application/json' \ | |
-u "$CHAINLAUNCH_USER:$CHAINLAUNCH_PASSWORD") | |
status_code=${response: -3} | |
response_body=${response:0:-3} | |
if [ "$status_code" -ne 200 ]; then | |
echo "Error: Expected status code 200, got $status_code" | |
echo "Response body: $response_body" | |
exit 1 | |
fi | |
echo "Got a block from the channel with status code 200" | |
- name: Show Fabric containers and logs (debug) | |
if: always() | |
run: | | |
echo "==== list fabric networks ====" | |
./chainlaunch networks fabric list --output=json | |
echo "==== list fabric peers ====" | |
./chainlaunch fabric peer list --output=json | |
echo "==== list fabric orderers ====" | |
./chainlaunch fabric orderer list --output=json | |
echo "==== docker ps ====" | |
docker ps -a || true | |
echo "==== docker logs (fabric containers) ====" | |
for cid in $(docker ps -a --filter "name=fabric" --format "{{.ID}}" ); do | |
echo "--- Logs for container $cid ---" | |
docker logs $cid || true | |
done | |
api-e2e: | |
name: Run API E2E Tests | |
runs-on: ubuntu-latest | |
needs: [build] | |
services: | |
mailhog: | |
image: mailhog/mailhog | |
ports: | |
- 1025:1025 | |
- 8025:8025 | |
env: | |
API_BASE_URL: http://localhost:8100/api/v1 | |
CHAINLAUNCH_USER: admin | |
CHAINLAUNCH_PASSWORD: admin123 | |
API_USERNAME: admin | |
API_PASSWORD: admin123 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
- name: Start the application and run API tests | |
run: | | |
export CHAINLAUNCH_USER=admin | |
export CHAINLAUNCH_PASSWORD=admin123 | |
export CHAINLAUNCH_DATA=${{ github.workspace }}/test-data | |
echo "CHAINLAUNCH_DATA: $CHAINLAUNCH_DATA" | |
chmod +x chainlaunch | |
./chainlaunch serve --data=$CHAINLAUNCH_DATA --port=8100 --db data.db & | |
# Wait for port 8100 to be available (60 seconds timeout) | |
timeout=60 | |
while ! curl -s http://localhost:8100 > /dev/null; do | |
if [ $timeout -le 0 ]; then | |
echo "Timeout waiting for API to become available" | |
exit 1 | |
fi | |
echo "Waiting for API to become available... ($timeout seconds remaining)" | |
sleep 1 | |
timeout=$((timeout - 1)) | |
done | |
- name: Upload API test results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: api-test-results | |
path: test-results.xml | |
ui-e2e: | |
name: Run UI E2E Tests | |
runs-on: ubuntu-latest | |
needs: build | |
services: | |
mailhog: | |
image: mailhog/mailhog | |
ports: | |
- 1025:1025 | |
- 8025:8025 | |
env: | |
CYPRESS_BASE_URL: http://localhost:8100 | |
CYPRESS_API_URL: http://localhost:8100/api/v1 | |
PLAYWRIGHT_USER: admin | |
PLAYWRIGHT_PASSWORD: admin123 | |
CHAINLAUNCH_USER: admin | |
CHAINLAUNCH_PASSWORD: admin123 | |
PLAYWRIGHT_BASE_URL: http://localhost:8100 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
- name: Cache Playwright Browsers | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/ms-playwright | |
key: playwright-browsers-${{ runner.os }}-${{ hashFiles('web/package.json', 'web/bun.lockb') }} | |
restore-keys: | | |
playwright-browsers-${{ runner.os }}- | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v2 | |
- name: Build UI | |
run: | | |
cd web | |
bun install | |
- name: Install Playwright Browsers | |
run: | | |
cd web | |
bunx playwright install --with-deps | |
- name: Start server and run UI tests | |
run: | | |
export CHAINLAUNCH_DATA=${{ github.workspace }}/test-data | |
chmod +x chainlaunch | |
./chainlaunch serve --data=$CHAINLAUNCH_DATA --port=8100 --db data.db & | |
# Wait for port 8100 to be available (60 seconds timeout) | |
timeout=60 | |
while ! curl -s http://localhost:8100 > /dev/null; do | |
if [ $timeout -le 0 ]; then | |
echo "Timeout waiting for API to become available" | |
exit 1 | |
fi | |
echo "Waiting for API to become available... ($timeout seconds remaining)" | |
sleep 1 | |
timeout=$((timeout - 1)) | |
done | |
cd web | |
bun run test:e2e | |
- name: Upload UI test results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ui-test-results | |
path: | | |
web/test-results |