From be873787edab7432df4dcdee0c2521d8a98af7c8 Mon Sep 17 00:00:00 2001 From: Gray Liang Date: Tue, 19 Dec 2023 19:40:30 +0800 Subject: [PATCH] ci: Test against various kernels on PR Closes: #368 --- .github/workflows/test.yml | 157 +++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..6ccaeccb7 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,157 @@ +name: Build and Test + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + + build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + + - name: Set up Go + uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe + with: + go-version: 1.21.0 + + - name: Generate and build + run: | + git submodule update --init + make GOFLAGS="-buildvcs=false" CC=clang + + - name: Store executable + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 + with: + name: dae + path: dae + + test: + runs-on: ubuntu-22.04 + name: Test + needs: build + strategy: + fail-fast: false + matrix: + kernel: [ '5.10-v0.3', '5.15-v0.3', '6.3-main', 'bpf-next-20231030.012704' ] + timeout-minutes: 10 + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + + - name: Retrieve stored skbdump executable + uses: actions/download-artifact@v3 + with: + name: dae + path: dae + + - name: Provision LVH VMs + uses: cilium/little-vm-helper@908ab1ff8a596a03cd5221a1f8602dc44c3f906d # v0.0.12 + with: + test-name: dae-test + image-version: ${{ matrix.kernel }} + host-mount: ./ + dns-resolver: '1.1.1.1' + install-dependencies: 'true' + cmd: | + chmod +x /host/dae/dae + + - name: Setup + uses: cilium/little-vm-helper@908ab1ff8a596a03cd5221a1f8602dc44c3f906d # v0.0.12 + with: + provision: 'false' + cmd: | + set -ex + + docker network create dae + docker run -td --name socks5 --privileged --network dae ubuntu:22.04 bash + docker run -td --name dae --privileged --network dae -v /host:/host ubuntu:22.04 bash + + - name: Setup socks5 server + uses: cilium/little-vm-helper@908ab1ff8a596a03cd5221a1f8602dc44c3f906d # v0.0.12 + with: + provision: 'false' + cmd: | + set -ex + + cat > ./danted.conf < ./conf.dae < proxy + fallback: direct + } + ! + + chmod 600 ./conf.dae + docker cp ./conf.dae dae:/etc/conf.dae + docker exec dae mount -t debugfs none /sys/kernel/debug/ + docker exec dae mount bpffs -t bpf /sys/fs/bpf + docker exec dae /host/dae/dae run -c /etc/conf.dae &> dae.log & + + docker exec dae apt update + docker exec dae apt install -y curl + docker exec dae curl 1.1.1.1 + docker exec dae curl 1.0.0.1 + + cat dae.log + + - name: Check + uses: cilium/little-vm-helper@908ab1ff8a596a03cd5221a1f8602dc44c3f906d # v0.0.12 + with: + provision: 'false' + cmd: | + set -ex + + docker exec socks5 cat /var/log/danted.log + docker exec socks5 cat /var/log/danted.log 2>&1 | grep -q 1.1.1.1 + docker exec socks5 cat /var/log/danted.log 2>&1 | grep 1.0.0.1 && false || true