Skip to content

Commit 31697c8

Browse files
committed
CI: refactor compile job into reusable workflow
Splits the compile matrix job into a reusable workflow that can be called with specific build configurations. This improves maintainability by centralizing build logic and enables parallel test execution by allowing jobs to depend on specific builds rather than all builds. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Changelog-None
1 parent af5d02a commit 31697c8

File tree

2 files changed

+132
-69
lines changed

2 files changed

+132
-69
lines changed

.github/workflows/build-cln.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
name: Build CLN
3+
on:
4+
workflow_call:
5+
inputs:
6+
cfg:
7+
description: 'Configuration name (e.g., compile-gcc)'
8+
required: true
9+
type: string
10+
compiler:
11+
description: 'Compiler to use (gcc or clang)'
12+
required: true
13+
type: string
14+
valgrind:
15+
description: 'Enable valgrind (0 or 1)'
16+
required: false
17+
type: number
18+
default: 1
19+
asan:
20+
description: 'Enable address sanitizer (0 or 1)'
21+
required: false
22+
type: number
23+
default: 0
24+
ubsan:
25+
description: 'Enable undefined behavior sanitizer (0 or 1)'
26+
required: false
27+
type: number
28+
default: 0
29+
coptflags:
30+
description: 'Additional compiler optimization flags'
31+
required: false
32+
type: string
33+
default: ''
34+
35+
env:
36+
RUST_PROFILE: release
37+
SLOW_MACHINE: 1
38+
39+
jobs:
40+
build:
41+
name: Build CLN ${{ inputs.cfg }}
42+
runs-on: ubuntu-22.04
43+
timeout-minutes: 30
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v4
47+
48+
- name: Set up Python 3.10
49+
uses: actions/setup-python@v5
50+
with:
51+
python-version: "3.10"
52+
53+
- name: Install uv
54+
uses: astral-sh/setup-uv@v5
55+
56+
- name: Install dependencies
57+
run: |
58+
bash -x .github/scripts/setup.sh
59+
60+
- name: Build
61+
env:
62+
COMPILER: ${{ inputs.compiler }}
63+
ASAN: ${{ inputs.asan }}
64+
UBSAN: ${{ inputs.ubsan }}
65+
VALGRIND: ${{ inputs.valgrind }}
66+
COMPAT: 1
67+
CFG: ${{ inputs.cfg }}
68+
run: |
69+
set -e
70+
./configure --enable-debugbuild CC="$COMPILER" ${{ inputs.coptflags }}
71+
72+
uv run make -j $(nproc) testpack.tar.bz2
73+
74+
# Rename now so we don't clash
75+
mv testpack.tar.bz2 cln-${CFG}.tar.bz2
76+
77+
- name: Check rust packages
78+
run: cargo test --all
79+
80+
- uses: actions/upload-artifact@v4
81+
with:
82+
name: cln-${{ inputs.cfg }}.tar.bz2
83+
path: cln-${{ inputs.cfg }}.tar.bz2

.github/workflows/ci.yaml

Lines changed: 49 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -97,70 +97,48 @@ jobs:
9797
- name: Check docs
9898
run: uv run make check-doc
9999

100-
compile:
101-
name: Compile CLN ${{ matrix.cfg }}
102-
runs-on: ubuntu-22.04
103-
timeout-minutes: 30
100+
compile-gcc:
101+
name: Compile CLN (GCC)
104102
needs:
105103
- prebuild
106-
strategy:
107-
fail-fast: true
108-
matrix:
109-
include:
110-
- CFG: compile-gcc
111-
VALGRIND: 1
112-
COMPILER: gcc
113-
- CFG: compile-gcc-O3
114-
VALGRIND: 1
115-
COMPILER: gcc
116-
COPTFLAGS_VAR: COPTFLAGS="-O3 -Werror"
117-
# While we're at it let's try to compile with clang
118-
- CFG: compile-clang
119-
VALGRIND: 1
120-
COMPILER: clang
121-
- CFG: compile-clang-sanitizers
122-
COMPILER: clang
123-
ASAN: 1
124-
UBSAN: 1
125-
VALGRIND: 0
126-
steps:
127-
- name: Checkout
128-
uses: actions/checkout@v4
129-
130-
- name: Set up Python 3.10
131-
uses: actions/setup-python@v5
132-
with:
133-
python-version: "3.10"
134-
135-
- name: Install uv
136-
uses: astral-sh/setup-uv@v5
137-
138-
- name: Install dependencies
139-
run: |
140-
bash -x .github/scripts/setup.sh
141-
142-
- name: Build
143-
env:
144-
COMPILER: ${{ matrix.COMPILER }}
145-
ASAN: ${{ matrix.ASAN }}
146-
UBSAN: ${{ matrix.UBSAN }}
147-
VALGRIND: ${{ matrix.VALGRIND }}
148-
COMPAT: 1
149-
CFG: ${{ matrix.CFG }}
150-
run: |
151-
set -e
152-
./configure --enable-debugbuild CC="$COMPILER" ${{ matrix.COPTFLAGS_VAR }}
153-
154-
uv run make -j $(nproc) testpack.tar.bz2
155-
156-
# Rename now so we don't clash
157-
mv testpack.tar.bz2 cln-${CFG}.tar.bz2
158-
- name: Check rust packages
159-
run: cargo test --all
160-
- uses: actions/upload-artifact@v4
161-
with:
162-
name: cln-${{ matrix.CFG }}.tar.bz2
163-
path: cln-${{ matrix.CFG }}.tar.bz2
104+
uses: ./.github/workflows/build-cln.yaml
105+
with:
106+
cfg: compile-gcc
107+
compiler: gcc
108+
valgrind: 1
109+
110+
compile-gcc-O3:
111+
name: Compile CLN (GCC -O3)
112+
needs:
113+
- prebuild
114+
uses: ./.github/workflows/build-cln.yaml
115+
with:
116+
cfg: compile-gcc-O3
117+
compiler: gcc
118+
valgrind: 1
119+
coptflags: 'COPTFLAGS="-O3 -Werror"'
120+
121+
compile-clang:
122+
name: Compile CLN (Clang)
123+
needs:
124+
- prebuild
125+
uses: ./.github/workflows/build-cln.yaml
126+
with:
127+
cfg: compile-clang
128+
compiler: clang
129+
valgrind: 1
130+
131+
compile-clang-sanitizers:
132+
name: Compile CLN (Clang with sanitizers)
133+
needs:
134+
- prebuild
135+
uses: ./.github/workflows/build-cln.yaml
136+
with:
137+
cfg: compile-clang-sanitizers
138+
compiler: clang
139+
valgrind: 0
140+
asan: 1
141+
ubsan: 1
164142

165143
check-units:
166144
# The unit test checks are not in the critical path (not dependent
@@ -171,7 +149,8 @@ jobs:
171149
env:
172150
BOLTDIR: bolts
173151
needs:
174-
- compile
152+
- compile-gcc
153+
- compile-clang-sanitizers
175154
strategy:
176155
fail-fast: true
177156
matrix:
@@ -239,7 +218,7 @@ jobs:
239218
name: Check we can downgrade the node
240219
runs-on: ubuntu-22.04
241220
needs:
242-
- compile
221+
- compile-gcc
243222
strategy:
244223
fail-fast: false
245224
matrix:
@@ -323,7 +302,8 @@ jobs:
323302
RUST_PROFILE: release # Has to match the one in the compile step
324303
PYTEST_OPTS: --timeout=1200 --durations=10
325304
needs:
326-
- compile
305+
- compile-gcc
306+
- compile-clang
327307
strategy:
328308
fail-fast: false
329309
matrix:
@@ -432,7 +412,7 @@ jobs:
432412
CFG: compile-gcc
433413
PYTEST_OPTS: --test-group-random-seed=42 --timeout=1800 --durations=10
434414
needs:
435-
- compile
415+
- compile-gcc
436416
strategy:
437417
fail-fast: false
438418
matrix:
@@ -503,7 +483,7 @@ jobs:
503483
TEST_DEBUG: 1
504484
PYTEST_OPTS: --test-group-random-seed=42 --timeout=1800 --durations=10
505485
needs:
506-
- compile
486+
- compile-clang-sanitizers
507487
strategy:
508488
fail-fast: false
509489
matrix:
@@ -572,7 +552,7 @@ jobs:
572552
PYTEST_OPTS: --timeout=1200 --durations=10
573553
TEST_NETWORK: regtest
574554
needs:
575-
- compile
555+
- compile-gcc
576556
steps:
577557
- name: Checkout
578558
uses: actions/checkout@v4
@@ -610,7 +590,7 @@ jobs:
610590
RUST_PROFILE: release # Has to match the one in the compile step
611591
PYTEST_OPTS: --timeout=1200 --durations=10
612592
needs:
613-
- compile
593+
- compile-clang
614594
strategy:
615595
fail-fast: false
616596
matrix:

0 commit comments

Comments
 (0)