fix: add 5-minute timeout to library tests to prevent CI hangs #250
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # yamllint disable rule:line-length | |
| name: Test | |
| on: [push, pull_request] | |
| jobs: | |
| test-pycparser: | |
| name: Test pycparser (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| python-version: '3.10' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: "**/pyproject.toml" | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: uv pip install --system -e .[test] | |
| - name: Test pycparser backend | |
| run: pytest ./test -m "not libclang" | |
| test-libclang: | |
| name: Test libclang (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| python-version: '3.13' | |
| - os: macos-latest | |
| python-version: '3.13' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: "**/pyproject.toml" | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install libclang (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update && sudo apt-get install -y libclang-dev llvm | |
| # Find libclang and add to library path for Python clang2 bindings | |
| LLVM_LIB_DIR=$(llvm-config --libdir 2>/dev/null || echo "/usr/lib/llvm-14/lib") | |
| echo "LD_LIBRARY_PATH=${LLVM_LIB_DIR}:${LD_LIBRARY_PATH}" >> $GITHUB_ENV | |
| # Get LLVM major version for matching Python clang2 package | |
| LLVM_VERSION=$(llvm-config --version 2>/dev/null | cut -d. -f1 || echo "14") | |
| echo "LLVM_MAJOR_VERSION=${LLVM_VERSION}" >> $GITHUB_ENV | |
| echo "Found LLVM version: $LLVM_VERSION, lib dir: $LLVM_LIB_DIR" | |
| - name: Install test libraries (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: sudo ./scripts/install-test-libs-linux.sh | |
| - name: Install libclang (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| # Install LLVM 19 (clang2 supports 16-21) | |
| brew install llvm@19 | |
| LLVM_PREFIX=$(brew --prefix llvm@19) | |
| echo "DYLD_LIBRARY_PATH=${LLVM_PREFIX}/lib:${DYLD_LIBRARY_PATH}" >> $GITHUB_ENV | |
| # Get LLVM major version for matching Python clang2 package | |
| LLVM_VERSION=$("${LLVM_PREFIX}/bin/llvm-config" --version | cut -d. -f1) | |
| echo "LLVM_MAJOR_VERSION=${LLVM_VERSION}" >> $GITHUB_ENV | |
| echo "Found LLVM version: $LLVM_VERSION, prefix: $LLVM_PREFIX" | |
| - name: Install dependencies | |
| run: uv pip install --system -e .[test] | |
| - name: Install matching clang2 Python package | |
| run: | | |
| # Install clang2 package version matching system libclang | |
| uv pip install --system "clang2==${LLVM_MAJOR_VERSION}.*" | |
| - name: Test all backends (Linux) | |
| if: runner.os == 'Linux' | |
| run: pytest ./test | |
| - name: Test (macOS, skip real headers) | |
| if: runner.os == 'macOS' | |
| run: pytest ./test -m "not real_headers" | |
| test-windows: | |
| name: Test Windows (pycparser) | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: "**/pyproject.toml" | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: Install dependencies | |
| run: uv pip install --system -e .[test] | |
| - name: Test pycparser backend | |
| run: pytest ./test -m "not libclang" |