Skip to content

Commit a118b06

Browse files
committed
feat(ci): add CI with lint, unit, E2E, and code quality checks
1 parent 09692ad commit a118b06

File tree

53 files changed

+804
-402
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+804
-402
lines changed

.github/workflows/tests.yml

Lines changed: 331 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,331 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
lint:
10+
name: Lint & static checks
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python 3.12.3
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.12.3"
20+
21+
- name: Install system build dependencies
22+
run: |
23+
sudo apt-get update
24+
sudo apt-get install -y \
25+
gobject-introspection \
26+
libgirepository1.0-dev \
27+
libcairo2-dev \
28+
libffi-dev \
29+
build-essential \
30+
python3-dev \
31+
meson \
32+
ninja-build \
33+
pkg-config \
34+
gir1.2-gtk-3.0
35+
36+
- name: Install Python dependencies (project)
37+
uses: ./.github/actions/install-python-dependencies
38+
39+
- name: Generate config.py
40+
run: |
41+
cd src/utils
42+
python generate_config.py
43+
44+
- name: Compile QT resources
45+
run: |
46+
poetry run pyside6-rcc src/resources.qrc -o src/resources_rc.py
47+
48+
- name: Code quality checks
49+
run: |
50+
pip install pre-commit
51+
pre-commit run --all-files --show-diff-on-failure
52+
53+
unit-tests:
54+
name: Unit tests
55+
runs-on: ubuntu-22.04
56+
env:
57+
QT_QPA_PLATFORM: offscreen
58+
TZ: Asia/Kolkata
59+
PYTHON_KEYRING_BACKEND: keyrings.alt.file.PlaintextKeyring
60+
steps:
61+
- name: Checkout repository
62+
uses: actions/checkout@v4
63+
64+
- name: Set up Python 3.12.3 environment
65+
uses: actions/setup-python@v5
66+
with:
67+
python-version: "3.12.3"
68+
69+
- name: Install required system dependencies
70+
run: |
71+
sudo apt-get update
72+
sudo apt-get install -y \
73+
libxcb-cursor0 \
74+
libegl1 \
75+
libgl1 \
76+
ruby-dev \
77+
build-essential \
78+
libgirepository1.0-dev \
79+
python3-dev \
80+
libfuse2 \
81+
gobject-introspection \
82+
meson \
83+
ninja-build \
84+
pkg-config \
85+
libcairo2-dev \
86+
libffi-dev
87+
sudo gem install fpm -f
88+
89+
- name: Generate config.py
90+
run: |
91+
cd src/utils
92+
python generate_config.py
93+
94+
- name: Preinstall keyring backends (system Python)
95+
run: |
96+
pip install keyring keyrings.alt
97+
98+
- name: Install Python dependencies
99+
uses: ./.github/actions/install-python-dependencies
100+
101+
- name: Install keyring backends in Poetry venv
102+
run: |
103+
poetry run pip install keyring keyrings.alt
104+
105+
- name: Set KEYRING_HOME env
106+
run: |
107+
echo "KEYRING_HOME=$RUNNER_TEMP/keyring" >> "$GITHUB_ENV"
108+
109+
- name: Ensure keyring storage directory exists
110+
run: |
111+
mkdir -p "$KEYRING_HOME"
112+
113+
- name: Compile QT resources
114+
run: |
115+
poetry run pyside6-rcc src/resources.qrc -o src/resources_rc.py
116+
117+
- name: Run unit tests (fail if coverage < 90%)
118+
run: |
119+
poetry run pytest -v --maxfail=1 \
120+
--cov=src \
121+
--cov-fail-under=90 \
122+
unit_tests/tests
123+
124+
e2e-dogtail:
125+
name: E2E Dogtail tests
126+
runs-on: ubuntu-22.04
127+
timeout-minutes: 120
128+
env:
129+
DISPLAY: :99
130+
steps:
131+
- name: Checkout repository
132+
uses: actions/checkout@v4
133+
134+
- name: Set up Python 3.12.3 environment
135+
uses: actions/setup-python@v5
136+
with:
137+
python-version: "3.12.3"
138+
139+
- name: Install Poetry
140+
uses: snok/install-poetry@v1
141+
with:
142+
version: 1.8.3
143+
virtualenvs-create: true
144+
virtualenvs-in-project: false
145+
installer-parallel: true
146+
147+
- name: Install required system dependencies
148+
run: |
149+
sudo apt-get install -y \
150+
xvfb \
151+
x11-apps \
152+
xauth \
153+
dbus-x11 \
154+
at-spi2-core \
155+
libatk-bridge2.0-0 \
156+
libxcb-cursor0 \
157+
libxkbcommon-x11-0 \
158+
libxkbcommon0 \
159+
libxcb1 \
160+
libxcb-xinerama0 \
161+
libxcb-xfixes0 \
162+
libxcb-randr0 \
163+
libxcb-icccm4 \
164+
libxcb-image0 \
165+
libxcb-keysyms1 \
166+
libxcb-render-util0 \
167+
libxcb-shape0 \
168+
libxcb-shm0 \
169+
libxcb-glx0 \
170+
libxcb-render0 \
171+
libxcb-present0 \
172+
libxcb-dri3-0 \
173+
libxcb-xinput0 \
174+
libx11-xcb1 \
175+
libxrender1 \
176+
libxcomposite1 \
177+
libxi6 \
178+
libxtst6 \
179+
libxrandr2 \
180+
libxdamage1 \
181+
libxext6 \
182+
libfontconfig1 \
183+
libdrm2 \
184+
libegl1 \
185+
libgl1 \
186+
libgtk-3-0 \
187+
gir1.2-gtk-3.0 \
188+
gir1.2-atspi-2.0 \
189+
python3-gi \
190+
xdg-desktop-portal \
191+
xdg-desktop-portal-gtk \
192+
qt6-gtk-platformtheme \
193+
fonts-dejavu-core \
194+
adwaita-icon-theme \
195+
shared-mime-info \
196+
libgl1-mesa-dri \
197+
mesa-utils \
198+
libgirepository1.0-dev \
199+
meson \
200+
gobject-introspection \
201+
ninja-build \
202+
gsettings-desktop-schemas \
203+
dconf-cli \
204+
dconf-service \
205+
xclip \
206+
wmctrl \
207+
libdbus-1-3 \
208+
libglib2.0-0 \
209+
libnss3 \
210+
libxss1 \
211+
libatk1.0-0 \
212+
libxcb-util1 \
213+
ruby-dev \
214+
build-essential \
215+
libfuse2
216+
sudo gem install fpm -f
217+
218+
- name: Install Rust toolchain
219+
uses: dtolnay/rust-toolchain@stable
220+
221+
- name: Preinstall keyring backends (system Python)
222+
run: |
223+
pip install keyring keyrings.alt
224+
225+
- name: Install Python dependencies
226+
uses: ./.github/actions/install-python-dependencies
227+
228+
- name: Install keyring backends in Poetry venv
229+
run: |
230+
poetry run pip install keyring keyrings.alt
231+
232+
- name: Set KEYRING_HOME env
233+
run: |
234+
echo "KEYRING_HOME=$RUNNER_TEMP/keyring" >> "$GITHUB_ENV"
235+
236+
- name: Ensure keyring storage directory exists
237+
run: |
238+
mkdir -p "$KEYRING_HOME"
239+
240+
- name: Build the rgb-lightning-node binary
241+
uses: ./.github/actions/build-rln-node
242+
243+
- name: Add rgb-lightning-node to PATH
244+
run: |
245+
chmod +x ln_node_binary/rgb-lightning-node
246+
echo "$GITHUB_WORKSPACE/ln_node_binary" >> $GITHUB_PATH
247+
248+
- name: Compile QT resources
249+
run: |
250+
poetry run pyside6-rcc src/resources.qrc -o src/resources_rc.py
251+
252+
- name: Start Xvfb (headless display) and prepare XAUTHORITY
253+
run: |
254+
export XAUTHORITY="${XAUTHORITY:-$RUNNER_TEMP/.Xauthority}"
255+
mkdir -p "$(dirname "$XAUTHORITY")"
256+
touch "$XAUTHORITY"
257+
cookie=$(mcookie)
258+
xauth -f "$XAUTHORITY" add :99 . "$cookie"
259+
echo "XAUTHORITY=$XAUTHORITY" >> $GITHUB_ENV
260+
Xvfb :99 -screen 0 1920x1080x24 -nolisten tcp -extension MIT-SHM &
261+
echo "XVFB_PID=$!" >> $GITHUB_ENV
262+
sleep 3 # Wait for Xvfb to start
263+
264+
- name: Ensure E2E scripts are executable
265+
run: |
266+
chmod +x run_e2e_tests.sh
267+
chmod +x e2e_tests/regtest.sh
268+
269+
- name: Prepare runtime Python deps for AppImage (keyring backends)
270+
run: |
271+
RUNTIME_PYDEPS="$RUNNER_TEMP/pydeps"
272+
mkdir -p "$RUNTIME_PYDEPS"
273+
python -m pip install --upgrade pip
274+
python -m pip install --target "$RUNTIME_PYDEPS" keyring keyrings.alt
275+
echo "PYTHONPATH=$RUNTIME_PYDEPS" >> $GITHUB_ENV
276+
277+
- name: Install lightweight window manager for Xvfb
278+
run: |
279+
sudo apt-get install -y --no-install-recommends openbox wmctrl dbus-x11
280+
281+
- name: Start regtest services (Docker)
282+
run: |
283+
poetry run regtest-start
284+
285+
- name: Run E2E tests (build if missing and run for both modes)
286+
env:
287+
CLIENT_ID: ${{ secrets.CLIENT_ID }}
288+
PROJECT_ID: ${{ secrets.PROJECT_ID }}
289+
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
290+
LD_LIBRARY_PATH: /usr/local/lib
291+
QT_QPA_PLATFORM: xcb
292+
APPIMAGE_EXTRACT_AND_RUN: '1'
293+
run: |
294+
cd src/utils
295+
python generate_config.py
296+
cd ../../
297+
dbus-run-session -- bash -lc '
298+
set -euo pipefail
299+
export DISPLAY=:99
300+
export NO_AT_BRIDGE=0
301+
export GTK_MODULES=atk-bridge
302+
export QT_QPA_PLATFORM=xcb
303+
export GDK_BACKEND=x11
304+
export XDG_CURRENT_DESKTOP=GNOME
305+
export GTK_USE_PORTAL=1
306+
export QT_QPA_PLATFORMTHEME=gtk3
307+
export QT_OPENGL=software
308+
export QT_XCB_GL_INTEGRATION=none
309+
export LIBGL_ALWAYS_SOFTWARE=1
310+
export QT_X11_NO_MITSHM=1
311+
export XAUTHORITY="${XAUTHORITY:-$RUNNER_TEMP/.Xauthority}"
312+
export LANG=C.UTF-8
313+
export LC_ALL=C.UTF-8
314+
export APPIMAGE_EXTRACT_AND_RUN=1
315+
export KEYRING_HOME="$RUNNER_TEMP/keyring"
316+
mkdir -p "$KEYRING_HOME"
317+
export PYTHON_KEYRING_BACKEND=keyrings.alt.file.PlaintextKeyring
318+
export PYTHONPATH="$RUNNER_TEMP/pydeps:$PYTHONPATH"
319+
export PYTHONNOUSERSITE=0
320+
export XDG_RUNTIME_DIR="$RUNNER_TEMP/xdg"
321+
mkdir -p "$XDG_RUNTIME_DIR" && chmod 700 "$XDG_RUNTIME_DIR"
322+
export GSETTINGS_BACKEND=dconf
323+
gsettings set org.gnome.desktop.interface toolkit-accessibility true
324+
/usr/lib/at-spi2-core/at-spi-bus-launcher --launch-immediately &
325+
/usr/lib/at-spi2-core/at-spi2-registryd &
326+
export PATH="$GITHUB_WORKSPACE/ln_node_binary:$PATH"
327+
dbus-update-activation-environment DISPLAY XAUTHORITY QT_ACCESSIBILITY QT_LINUX_ACCESSIBILITY_ALWAYS_ON NO_AT_BRIDGE GTK_MODULES GDK_BACKEND PYTHON_KEYRING_BACKEND KEYRING_HOME APPIMAGE_EXTRACT_AND_RUN PATH
328+
openbox &
329+
sleep 6 # Wait for Xvfb to start
330+
poetry run e2e-test all
331+
'

build_linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ else
1010
echo "File not found: ./$PROJECT_NAME.deb"
1111
fi
1212

13-
#remove aready exits file and dir
13+
#remove already exits file and dir
1414
rm -rf build
1515
rm -rf dist
1616
rm -rf package

0 commit comments

Comments
 (0)