Skip to content

Add action pwru-test and more CI tests #331

Add action pwru-test and more CI tests

Add action pwru-test and more CI tests #331

Workflow file for this run

name: Build and Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe
with:
go-version: 1.20.5
- name: Check module vendoring
run: |
go mod tidy
go mod vendor
go mod verify
test -z "$(git status --porcelain)" || (echo "please run 'go mod tidy && go mod vendor', and submit your changes"; exit 1)
- name: Generate and build
run: |
make release
tar xfv release/pwru-linux-amd64.tar.gz
- name: Store executable
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
with:
name: pwru
path: pwru
test:
runs-on: ubuntu-latest-4cores-16gb
name: Test
needs: build
strategy:
fail-fast: false
matrix:
kernel: [ '5.4-v0.3', '5.15-v0.3', '6.3-main', 'bpf-next-main' ]
timeout-minutes: 10
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
- name: Retrieve stored pwru executable
uses: actions/download-artifact@v3
with:
name: pwru
path: pwru
- name: Setup PWRU
uses: cilium/little-vm-helper@908ab1ff8a596a03cd5221a1f8602dc44c3f906d
with:
test-name: ${{ inputs.test-name }}
image-version: ${{ matrix.kernel }}
install-dependencies: 'true'
dns-resolver: '1.1.1.1'
host-mount: ./
cmd: |
chmod +x /host/pwru/pwru
- name: Test basic IPv4
uses: ./.github/actions/pwru-test
with:
test-name: basic-ipv4
pwru-filter-flags: 'dst host 1.0.0.1 and port 8080'
traffic-setup: |
iptables -I OUTPUT 1 -m tcp --proto tcp --dst 1.0.0.1/32 --dport 8080 -j DROP
curl -vvv -sS --fail --connect-timeout "1" -o /dev/null http://1.0.0.1:8080 || true
expected-output-pattern: 'SKB_DROP_REASON_NETFILTER_DROP.*1.0.0.1:8080'
- name: Test basic IPv6
uses: ./.github/actions/pwru-test
with:
test-name: basic-ipv6
pwru-filter-flags: 'dst host 2606:4700:4700::1001 and port 8080'
traffic-setup: |
ip6tables -I OUTPUT 1 -m tcp --proto tcp --dst 2606:4700:4700::1001 --dport 8080 -j DROP
curl -vvv -sS --fail --connect-timeout "1" -o /dev/null http://[2606:4700:4700::1001]:8080 || true
expected-output-pattern: 'SKB_DROP_REASON_NETFILTER_DROP.*[2606:4700:4700::1001]:8080'
- name: Fetch artifacts
if: ${{ !success() }}
uses: cilium/little-vm-helper@908ab1ff8a596a03cd5221a1f8602dc44c3f906d
with:
provision: 'false'
cmd: |
cat /tmp/pwru-*.status || true
cat /tmp/pwru-*.ready || true
cat /tmp/pwru-*.log || true