@@ -13,18 +13,95 @@ jobs:
1313 - name : Checkout repository
1414 uses : actions/checkout@v4
1515
16- - name : Install dependencies
16+ - name : Create temporary directory for CLN data
17+ run : echo "CLN_DATA_DIR=$(mktemp -d)" >> $GITHUB_ENV
18+
19+ - name : Start bitcoind and electrs
20+ run : docker compose up -d bitcoin electrs
21+ env :
22+ CLN_DATA_DIR : ${{ env.CLN_DATA_DIR }}
23+
24+ - name : Wait for bitcoind to be healthy
25+ run : |
26+ for i in $(seq 1 30); do
27+ if docker compose exec bitcoin bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass getblockchaininfo > /dev/null 2>&1; then
28+ echo "bitcoind is ready"
29+ exit 0
30+ fi
31+ echo "Waiting for bitcoind... ($i/30)"
32+ sleep 2
33+ done
34+ echo "ERROR: bitcoind not ready"
35+ exit 1
36+
37+ - name : Wait for electrs to be ready
38+ run : |
39+ for i in $(seq 1 30); do
40+ if curl -s http://127.0.0.1:3002/blocks/tip/height 2>/dev/null | grep -q '[0-9]'; then
41+ echo "electrs is ready"
42+ exit 0
43+ fi
44+ echo "Waiting for electrs... ($i/30)"
45+ sleep 2
46+ done
47+ echo "ERROR: electrs not ready"
48+ exit 1
49+
50+ - name : Mine initial block for CLN
51+ # CLN refuses to start until bitcoind's initial block download is complete.
52+ # In regtest with 0 blocks, IBD stays true. Mining one block resolves this.
53+ run : |
54+ docker compose exec bitcoin bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass createwallet miner
55+ ADDR=$(docker compose exec bitcoin bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass -rpcwallet=miner getnewaddress)
56+ docker compose exec bitcoin bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass generatetoaddress 1 "$ADDR"
57+ docker compose exec bitcoin bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass unloadwallet miner
58+
59+ - name : Wait for electrs to index mined block
1760 run : |
18- sudo apt-get update -y
19- sudo apt-get install -y socat
61+ for i in $(seq 1 30); do
62+ HEIGHT=$(curl -s http://127.0.0.1:3002/blocks/tip/height 2>/dev/null)
63+ if [ "$HEIGHT" -ge 1 ] 2>/dev/null; then
64+ echo "electrs indexed to height $HEIGHT"
65+ exit 0
66+ fi
67+ echo "Waiting for electrs to index... ($i/30)"
68+ sleep 2
69+ done
70+ echo "ERROR: electrs did not index block"
71+ exit 1
2072
21- - name : Start bitcoind, electrs, and lightningd
22- run : docker compose -f docker-compose-cln.yml up -d
73+ - name : Start lightningd
74+ run : docker compose --profile cln up -d cln
75+ env :
76+ CLN_DATA_DIR : ${{ env.CLN_DATA_DIR }}
77+
78+ - name : Wait for CLN to be ready
79+ # CLN creates files as root with restrictive permissions, so we check
80+ # for the socket inside the container rather than on the host volume.
81+ run : |
82+ for i in $(seq 1 30); do
83+ if docker compose exec cln test -S /root/.lightning/regtest/lightning-rpc 2>/dev/null; then
84+ echo "CLN RPC socket found"
85+ break
86+ fi
87+ echo "Waiting for CLN RPC socket... ($i/30)"
88+ sleep 2
89+ done
90+ docker compose exec cln test -S /root/.lightning/regtest/lightning-rpc || {
91+ echo "ERROR: CLN RPC socket not found after 60 seconds"
92+ docker compose --profile cln logs cln
93+ exit 1
94+ }
2395
24- - name : Forward lightningd RPC socket
96+ - name : Set permissions for CLN data directory
2597 run : |
26- docker exec ldk-node-cln-1 sh -c "socat -d -d TCP-LISTEN:9937,fork,reuseaddr UNIX-CONNECT:/root/.lightning/regtest/lightning-rpc&"
27- socat -d -d UNIX-LISTEN:/tmp/lightning-rpc,reuseaddr,fork TCP:127.0.0.1:9937&
98+ sudo chown -R $(id -u):$(id -g) $CLN_DATA_DIR
99+ sudo chmod -R 755 $CLN_DATA_DIR
100+ env :
101+ CLN_DATA_DIR : ${{ env.CLN_DATA_DIR }}
28102
29103 - name : Run CLN integration tests
30- run : RUSTFLAGS="--cfg cln_test" cargo test --test integration_tests_cln
104+ run : CLN_SOCKET_PATH=$CLN_DATA_DIR/regtest/lightning-rpc
105+ RUSTFLAGS="--cfg cln_test" cargo test --test integration_tests_cln -- --show-output --test-threads=1
106+ env :
107+ CLN_DATA_DIR : ${{ env.CLN_DATA_DIR }}
0 commit comments