| 1 |
--- |
| 2 |
name: test |
| 3 |
|
| 4 |
on: |
| 5 |
pull_request: {} |
| 6 |
|
| 7 |
env: |
| 8 |
LINUX_ARCHES: "amd64 386 arm arm64 s390x mips64le ppc64le riscv64" |
| 9 |
|
| 10 |
jobs: |
| 11 |
lint: |
| 12 |
name: Lint |
| 13 |
runs-on: ubuntu-latest |
| 14 |
steps: |
| 15 |
- uses: actions/checkout@v4 |
| 16 |
- name: setup go |
| 17 |
uses: actions/setup-go@v5 |
| 18 |
with: |
| 19 |
go-version-file: .github/go-version |
| 20 |
- uses: ibiqlik/action-yamllint@v3 |
| 21 |
with: |
| 22 |
format: auto |
| 23 |
- uses: golangci/golangci-lint-action@v9 |
| 24 |
with: |
| 25 |
version: v2.3.0 |
| 26 |
args: -v |
| 27 |
verify-vendor: |
| 28 |
name: Verify vendor directory |
| 29 |
runs-on: ubuntu-latest |
| 30 |
steps: |
| 31 |
- uses: actions/checkout@v4 |
| 32 |
- name: Install Go |
| 33 |
uses: actions/setup-go@v5 |
| 34 |
with: |
| 35 |
go-version-file: .github/go-version |
| 36 |
- name: Check module vendoring |
| 37 |
run: | |
| 38 |
go mod tidy |
| 39 |
go mod vendor |
| 40 |
test -z "$(git status --porcelain)" || (echo "please run 'go mod tidy && go mod vendor', and submit your changes"; exit 1) |
| 41 |
build: |
| 42 |
name: Build all linux architectures |
| 43 |
needs: lint |
| 44 |
runs-on: ubuntu-latest |
| 45 |
steps: |
| 46 |
- uses: actions/checkout@v4 |
| 47 |
- name: setup go |
| 48 |
uses: actions/setup-go@v5 |
| 49 |
with: |
| 50 |
go-version-file: .github/go-version |
| 51 |
- name: Build on all supported architectures |
| 52 |
run: | |
| 53 |
set -e |
| 54 |
for arch in ${LINUX_ARCHES}; do |
| 55 |
echo "Building for arch $arch" |
| 56 |
GOARCH=$arch ./build_linux.sh |
| 57 |
rm bin/* |
| 58 |
done |
| 59 |
test-linux: |
| 60 |
name: Run tests on Linux amd64 |
| 61 |
needs: build |
| 62 |
runs-on: ubuntu-latest |
| 63 |
steps: |
| 64 |
- name: Install kernel module |
| 65 |
run: | |
| 66 |
sudo apt-get update |
| 67 |
sudo apt-get install linux-modules-extra-$(uname -r) |
| 68 |
- name: Install nftables |
| 69 |
|
| 70 |
run: | |
| 71 |
sudo apt-get install nftables |
| 72 |
sudo modprobe br-netfilter |
| 73 |
- name: Install dnsmasq(dhcp server) |
| 74 |
run: | |
| 75 |
sudo apt-get install dnsmasq |
| 76 |
sudo systemctl disable --now dnsmasq |
| 77 |
- uses: actions/checkout@v4 |
| 78 |
- name: setup go |
| 79 |
uses: actions/setup-go@v5 |
| 80 |
with: |
| 81 |
go-version-file: .github/go-version |
| 82 |
- name: Set up Go for root |
| 83 |
run: | |
| 84 |
sudo ln -sf `which go` `sudo which go` || true |
| 85 |
sudo go version |
| 86 |
|
| 87 |
- name: Install test binaries |
| 88 |
run: | |
| 89 |
go install github.com/containernetworking/cni/cnitool@latest |
| 90 |
go install github.com/mattn/goveralls@latest |
| 91 |
go install github.com/modocache/gover@latest |
| 92 |
|
| 93 |
- name: test |
| 94 |
run: PATH=$PATH:$(go env GOPATH)/bin COVERALLS=1 ./test_linux.sh |
| 95 |
|
| 96 |
- name: Send coverage to coveralls |
| 97 |
env: |
| 98 |
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 99 |
run: | |
| 100 |
PATH=$PATH:$(go env GOPATH)/bin |
| 101 |
gover |
| 102 |
goveralls -coverprofile=gover.coverprofile -service=github |
| 103 |
test-win: |
| 104 |
name: Build and run tests on Windows |
| 105 |
needs: build |
| 106 |
runs-on: windows-latest |
| 107 |
steps: |
| 108 |
- uses: actions/checkout@v4 |
| 109 |
- name: setup go |
| 110 |
uses: actions/setup-go@v5 |
| 111 |
with: |
| 112 |
go-version-file: .github/go-version |
| 113 |
- name: test |
| 114 |
run: bash ./test_windows.sh |