From 4a85c51b9f14d0c565c28de5b98c43e7ba984b74 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 14 Jul 2018 15:17:48 +0200 Subject: [PATCH] add travis config --- .travis.yml | 30 ++++++++++++++++++++++++++++++ travis/Dockerfile | 18 ++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .travis.yml create mode 100644 travis/Dockerfile diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..936162e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,30 @@ +# Use the (faster) container-based infrastructure, see also +# http://docs.travis-ci.com/user/workers/container-based-infrastructure/ +sudo: required +dist: trusty +services: + - docker + +language: go +go: + - "1.10" + +install: + - go get -t -v -d ./... + # TODO: get rid of this once https://github.com/google/gopacket/pull/470 is merged + - (cd $GOPATH/src/github.com/google/gopacket && wget -qO- https://patch-diff.githubusercontent.com/raw/google/gopacket/pull/470.patch | patch -p1) + +script: + # Check whether files are syntactically correct. + - "gofmt -l $(find . -name '*.go' | tr '\\n' ' ') >/dev/null" + # Check whether files were not gofmt'ed. + - "gosrc=$(find . -name '*.go' | tr '\\n' ' '); [ $(gofmt -l $gosrc 2>&- | wc -l) -eq 0 ] || (echo 'gofmt was not run on these files:'; gofmt -l $gosrc 2>&-; false)" + # TODO: remove the || true suffix once vet errors are fixed + - go tool vet . || true + - go build ./cmd/... + - go test -v -race ./internal/... + - docker build --pull --no-cache --rm -t=router7 -f travis/Dockerfile . + - sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 + - sudo service docker restart + # NOTE: this must be the last command because of the travis_terminate usage: + - exit=0; for pkg in $(go list ./integration/...); do go test -c $pkg && docker run --privileged --net=host -v $PWD:/usr/src:ro router7 /bin/sh -c "./$(basename $pkg).test -test.v" || exit=1; done; [ $exit = 0 ] || travis_terminate 1 diff --git a/travis/Dockerfile b/travis/Dockerfile new file mode 100644 index 0000000..48955ed --- /dev/null +++ b/travis/Dockerfile @@ -0,0 +1,18 @@ +# vim:ft=Dockerfile +FROM debian:sid + +RUN echo force-unsafe-io > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup +# Paper over occasional network flakiness of some mirrors. +RUN echo 'APT::Acquire::Retries "5";' > /etc/apt/apt.conf.d/80retry + +# NOTE: I tried exclusively using gce_debian_mirror.storage.googleapis.com +# instead of httpredir.debian.org, but the results (Fetched 123 MB in 36s (3357 +# kB/s)) are not any better than httpredir.debian.org (Fetched 123 MB in 34s +# (3608 kB/s)). Hence, let’s stick with httpredir.debian.org (default) for now. + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + dnsmasq ndisc6 nftables dnsutils strace && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /usr/src