From 9c7e626f7d4d6cd76b0829e7c5477ce4e4637207 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 16 Jun 2020 23:14:39 +0200 Subject: [PATCH] switch from travis to GitHub actions --- .github/workflows/go.yml | 78 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 28 --------------- 2 files changed, 78 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/go.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..0ec6246 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,78 @@ +name: GitHub Actions CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + build: + name: build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + # Run on the latest minor release of Go 1.14: + go-version: ^1.14 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Ensure all files were formatted as per gofmt + run: | + gofmt -l $(find . -name '*.go') >/dev/null + + - name: Go Vet + run: | + go vet + + - name: Build + run: | + go build -v ./cmd/... + + test: + name: test + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + # Run on the latest minor release of Go 1.14: + go-version: ^1.14 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Test + run: | + go test -v -race ./internal/... + + integrationtest: + name: integrationtest + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + # Run on the latest minor release of Go 1.14: + go-version: ^1.14 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Build Docker container with the tools our tests require + run: | + docker build --pull --no-cache --rm -t=router7 -f travis/Dockerfile . + + - name: Run tests in Docker container + run: | + 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 ] diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 455d1ae..0000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -# Use the (faster) container-based infrastructure, see also -# http://docs.travis-ci.com/user/workers/container-based-infrastructure/ -sudo: required -dist: xenial -services: - - docker - -language: go -go: - - "1.14" - -install: - - go get -t -v -d ./... - -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 vet . || true - - sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 - - go build ./cmd/... - - go test -v -race ./internal/... - - docker build --pull --no-cache --rm -t=router7 -f travis/Dockerfile . - - 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