Skip to content

Commit 8cf2351

Browse files
committed
integration tests: update CI to include regtest env setup
1 parent 33d6f8d commit 8cf2351

2 files changed

Lines changed: 79 additions & 3 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Setup regtest executables
2+
description: Download and expose Liquid regtest executables for CI
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Download regtest executables
8+
shell: bash
9+
run: |
10+
set -euo pipefail
11+
12+
BIN_DIR="${RUNNER_TEMP}/regtest-bin"
13+
mkdir -p "${BIN_DIR}"
14+
cd "${BIN_DIR}"
15+
16+
ELECTRS_FILENAME="electrs_linux_esplora_027e38d3ebc2f85b28ae76f8f3448438ee4fc7b1_liquid.zip"
17+
ELECTRS_SHA256="a63a314c16bc6642fc060bbc19bd1d54ebf86b42188ff2a11c705177c1eb22f7"
18+
if [ ! -x "${BIN_DIR}/electrs" ]; then
19+
curl -Ls "https://github.com/RCasatta/electrsd/releases/download/electrs_releases/${ELECTRS_FILENAME}" -o "${ELECTRS_FILENAME}"
20+
echo "${ELECTRS_SHA256} ${ELECTRS_FILENAME}" | sha256sum -c -
21+
unzip -qo "${ELECTRS_FILENAME}"
22+
chmod +x "${BIN_DIR}/electrs"
23+
fi
24+
25+
ELEMENTSD_VERSION="23.3.1"
26+
ELEMENTSD_FILENAME="elements-${ELEMENTSD_VERSION}-x86_64-linux-gnu.tar.gz"
27+
ELEMENTSD_SHA256="864e3a8240137c4e948ecae7c526ccb363771351ea68737a14c682025d5fedaa"
28+
if [ ! -x "${BIN_DIR}/elements-${ELEMENTSD_VERSION}/bin/elementsd" ]; then
29+
curl -Ls "https://github.com/ElementsProject/elements/releases/download/elements-${ELEMENTSD_VERSION}/${ELEMENTSD_FILENAME}" -o "${ELEMENTSD_FILENAME}"
30+
echo "${ELEMENTSD_SHA256} ${ELEMENTSD_FILENAME}" | sha256sum -c -
31+
tar -xzf "${ELEMENTSD_FILENAME}"
32+
chmod +x "${BIN_DIR}/elements-${ELEMENTSD_VERSION}/bin/elementsd"
33+
fi
34+
35+
echo "${BIN_DIR}" >> "${GITHUB_PATH}"
36+
echo "${BIN_DIR}/elements-${ELEMENTSD_VERSION}/bin" >> "${GITHUB_PATH}"
37+
echo "ELECTRS_LIQUID_EXEC=${BIN_DIR}/electrs" >> "${GITHUB_ENV}"
38+
echo "ELEMENTSD_EXEC=${BIN_DIR}/elements-${ELEMENTSD_VERSION}/bin/elementsd" >> "${GITHUB_ENV}"

.github/workflows/tests.yml

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ permissions:
2121

2222
jobs:
2323
test:
24-
name: Build and test (matrix)
24+
name: Build and test (matrix, non-regtest)
2525
runs-on: ubuntu-latest
2626
services:
2727
postgres:
@@ -88,8 +88,46 @@ jobs:
8888
cd crates/indexer
8989
SKIP_DOCKER=true ./scripts/init_db.sh
9090
91-
- name: Run tests
92-
run: cargo test --workspace --all-features --no-fail-fast --verbose
91+
- name: Run non-regtest workspace tests
92+
run: cargo test --workspace --all-features --exclude lending-contracts --no-fail-fast --verbose
93+
94+
- name: Run lending-contracts library tests
95+
run: cargo test -p lending-contracts --lib --all-features --verbose
9396

9497
- name: Check that queries are fresh
9598
run: cargo sqlx prepare --workspace --check -- --all-targets
99+
100+
contracts-regtest:
101+
name: Contracts regtest tests
102+
runs-on: ubuntu-latest
103+
104+
steps:
105+
- name: Checkout
106+
uses: actions/checkout@v4
107+
108+
- name: Setup Rust (stable)
109+
uses: actions-rust-lang/setup-rust-toolchain@v1
110+
with:
111+
toolchain: stable
112+
113+
- name: Cache cargo
114+
uses: Swatinem/rust-cache@v2
115+
with:
116+
cache-on-failure: true
117+
118+
- name: Setup regtest executables
119+
uses: ./.github/actions/setup-regtest-execs
120+
121+
- name: Test lending-contracts regtest integration tests
122+
run: cargo test -p lending-contracts --tests --all-features --no-fail-fast --verbose -- --test-threads=1
123+
124+
- name: Assert no leaked regtest nodes after contracts tests
125+
if: always()
126+
run: |
127+
set -euo pipefail
128+
leaks="$(ps -eo pid=,comm=,args= | awk '$2=="elementsd" || $2=="electrs" {print}')"
129+
if [ -n "$leaks" ]; then
130+
echo "Leaked regtest node processes after contracts regtest tests:"
131+
echo "$leaks"
132+
exit 1
133+
fi

0 commit comments

Comments
 (0)