Skip to content

Commit

Permalink
Add GitHub Actions for Bitcoin, c-lightning, and LND setup and Integr…
Browse files Browse the repository at this point in the history
…ation Tests

- Added a new workflow for running integration tests in .github/workflows/integration_tests.yaml.
- Implemented new GitHub Actions for setting up Bitcoin, c-lightning, and LND environments in .github/actions/setup-bitcoin/action.yaml, .github/actions/setup-clightning/action.yaml, and .github/actions/setup-lnd/action.yaml respectively.
- Updated .gitignore.
- Currently continue-on-error=true until all tests are fixed.
  • Loading branch information
lndev committed Jul 11, 2023
1 parent 70d6afc commit 7208ae3
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/actions/setup-bitcoin/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'Setup Bitcoin Core'
description: 'Download and install Bitcoin Core'
inputs:
bitcoin-version:
description: 'Version of Bitcoin Core'
required: true
runs:
using: 'composite'
steps:
- name: Setup dependencies
run: |
sudo apt-get update
sudo apt-get install -y axel
shell: bash

- name: Download Bitcoin Core
run: |
mkdir -p ~/bitcoin-core-${{ inputs.bitcoin-version }}
cd ~/bitcoin-core-${{ inputs.bitcoin-version }}
axel https://bitcoin.org/bin/bitcoin-core-${{ inputs.bitcoin-version }}/bitcoin-${{ inputs.bitcoin-version }}-x86_64-linux-gnu.tar.gz
tar -xzf bitcoin-${{ inputs.bitcoin-version }}-x86_64-linux-gnu.tar.gz
rm bitcoin-${{ inputs.bitcoin-version }}-x86_64-linux-gnu.tar.gz
shell: bash
51 changes: 51 additions & 0 deletions .github/actions/setup-clightning/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'Setup Core Lightning'
description: 'Set up Core Lightning on the runner'

inputs:
checkout-version:
description: 'v23.05.1'
required: true
default: 'v23.05.1'

runs:
using: 'composite'
steps:
- name: Setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Install dependencies
run: |
sudo apt-get install -y autoconf automake build-essential git libtool libgmp-dev libsqlite3-dev python3 python3-pip net-tools zlib1g-dev libsodium-dev gettext valgrind libpq-dev shellcheck cppcheck libsecp256k1-dev jq
sudo apt-get remove -y protobuf-compiler
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.12.0/protoc-3.12.0-linux-x86_64.zip
sudo unzip -o protoc-3.12.0-linux-x86_64.zip -d /usr/local bin/protoc
sudo unzip -o protoc-3.12.0-linux-x86_64.zip -d /usr/local 'include/*'
rm -f protoc-3.12.0-linux-x86_64.zip
sudo chmod 755 /usr/local/bin/protoc
shell: bash

- name: Install Python dependencies
run: |
pip3 install --upgrade pip
pip3 install poetry mako
pip install grpcio-tools
shell: bash

- name: Checkout and build lightning
run: |
git clone https://github.com/ElementsProject/lightning.git lightning_git
cd lightning_git
git checkout ${{ inputs.checkout-version }}
./configure --enable-developer --enable-rust
poetry install
poetry run make -j `nproc`
shell: bash
49 changes: 49 additions & 0 deletions .github/actions/setup-lnd/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: 'Setup LND'
description: 'Set up LND for both LSP and Client on the runner'

inputs:
lsp-ref:
description: 'The Git reference for the LSP version of LND'
required: true
default: 'breez-node-v0.16.2-beta'

client-ref:
description: 'The Git reference for the Client version of LND'
required: true
default: 'v0.16.2-breez'

runs:
using: 'composite'
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16

- name: Checkout LND for LSP
uses: actions/checkout@v2
with:
repository: breez/lnd
ref: ${{ inputs.lsp-ref }}
path: lnd_lsp

- name: Build LND for LSP
run: |
cd lnd_lsp
env GOPATH=~/go_lnd_lsp make install
ls ~/go_lnd_lsp/bin/lnd
shell: bash

- name: Checkout LND for Client
uses: actions/checkout@v2
with:
repository: breez/lnd
ref: ${{ inputs.client-ref }}
path: lnd_client

- name: Build LND for Client
run: |
cd lnd_client
env GOPATH=~/go_lnd_client make install
ls ~/go_lnd_client/bin/lnd
shell: bash
101 changes: 101 additions & 0 deletions .github/workflows/integration_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: integration tests
on: [push]
jobs:
setup:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2

############################
# Build and Cache Bitcoind #
############################

- name: Cache Bitcoin Core
id: cache-bitcoin
uses: actions/cache@v2
with:
path: ~/bitcoin-core-22.0
key: bitcoin-core-22.0

- name: Set up Bitcoin Core
if: steps.cache-bitcoin.outputs.cache-hit != 'true'
uses: ./.github/actions/setup-bitcoin
with:
bitcoin-version: '22.0'

- name: Copy Bitcoin binaries to bin folder
run: |
sudo cp ~/bitcoin-core-22.0/bitcoin-22.0/bin/bitcoind /usr/bin/
sudo cp ~/bitcoin-core-22.0/bitcoin-22.0/bin/bitcoin-cli /usr/bin/
####################
# Build lightningd #
####################

- name: Set up Core Lightning
uses: ./.github/actions/setup-clightning
with:
checkout-version: 'v23.05.1'

# ######################################
# # Build and Cache LND Client and LSP #
# ######################################

- name: Cache LND
id: cache-lnd
uses: actions/cache@v2
with:
path: |
~/go_lnd_lsp/bin/lnd
~/go_lnd_client/bin/lnd
key: go_lnd_lsp

- name: Setup LND
if: steps.cache-lnd.outputs.cache-hit != 'true'
uses: ./.github/actions/setup-lnd
with:
lsp-ref: 'breez-node-v0.16.2-beta'
client-ref: 'v0.16.2-breez'

##############
# Build LSPD #
##############

- name: Build LSPD
run: |
go get github.com/breez/lspd
go get github.com/breez/lspd/cln_plugin
go build .
go build -o lspd_plugin ./cln_plugin/cmd
shell: bash

- name: Test LSPD
run: |
go get github.com/breez/lspd/itest
go test -timeout 20m -v \
./itest \
--bitcoindexec /usr/bin/bitcoind \
--bitcoincliexec /usr/bin/bitcoin-cli \
--lightningdexec ${GITHUB_WORKSPACE}/lightning_git/lightningd/lightningd \
--lndexec ~/go_lnd_lsp/bin/lnd \
--lndmobileexec ~/go_lnd_client/bin/lnd \
--clnpluginexec ${GITHUB_WORKSPACE}/lspd_plugin \
--lspdexec ${GITHUB_WORKSPACE}/lspd \
--lspdmigrationsdir ${GITHUB_WORKSPACE}/postgresql/migrations \
--testdir ~/test_state \
--preservestate
shell: bash
# remove the following line once all tests pass
continue-on-error: true

- name: Tar state
run: |
find ~/test_state -type f -o -type d | tar -czf ~/test_state.tar.gz -T -
shell: bash

- name: Upload test_state as artifact
uses: actions/upload-artifact@v2
with:
name: test_state_artifact
path: ~/test_state.tar.gz
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.vscode
go.sum
lspd
lspd_plugin

0 comments on commit 7208ae3

Please sign in to comment.