| 1 |
name: CI |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- main |
| 7 |
workflow_dispatch: |
| 8 |
inputs: |
| 9 |
test_all_python_versions: |
| 10 |
description: "Run tests on all Python versions" |
| 11 |
type: boolean |
| 12 |
default: false |
| 13 |
required: true |
| 14 |
test_all_kernel_flavors: |
| 15 |
description: "Run tests on all kernel flavors" |
| 16 |
type: boolean |
| 17 |
default: false |
| 18 |
required: true |
| 19 |
workflow_call: |
| 20 |
inputs: |
| 21 |
test_all_python_versions: |
| 22 |
description: "Run tests on all Python versions" |
| 23 |
type: boolean |
| 24 |
default: false |
| 25 |
required: true |
| 26 |
test_all_kernel_flavors: |
| 27 |
description: "Run tests on all kernel flavors" |
| 28 |
type: boolean |
| 29 |
default: false |
| 30 |
required: true |
| 31 |
|
| 32 |
concurrency: |
| 33 |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 34 |
cancel-in-progress: true |
| 35 |
|
| 36 |
jobs: |
| 37 |
test: |
| 38 |
runs-on: ubuntu-22.04 |
| 39 |
strategy: |
| 40 |
matrix: |
| 41 |
python-version: ${{ (github.event_name == 'push' || inputs.test_all_python_versions) |
| 42 |
&& fromJSON('["3.14", "3.13", "3.12", "3.11", "3.10", "3.9", "3.8"]') |
| 43 |
|| fromJSON('["3.14", "3.8"]')}} |
| 44 |
cc: [gcc, clang] |
| 45 |
fail-fast: false |
| 46 |
env: |
| 47 |
CC: ${{ matrix.cc }} |
| 48 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 49 |
steps: |
| 50 |
- uses: actions/checkout@v5 |
| 51 |
- name: Set up Python ${{ matrix.python-version }} |
| 52 |
uses: actions/setup-python@v6 |
| 53 |
with: |
| 54 |
python-version: ${{ matrix.python-version }} |
| 55 |
allow-prereleases: true |
| 56 |
- name: Install dependencies |
| 57 |
run: | |
| 58 |
sudo apt-get update -y |
| 59 |
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' || '' }} |
| 60 |
# pyroute2 0.9.1 dropped support for Python < 3.9. |
| 61 |
if [[ "${{ matrix.python-version }}" =~ ^3\.[678]$ ]]; then |
| 62 |
pyroute2_version="<0.9.1" |
| 63 |
fi |
| 64 |
pip install "pyroute2$pyroute2_version" setuptools pre-commit |
| 65 |
# Upstream defaults to world-read-writeable /dev/kvm. Debian/Ubuntu |
| 66 |
# override this; see |
| 67 |
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=892945. We want the |
| 68 |
# upstream default. |
| 69 |
- name: Set up KVM |
| 70 |
run: | |
| 71 |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /lib/udev/rules.d/99-fix-kvm.rules > /dev/null |
| 72 |
sudo udevadm control --reload-rules |
| 73 |
sudo udevadm trigger -w /dev/kvm |
| 74 |
- name: Generate version.py |
| 75 |
run: python setup.py --version |
| 76 |
- name: Check with mypy |
| 77 |
run: pre-commit run --all-files mypy |
| 78 |
- name: Build and test with ${{ matrix.cc }} |
| 79 |
# We link to libgcc_s on Python 3.8 to work around |
| 80 |
# https://github.com/python/cpython/issues/88600 (which for us |
| 81 |
# manifested as spurious crashes in test cases that fork). |
| 82 |
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' || '' }} |
| 83 |
|
| 84 |
lint: |
| 85 |
runs-on: ubuntu-latest |
| 86 |
steps: |
| 87 |
- uses: actions/checkout@v5 |
| 88 |
- name: Set up Python |
| 89 |
uses: actions/setup-python@v6 |
| 90 |
with: |
| 91 |
python-version: '3.x' |
| 92 |
- name: Install dependencies |
| 93 |
run: pip install pre-commit |
| 94 |
- name: Run pre-commit hooks |
| 95 |
run: SKIP=mypy pre-commit run --all-files --show-diff-on-failure |