-
Notifications
You must be signed in to change notification settings - Fork 168
88 lines (84 loc) · 3 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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:
# We're stuck on Ubuntu 20.04 as long as we want to keep testing on Python
# 3.6 due to actions/setup-python#544.
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ${{ (github.event_name == 'push' || inputs.test_all_python_versions)
&& fromJSON('["3.13", "3.12", "3.11", "3.10", "3.9", "3.8", "3.7", "3.6"]')
|| fromJSON('["3.12", "3.6"]')}}
cc: [gcc, clang]
fail-fast: false
env:
CC: ${{ matrix.cc }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Check Python version for pre-commit
# Only run pre-commit / mypy on upstream supported Python versions
run: |
if [[ "${{ matrix.python-version }}" =~ ^3\.([89]|[0-9][0-9])$ ]]; then
echo USE_PRE_COMMIT=1 >> $GITHUB_ENV
fi
- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y btrfs-progs check dwarves libelf-dev libdw-dev qemu-kvm zstd ${{ matrix.cc == 'clang' && 'libomp-$(clang --version | sed -rn "s/.*clang version ([0-9]+).*/\\1/p")-dev' || '' }}
pip install pyroute2 setuptools ${USE_PRE_COMMIT/1/pre-commit}
- name: Generate version.py
run: python setup.py --version
- name: Check with mypy
if: ${{ env.USE_PRE_COMMIT == '1' }}
run: pre-commit run --all-files mypy
- name: Build and test with ${{ matrix.cc }}
run: CONFIGURE_FLAGS="--enable-compiler-warnings=error" python setup.py test -K ${{ inputs.test_all_kernel_flavors && '-F' || '' }}
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
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