name: CI on: push: branches: - main workflow_dispatch: inputs: test_all_python_versions: description: "Run tests on all Python versions" type: boolean default: false required: true test_all_kernel_flavors: description: "Run tests on all kernel flavors" type: boolean default: false required: true workflow_call: inputs: test_all_python_versions: description: "Run tests on all Python versions" type: boolean default: false required: true test_all_kernel_flavors: description: "Run tests on all kernel flavors" type: boolean default: false required: true concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: test: runs-on: ubuntu-22.04 strategy: matrix: python-version: ${{ (github.event_name == 'push' || inputs.test_all_python_versions) && fromJSON('["3.14", "3.13", "3.12", "3.11", "3.10", "3.9", "3.8"]') || fromJSON('["3.14", "3.8"]')}} cc: [gcc, clang] fail-fast: false env: CC: ${{ matrix.cc }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v5 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} allow-prereleases: true - name: Install dependencies run: | sudo apt-get update -y sudo apt-get install -y btrfs-progs check dwarves libelf-dev libdw-dev libjson-c-dev libpcre2-dev qemu-kvm zstd ${{ matrix.cc == 'clang' && 'libomp-$(clang --version | sed -rn "s/.*clang version ([0-9]+).*/\\1/p")-dev' || '' }} # pyroute2 0.9.1 dropped support for Python < 3.9. if [[ "${{ matrix.python-version }}" =~ ^3\.[678]$ ]]; then pyroute2_version="<0.9.1" fi pip install "pyroute2$pyroute2_version" setuptools pre-commit # Upstream defaults to world-read-writeable /dev/kvm. Debian/Ubuntu # override this; see # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=892945. We want the # upstream default. - name: Set up KVM run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /lib/udev/rules.d/99-fix-kvm.rules > /dev/null sudo udevadm control --reload-rules sudo udevadm trigger -w /dev/kvm - name: Generate version.py run: python setup.py --version - name: Check with mypy run: pre-commit run --all-files mypy - name: Build and test with ${{ matrix.cc }} # We link to libgcc_s on Python 3.8 to work around # https://github.com/python/cpython/issues/88600 (which for us # manifested as spurious crashes in test cases that fork). run: CONFIGURE_FLAGS="--enable-compiler-warnings=error ${{ matrix.python-version == '3.8' && 'LIBS=-lgcc_s' || '' }}" python setup.py test -K ${{ inputs.test_all_kernel_flavors && '-F' || '' }} lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - name: Set up Python uses: actions/setup-python@v6 with: python-version: '3.x' - name: Install dependencies run: pip install pre-commit - name: Run pre-commit hooks run: SKIP=mypy pre-commit run --all-files --show-diff-on-failure