-
Notifications
You must be signed in to change notification settings - Fork 129
251 lines (223 loc) · 9.8 KB
/
main.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: Integration Tests (latest)
# Cancel duplicate jobs
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
push:
branches: [ master ]
pull_request:
jobs:
build-and-test:
name: Test CLN=${{ matrix.cln-version }}, PY=${{ matrix.python-version }}, BCD=${{ matrix.bitcoind-version }}, EXP=${{ matrix.experimental }}, DEP=${{ matrix.deprecated }}
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.11"]
bitcoind-version: ["27.1"]
cln-version: ["24.08.1", "24.05", "24.02.2"]
experimental: [1]
deprecated: [0]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Get changed files
id: get_changed_files
if: ${{ github.event_name == 'pull_request' }}
uses: tj-actions/changed-files@v44
with:
files: '**/*'
files_ignore: |
*.md
*.toml
*.yml
*.lock
Dockerfile
.gitignore
LICENSE
archived/**
- name: Set plugin_dirs
id: set_plugin_dirs
if: ${{ github.event_name == 'pull_request' }}
run: |
changed_files=$(echo "${{ steps.get_changed_files.outputs.all_changed_files }}" | tr ',' '\n')
plugin_dirs=""
for file in $changed_files; do
dir=$(dirname "$file" | cut -d'/' -f1)
if [[ "$dir" != "." && "${dir:0:1}" != "." && ! " ${plugin_dirs[@]} " =~ " ${dir} " ]]; then
plugin_dirs="${plugin_dirs} ${dir}"
fi
done
echo "plugin_dirs=${plugin_dirs}" >> "$GITHUB_OUTPUT"
if [[ -n "${{ steps.get_changed_files.outputs.all_changed_files }}" ]]; then
echo "run_ci=true" >> "$GITHUB_OUTPUT"
else
echo "run_ci=false" >> "$GITHUB_OUTPUT"
fi
- name: Set up Python ${{ matrix.python-version }}
if: ${{ github.event_name == 'push' || steps.set_plugin_dirs.outputs.run_ci == 'true' }}
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: Create cache paths
if: ${{ github.event_name == 'push' || steps.set_plugin_dirs.outputs.run_ci == 'true' }}
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: Restore bitcoind cache
id: cache-bitcoind
if: ${{ github.event_name == 'push' || steps.set_plugin_dirs.outputs.run_ci == 'true' }}
uses: actions/cache@v4
with:
path: /usr/local/bin/bitcoin*
key: cache-bitcoind-${{ matrix.bitcoind-version }}-${{ steps.exact_versions.outputs.os_version }}
- name: Download Bitcoin ${{ matrix.bitcoind-version }} & install binaries
if: ${{ steps.cache-bitcoind.outputs.cache-hit != 'true' && (github.event_name == 'push' || steps.set_plugin_dirs.outputs.run_ci == 'true') }}
run: |
export BITCOIND_VERSION=${{ matrix.bitcoind-version }}
wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIND_VERSION}/bitcoin-${BITCOIND_VERSION}-x86_64-linux-gnu.tar.gz
tar -xzf bitcoin-${BITCOIND_VERSION}-x86_64-linux-gnu.tar.gz
sudo mv bitcoin-${BITCOIND_VERSION}/bin/* /usr/local/bin
rm -rf bitcoin-${BITCOIND_VERSION}-x86_64-linux-gnu.tar.gz bitcoin-${BITCOIND_VERSION}
- name: Save bitcoind cache
uses: actions/cache/save@v4
if: ${{ steps.cache-bitcoind.outputs.cache-hit != 'true' && github.event_name == 'push' }}
with:
path: /usr/local/bin/bitcoin*
key: cache-bitcoind-${{ matrix.bitcoind-version }}-${{ steps.exact_versions.outputs.os_version }}
- name: Restore CLN cache
id: cache-cln
if: ${{ github.event_name == 'push' || steps.set_plugin_dirs.outputs.run_ci == 'true' }}
uses: actions/cache@v4
with:
path: |
/usr/local/bin/lightning*
/usr/local/libexec/c-lightning
./lightning
key: cache-cln-${{ matrix.cln-version }}-${{ steps.exact_versions.outputs.os_version }}
- name: Download Core Lightning ${{ matrix.cln-version }} & install binaries
if: ${{ steps.cache-cln.outputs.cache-hit != 'true' && (github.event_name == 'push' || steps.set_plugin_dirs.outputs.run_ci == 'true') }}
id: cln-install
run: |
url=$(curl -s https://api.github.com/repos/ElementsProject/lightning/releases/tags/v${{ matrix.cln-version }} \
| jq '.assets[] | select(.name | contains("22.04")) | .browser_download_url' \
| tr -d '\"')
wget $url
sudo tar -xvf ${url##*/} -C /usr/local --strip-components=2
- name: Checkout Core Lightning ${{ matrix.cln-version }}
if: ${{ steps.cache-cln.outputs.cache-hit != 'true' && (github.event_name == 'push' || steps.set_plugin_dirs.outputs.run_ci == 'true') }}
uses: actions/checkout@v4
with:
repository: 'ElementsProject/lightning'
path: 'lightning'
ref: 'v${{ matrix.cln-version }}'
fetch-depth: 0 # Fetch all history for all branches and tags
submodules: 'recursive'
- name: Save CLN cache
uses: actions/cache/save@v4
if: ${{ steps.cache-cln.outputs.cache-hit != 'true' && github.event_name == 'push' }}
with:
path: |
/usr/local/bin/lightning*
/usr/local/libexec/c-lightning
./lightning
key: cache-cln-${{ matrix.cln-version }}-${{ steps.exact_versions.outputs.os_version }}
- name: Restore python dependencies cache
id: cache-python-deps
if: ${{ github.event_name == 'push' || steps.set_plugin_dirs.outputs.run_ci == 'true' }}
uses: actions/cache@v4
with:
path: ~/.local/lib/python${{ matrix.python-version }}/site-packages
key: cache-python-deps-${{ steps.exact_versions.outputs.python_version }}-${{ matrix.cln-version }}-${{ steps.exact_versions.outputs.os_version }}
- name: Install Core Lightning Python package dependencies
if: ${{ steps.cache-python-deps.outputs.cache-hit != 'true' && (github.event_name == 'push' || steps.set_plugin_dirs.outputs.run_ci == 'true') }}
run: |
cd lightning
pip3 install --user -U \
pip \
poetry \
wheel \
blinker \
pytest-custom-exit-code==0.3.0 \
pytest-json-report
poetry install
poetry update
poetry export --without-hashes -f requirements.txt --output requirements.txt
pip install --user -U -r requirements.txt
pip install --user contrib/pyln-client contrib/pyln-testing flaky
pip3 install --upgrade pip
pip3 install --user -U virtualenv pip > /dev/null
- name: Save python dependencies cache
uses: actions/cache/save@v4
if: ${{ steps.cache-python-deps.outputs.cache-hit != 'true' && github.event_name == 'push' }}
with:
path: ~/.local/lib/python${{ matrix.python-version }}/site-packages
key: cache-python-deps-${{ steps.exact_versions.outputs.python_version }}-${{ matrix.cln-version }}-${{ steps.exact_versions.outputs.os_version }}
- name: Run pytest tests
id: pytest_tests
if: ${{ github.event_name == 'push' || steps.set_plugin_dirs.outputs.run_ci == 'true' }}
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
if [[ "${{ github.event_name }}" == 'pull_request' ]]; then
plugin_dirs="${{ steps.set_plugin_dirs.outputs.plugin_dirs }}"
else
plugin_dirs=""
fi
# Run the tests: In the case of a 'pull_request' event only the plugins in `plugin_dirs`
# are going to be tested; otherwise ('push' event) we test all plugins.
update_badges=''
if [[ "${{ github.event_name }}" == 'push' && "${{ github.ref }}" == 'refs/heads/master' ]] || [[ "${{ github.event_name }}" == 'schedule' ]]
then
update_badges='--update-badges'
fi
if [[ -z "$plugin_dirs" ]]; then
# Test all plugins if no specific plugins were changed
python3 .ci/test.py ${{ matrix.cln-version }} ${{ matrix.python-version }} $update_badges
else
python3 .ci/test.py ${{ matrix.cln-version }} ${{ matrix.python-version }} $update_badges $(echo "$plugin_dirs")
fi
gather:
# A dummy task that depends on the full matrix of tests, and signals completion.
name: CI completion
runs-on: ubuntu-latest
if: ${{ always() && github.event_name == 'push' }}
needs:
- build-and-test
strategy:
fail-fast: false
matrix:
cln-version: ["24.08.1", "24.05", "24.02.2"]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Complete
run: |
python_versions='3.8 3.11'
echo "Updating badges data for ${{ matrix.cln-version }} workflow..."
python3 .ci/update_badges.py ${{ matrix.cln-version }} $(echo "$python_versions")
echo "CI completed."