Skip to content

Commit be09f13

Browse files
committed
feat(ci): split ci into files & add path filter
1 parent f6f9ebf commit be09f13

File tree

3 files changed

+172
-134
lines changed

3 files changed

+172
-134
lines changed

.github/workflows/build-deb.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Build .deb packages
2+
3+
on:
4+
push:
5+
paths:
6+
- .github/workflows/build-deb.yml
7+
- "**.c"
8+
- "**.h"
9+
- "**/Makefile"
10+
- debian/**
11+
- install/**
12+
- kmod/**
13+
# - tests/**
14+
- tools/**
15+
pull_request:
16+
workflow_dispatch:
17+
18+
jobs:
19+
build-deb:
20+
name: Build .deb packages for ${{ matrix.distro.name }} (${{ matrix.arch }})
21+
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
arch: [amd64, arm64]
26+
distro:
27+
- name: Debian 12
28+
codename: bookworm
29+
image: debian:bookworm-slim
30+
extra-repos: |
31+
deb http://deb.debian.org/debian bookworm-backports main
32+
extra-cmd: |
33+
sed -i 's/clang/clang-16/' debian/control
34+
sed -i 's/BPF_CC=clang/BPF_CC=clang-16 COMPAT_LINUX_6_1=1/' debian/rules
35+
- name: Debian 13
36+
codename: trixie
37+
image: debian:trixie-slim
38+
- name: Debian 14 (testing)
39+
codename: forky
40+
image: debian:forky-slim
41+
- name: Debian sid
42+
codename: sid
43+
image: debian:sid-slim
44+
- name: Ubuntu 24.04
45+
codename: noble
46+
image: ubuntu:noble
47+
extra-repos-amd64: |
48+
deb http://archive.ubuntu.com/ubuntu noble-backports main restricted universe multiverse
49+
extra-repos-arm64: |
50+
deb http://ports.ubuntu.com/ubuntu-ports noble-backports main restricted universe multiverse
51+
extra-cmd: |
52+
sed -i 's/clang,/clang, llvm,/' debian/control
53+
steps:
54+
- name: Checkout
55+
uses: actions/checkout@v4
56+
- name: Run pre-building script
57+
run: |
58+
${{ matrix.distro.extra-cmd }}
59+
${{ matrix.arch == 'arm64' && matrix.distro.extra-cmd-arm64 || matrix.distro.extra-cmd-amd64 }}
60+
- name: Build
61+
uses: jtdor/build-deb-action@v1
62+
with:
63+
buildpackage-opts: -b -us -uc
64+
docker-image: ${{ matrix.distro.image }}
65+
extra-repos: |
66+
${{ matrix.distro.extra-repos }}
67+
${{ matrix.arch == 'arm64' && matrix.distro.extra-repos-arm64 || matrix.distro.extra-repos-amd64 }}
68+
- name: Upload
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: packages-${{ matrix.distro.codename }}-${{ matrix.arch }}
72+
path: |
73+
debian/artifacts/*.deb
74+
debian/artifacts/*.ddeb
75+
76+
test-deb-install:
77+
name: Test .deb installation
78+
needs: build-deb
79+
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
80+
strategy:
81+
fail-fast: false
82+
matrix:
83+
arch: [amd64, arm64]
84+
steps:
85+
- name: Checkout
86+
uses: actions/checkout@v4
87+
- name: Download artifact
88+
uses: actions/download-artifact@v4
89+
with:
90+
name: packages-noble-${{ matrix.arch }}
91+
path: packages-noble-${{ matrix.arch }}
92+
- name: Test Install
93+
run: |
94+
sudo apt install ./packages-noble-${{ matrix.arch }}/*.deb linux-headers-`uname -r`
95+
sudo modprobe mimic
96+
- name: Upload log
97+
if: always()
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: dkms-make-log
101+
path: /var/lib/dkms/mimic/*/build/make.log
Lines changed: 8 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,18 @@
1-
name: Push actions
1+
name: Run tests in LVH
22

33
on:
44
push:
5+
paths:
6+
- .github/workflows/test.yml
7+
- "**.c"
8+
- "**.h"
9+
- "**/Makefile"
10+
# - tests/**
11+
- "!tools/**"
512
pull_request:
613
workflow_dispatch:
714

815
jobs:
9-
test:
10-
name: Run tests with ${{ matrix.flags.flags }} ${{ matrix.flags.args }}
11-
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
12-
strategy:
13-
fail-fast: false
14-
matrix:
15-
arch: [amd64] # TODO: arm64 (bpftool not working)
16-
flags:
17-
- flags: CHECKSUM_HACK=kfunc
18-
args: ""
19-
desc: kfunc
20-
- flags: CHECKSUM_HACK=kfunc USE_LIBXDP=0
21-
args: ""
22-
desc: kfunc-no-libxdp
23-
- flags: CHECKSUM_HACK=kfunc USE_LIBXDP=1
24-
args: ""
25-
desc: kfunc-libxdp-use-libbpf
26-
- flags: CHECKSUM_HACK=kfunc USE_LIBXDP=1
27-
args: --use-libxdp
28-
desc: kfunc-libxdp-use-libxdp
29-
- flags: CHECKSUM_HACK=kprobe STRIP_BTF_EXT=1
30-
args: ""
31-
desc: kprobe-strip-btf-ext
32-
steps:
33-
- name: Checkout
34-
uses: actions/checkout@v4
35-
- name: Install dependencies
36-
run: |
37-
sudo apt update
38-
sudo apt install python3 clang-15 llvm pahole \
39-
linux-tools-common linux-tools-$(uname -r) linux-cloud-tools-$(uname -r) \
40-
libbpf-dev libffi-dev libelf-dev libxdp-dev \
41-
bats bc conntrack ethtool iperf3 jq socat tshark wireguard-tools
42-
- name: Build & Test
43-
run: |
44-
export BPF_CC=clang-15
45-
sudo cp /sys/kernel/btf/vmlinux /lib/modules/$(uname -r)/build
46-
make -j ${{ matrix.flags.flags }}
47-
sudo nft delete table filter # Docker's nftables rule drops IPv4 packets in tests
48-
sudo nft list ruleset
49-
sudo insmod out/mimic.ko
50-
sudo env MIMIC_TEST_EXTRA_ARGS="${{ matrix.flags.args }}" make test ${{ matrix.flags.flags }}
51-
- name: Upload captured packets
52-
uses: actions/upload-artifact@v4
53-
if: always()
54-
with:
55-
name: pcap-${{ matrix.flags.desc }}
56-
path: out/*.pcapng
57-
58-
build-deb:
59-
name: Build .deb packages for ${{ matrix.distro.name }}
60-
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
61-
strategy:
62-
fail-fast: false
63-
matrix:
64-
arch: [amd64, arm64]
65-
distro:
66-
- name: Debian 12
67-
codename: bookworm
68-
image: debian:bookworm-slim
69-
extra-repos: |
70-
deb http://deb.debian.org/debian bookworm-backports main
71-
extra-cmd: |
72-
sed -i 's/clang/clang-16/' debian/control
73-
sed -i 's/BPF_CC=clang/BPF_CC=clang-16 COMPAT_LINUX_6_1=1/' debian/rules
74-
- name: Debian 13
75-
codename: trixie
76-
image: debian:trixie-slim
77-
- name: Debian 14 (testing)
78-
codename: forky
79-
image: debian:forky-slim
80-
- name: Debian sid
81-
codename: sid
82-
image: debian:sid-slim
83-
- name: Ubuntu 24.04
84-
codename: noble
85-
image: ubuntu:noble
86-
extra-repos-amd64: |
87-
deb http://archive.ubuntu.com/ubuntu noble-backports main restricted universe multiverse
88-
extra-repos-arm64: |
89-
deb http://ports.ubuntu.com/ubuntu-ports noble-backports main restricted universe multiverse
90-
extra-cmd: |
91-
sed -i 's/clang,/clang, llvm,/' debian/control
92-
steps:
93-
- name: Checkout
94-
uses: actions/checkout@v4
95-
- name: Run pre-building script
96-
run: |
97-
${{ matrix.distro.extra-cmd }}
98-
${{ matrix.arch == 'arm64' && matrix.distro.extra-cmd-arm64 || matrix.distro.extra-cmd-amd64 }}
99-
- name: Build
100-
uses: jtdor/build-deb-action@v1
101-
with:
102-
buildpackage-opts: -b -us -uc
103-
docker-image: ${{ matrix.distro.image }}
104-
extra-repos: |
105-
${{ matrix.distro.extra-repos }}
106-
${{ matrix.arch == 'arm64' && matrix.distro.extra-repos-arm64 || matrix.distro.extra-repos-amd64 }}
107-
- name: Upload
108-
uses: actions/upload-artifact@v4
109-
with:
110-
name: packages-${{ matrix.distro.codename }}-${{ matrix.arch }}
111-
path: |
112-
debian/artifacts/*.deb
113-
debian/artifacts/*.ddeb
114-
115-
test-deb-install:
116-
name: Test .deb installation
117-
needs: build-deb
118-
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
119-
strategy:
120-
fail-fast: false
121-
matrix:
122-
arch: [amd64, arm64]
123-
steps:
124-
- name: Checkout
125-
uses: actions/checkout@v4
126-
- name: Download artifact
127-
uses: actions/download-artifact@v4
128-
with:
129-
name: packages-noble-${{ matrix.arch }}
130-
path: packages-noble-${{ matrix.arch }}
131-
- name: Test Install
132-
run: |
133-
sudo apt install ./packages-noble-${{ matrix.arch }}/*.deb linux-headers-`uname -r`
134-
sudo modprobe mimic
135-
- name: Upload log
136-
if: always()
137-
uses: actions/upload-artifact@v4
138-
with:
139-
name: dkms-make-log
140-
path: /var/lib/dkms/mimic/*/build/make.log
141-
14216
build-exe:
14317
name: Build Mimic CLI executable
14418
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}

.github/workflows/test.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Run tests
2+
3+
on:
4+
push:
5+
paths:
6+
- .github/workflows/test.yml
7+
- "**.c"
8+
- "**.h"
9+
- "**/Makefile"
10+
- tests/**
11+
- "!tools/**"
12+
pull_request:
13+
workflow_dispatch:
14+
15+
jobs:
16+
test:
17+
name: Run tests with ${{ matrix.flags.flags }} ${{ matrix.flags.args }}
18+
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
arch: [amd64] # TODO: arm64 (bpftool not working)
23+
flags:
24+
- flags: CHECKSUM_HACK=kfunc
25+
args: ""
26+
desc: kfunc
27+
- flags: CHECKSUM_HACK=kfunc USE_LIBXDP=0
28+
args: ""
29+
desc: kfunc-no-libxdp
30+
- flags: CHECKSUM_HACK=kfunc USE_LIBXDP=1
31+
args: ""
32+
desc: kfunc-libxdp-use-libbpf
33+
- flags: CHECKSUM_HACK=kfunc USE_LIBXDP=1
34+
args: --use-libxdp
35+
desc: kfunc-libxdp-use-libxdp
36+
- flags: CHECKSUM_HACK=kprobe STRIP_BTF_EXT=1
37+
args: ""
38+
desc: kprobe-strip-btf-ext
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
- name: Install dependencies
43+
run: |
44+
sudo apt update
45+
sudo apt install python3 clang-15 llvm pahole \
46+
linux-tools-common linux-tools-$(uname -r) linux-cloud-tools-$(uname -r) \
47+
libbpf-dev libffi-dev libelf-dev libxdp-dev \
48+
bats bc conntrack ethtool iperf3 jq socat tshark wireguard-tools
49+
- name: Build & Test
50+
run: |
51+
export BPF_CC=clang-15
52+
sudo cp /sys/kernel/btf/vmlinux /lib/modules/$(uname -r)/build
53+
make -j ${{ matrix.flags.flags }}
54+
sudo nft delete table filter # Docker's nftables rule drops IPv4 packets in tests
55+
sudo nft list ruleset
56+
sudo insmod out/mimic.ko
57+
sudo env MIMIC_TEST_EXTRA_ARGS="${{ matrix.flags.args }}" make test ${{ matrix.flags.flags }}
58+
- name: Upload captured packets
59+
uses: actions/upload-artifact@v4
60+
if: always()
61+
with:
62+
name: pcap-${{ matrix.flags.desc }}
63+
path: out/*.pcapng

0 commit comments

Comments
 (0)