Skip to content

Commit 27a8a0d

Browse files
committed
Add headless mode and enhance GitHub Actions
This introduces headless mode for menuconfig to enable non-interactive configuration in CI/CD pipelines. This allows menuconfig to load configs without requiring a terminal or curses interface.
1 parent 43e1f91 commit 27a8a0d

File tree

2 files changed

+55
-8
lines changed

2 files changed

+55
-8
lines changed

.github/workflows/test.yml

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
# NOTE: Testing of the Windows targets are currently disabled because
22-
# the test script is simply not ready for it.
21+
# NOTE: Full testsuite on Windows is disabled because the test script
22+
# requires Linux kernel source tree. However, headless mode tests
23+
# are now enabled for Windows.
2324
target:
2425
# Python 3.12
2526
- python: '3.12'
@@ -28,9 +29,10 @@ jobs:
2829
- python: '3.12'
2930
os: macOS
3031
builder: macos-15
31-
# - python: '3.12'
32-
# os: Windows
33-
# builder: windows-2022
32+
- python: '3.12'
33+
os: Windows
34+
builder: windows-2022
35+
headless-only: true
3436

3537
steps:
3638
- name: Set up environment
@@ -58,6 +60,8 @@ jobs:
5860
pip install --user setuptools wheel
5961
6062
- name: Check out Linux source code
63+
# Skip for Windows (headless-only mode)
64+
if: ${{ matrix.target.headless-only != true }}
6165
uses: actions/checkout@v5
6266
# On Windows, checkout of 'aux.c' is expected to fail because ... Windows.
6367
continue-on-error: true
@@ -68,12 +72,44 @@ jobs:
6872
- name: Check out Kconfiglib source code
6973
uses: actions/checkout@v5
7074
with:
71-
path: Kconfiglib
75+
# Windows (headless-only): checkout to root directory
76+
# Linux/macOS (full test): checkout to Kconfiglib subdirectory
77+
path: ${{ matrix.target.headless-only && '.' || 'Kconfiglib' }}
7278

7379
- name: Apply Linux Kconfig Makefile patch
80+
# Skip for Windows (headless-only mode)
81+
if: ${{ matrix.target.headless-only != true }}
7482
run: |
7583
git apply Kconfiglib/makefile.patch
7684
7785
- name: Run testsuite
86+
# Skip for Windows (headless-only mode)
87+
if: ${{ matrix.target.headless-only != true }}
7888
run: |
7989
Kconfiglib/tests/reltest python
90+
91+
- name: Test headless mode
92+
# Use root dir for Windows, Kconfiglib subdir for Linux/macOS
93+
working-directory: ${{ matrix.target.headless-only && '.' || 'Kconfiglib' }}
94+
run: |
95+
python -c "
96+
from kconfiglib import Kconfig
97+
import menuconfig
98+
99+
print('Testing headless mode...')
100+
kconf = Kconfig('examples/Kmenuconfig')
101+
menuconfig.menuconfig(kconf, headless=True)
102+
print('✅ Headless mode test passed')
103+
"
104+
105+
- name: Install windows-curses (Windows only)
106+
if: matrix.target.os == 'Windows'
107+
run: |
108+
pip install windows-curses
109+
110+
- name: Test menuconfig import (Windows Python 3.12)
111+
if: matrix.target.os == 'Windows'
112+
# Use root dir for Windows (headless-only mode)
113+
working-directory: ${{ matrix.target.headless-only && '.' || 'Kconfiglib' }}
114+
run: |
115+
python -c "import menuconfig; print('✅ menuconfig import successful')"

menuconfig.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,15 +729,22 @@ def _main():
729729
menuconfig(standard_kconfig(__doc__))
730730

731731

732-
def menuconfig(kconf):
732+
def menuconfig(kconf, headless=False):
733733
"""
734734
Launches the configuration interface, returning after the user exits.
735735
736736
kconf:
737737
Kconfig instance to be configured
738+
739+
headless:
740+
If True, run in headless mode without launching the terminal interface.
741+
This is useful for testing, CI/CD pipelines, and automated configuration
742+
processing. In headless mode, the function only loads the configuration
743+
and returns immediately without user interaction.
738744
"""
739745
# Import curses at runtime to avoid issues in headless environments
740-
_ensure_curses()
746+
if not headless:
747+
_ensure_curses()
741748

742749
global _kconf
743750
global _conf_filename
@@ -785,6 +792,10 @@ def menuconfig(kconf):
785792
if _CHANGE_C_LC_CTYPE_TO_UTF8:
786793
_change_c_lc_ctype_to_utf8()
787794

795+
# In headless mode, just load the configuration and return
796+
if headless:
797+
return
798+
788799
# Get rid of the delay between pressing ESC and jumping to the parent menu,
789800
# unless the user has set ESCDELAY (see ncurses(3)). This makes the UI much
790801
# smoother to work with.

0 commit comments

Comments
 (0)