-
Notifications
You must be signed in to change notification settings - Fork 1
187 lines (164 loc) · 6.64 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: CI
# Cancel duplicate jobs
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
workflow_call:
inputs:
cln-version:
required: true
type: string
pyln-version:
required: true
type: string
tagged-release:
required: true
type: boolean
jobs:
build:
name: Test CLN=${{ inputs.cln-version }}, OS=${{ matrix.os }}, PY=${{ matrix.python-version }}, BCD=${{ matrix.bitcoind-version }}, EXP=${{ matrix.experimental }}, DEP=${{ matrix.deprecated }}
strategy:
fail-fast: false
matrix:
bitcoind-version: ["28.0"]
experimental: [1]
deprecated: [0]
python-version: ["3.8", "3.11"]
os: ["ubuntu-24.04"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create cache paths
run: |
sudo mkdir /usr/local/libexec
sudo mkdir /usr/local/libexec/c-lightning
sudo mkdir /usr/local/libexec/c-lightning/plugins
sudo chown -R $USER /usr/local/libexec
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Extract exact python and os version
id: exact_versions
run: |
PYTHON_VERSION=$(python --version 2>&1 | grep -oP '(?<=Python )\d+\.\d+(\.\d+)?')
echo "Python version: $PYTHON_VERSION"
echo "python_version=$PYTHON_VERSION" >> "$GITHUB_OUTPUT"
OS_VERSION=$(lsb_release -rs)
echo "OS version: $OS_VERSION"
echo "os_version=$OS_VERSION" >> $GITHUB_OUTPUT
- name: Cache CLN
id: cache-cln
uses: actions/cache@v4
with:
path: |
/usr/local/bin/lightning*
/usr/local/libexec/c-lightning
key: cache-cln-${{ inputs.cln-version }}-${{ steps.exact_versions.outputs.os_version }}
- name: Cache bitcoind
id: cache-bitcoind
uses: actions/cache@v4
with:
path: /usr/local/bin/bitcoin*
key: cache-bitcoind-${{ matrix.bitcoind-version }}-${{ steps.exact_versions.outputs.os_version }}
- name: Cache python dependencies
id: cache-python
uses: actions/cache@v4
with:
path: venv
key: cache-python-${{ steps.exact_versions.outputs.python_version }}-${{ steps.exact_versions.outputs.os_version }}-${{ inputs.pyln-version }}-${{ hashFiles('tests/requirements.txt') }}
- name: Download Bitcoin ${{ matrix.bitcoind-version }} & install binaries
if: ${{ steps.cache-bitcoind.outputs.cache-hit != 'true' }}
run: |
export BITCOIND_VERSION=${{ matrix.bitcoind-version }}
if [[ "${{ matrix.os }}" =~ "ubuntu" ]]; then
export TARGET_ARCH="x86_64-linux-gnu"
fi
if [[ "${{ matrix.os }}" =~ "macos" ]]; then
export TARGET_ARCH="x86_64-apple-darwin"
fi
wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIND_VERSION}/bitcoin-${BITCOIND_VERSION}-${TARGET_ARCH}.tar.gz
tar -xzf bitcoin-${BITCOIND_VERSION}-${TARGET_ARCH}.tar.gz
sudo mv bitcoin-${BITCOIND_VERSION}/bin/* /usr/local/bin
rm -rf bitcoin-${BITCOIND_VERSION}-${TARGET_ARCH}.tar.gz bitcoin-${BITCOIND_VERSION}
- name: Download Core Lightning ${{ inputs.cln-version }} & install binaries
if: ${{ contains(matrix.os, 'ubuntu') && steps.cache-cln.outputs.cache-hit != 'true' }}
run: |
url=$(curl -s https://api.github.com/repos/ElementsProject/lightning/releases/tags/${{ inputs.cln-version }} \
| jq '.assets[] | select(.name | contains("24.04")) | .browser_download_url' \
| tr -d '\"')
wget $url
sudo tar -xvf ${url##*/} -C /usr/local --strip-components=2
echo "CLN_VERSION=$(lightningd --version)" >> "$GITHUB_OUTPUT"
- name: Set up Rust
if: ${{ inputs.tagged-release == false}}
uses: dtolnay/rust-toolchain@stable
- name: Set up protoc
if: ${{ inputs.tagged-release == false}} || contains(matrix.os, 'macos') && ${{ steps.cache-cln.outputs.cache-hit != 'true' }}
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Core Lightning ${{ inputs.cln-version }}
if: ${{ contains(matrix.os, 'macos') && steps.cache-cln.outputs.cache-hit != 'true' }}
uses: actions/checkout@v4
with:
repository: 'ElementsProject/lightning'
path: 'lightning'
ref: ${{ inputs.cln-version }}
submodules: 'recursive'
- name: Install System dependencies
run: |
if [[ "${{ matrix.os }}" =~ "macos" ]]; then
brew install autoconf automake libtool gnu-sed gettext libsodium sqlite
fi
- name: Install Python dependencies
if: ${{ steps.cache-python.outputs.cache-hit != 'true' }}
run: |
python -m venv venv
source venv/bin/activate
python -m pip install -U pip poetry wheel
pip3 install "pyln-proto<=${{ inputs.pyln-version }}" "pyln-client<=${{ inputs.pyln-version }}" "pyln-testing<=${{ inputs.pyln-version }}"
pip3 install pytest-xdist pytest-test-groups pytest-timeout
if [ -f "tests/requirements.txt" ]; then
pip3 install -r tests/requirements.txt
fi
- name: Compile Core Lightning ${{ inputs.cln-version }} & install binaries
if: ${{ contains(matrix.os, 'macos') && steps.cache-cln.outputs.cache-hit != 'true' }}
run: |
export EXPERIMENTAL_FEATURES=${{ matrix.experimental }}
export COMPAT=${{ matrix.deprecated }}
export VALGRIND=0
source venv/bin/activate
cd lightning
poetry lock
poetry install
./configure --disable-valgrind
poetry run make
sudo make install
- name: Get plugin binary
run: |
source venv/bin/activate
if ${{ inputs.tagged-release }}; then
cd tests
./setup.sh
cd ..
else
if [ -d "proto" ]; then
python -m grpc_tools.protoc --proto_path="proto" --python_out="tests" --grpc_python_out="tests" proto/*.proto
fi
cargo build
fi
- name: Run tests
run: |
export CLN_PATH=${{ github.workspace }}/lightning
export COMPAT=${{ matrix.deprecated }}
export EXPERIMENTAL_FEATURES=${{ matrix.experimental }}
export SLOW_MACHINE=1
export TEST_DEBUG=1
export TRAVIS=1
export VALGRIND=0
export PYTEST_TIMEOUT=600
source venv/bin/activate
pytest -n=5 tests/test_*.py