2020-06-16 23:14:39 +02:00
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 :
2022-03-25 09:12:16 +01:00
# Run on the latest minor release of Go 1.18:
go-version : ^1.18
2020-06-16 23:14:39 +02:00
id : go
- name : Check out code into the Go module directory
uses : actions/checkout@v2
2020-06-16 23:33:27 +02:00
- name : Share cache with other actions
uses : actions/cache@v2
with :
path : ~/go/pkg/mod
key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys : |
${{ runner.os }}-go-
2020-06-16 23:14:39 +02:00
- name : Ensure all files were formatted as per gofmt
run : |
2020-08-01 09:46:19 +02:00
[ "$(gofmt -l $(find . -name '*.go') 2>&1)" = "" ]
2020-06-16 23:14:39 +02:00
- 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 :
2022-03-25 09:12:16 +01:00
# Run on the latest minor release of Go 1.18:
go-version : ^1.18
2020-06-16 23:14:39 +02:00
id : go
- name : Check out code into the Go module directory
uses : actions/checkout@v2
2020-06-16 23:33:27 +02:00
- name : Share cache with other actions
uses : actions/cache@v2
with :
path : ~/go/pkg/mod
key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys : |
${{ runner.os }}-go-
2020-06-16 23:14:39 +02:00
- 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 :
2022-03-25 09:12:16 +01:00
# Run on the latest minor release of Go 1.18:
go-version : ^1.18
2020-06-16 23:14:39 +02:00
id : go
- name : Check out code into the Go module directory
uses : actions/checkout@v2
2020-06-16 23:33:27 +02:00
- name : Share cache with other actions
uses : actions/cache@v2
with :
path : ~/go/pkg/mod
key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys : |
${{ runner.os }}-go-
2020-06-16 23:14:39 +02:00
- 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 ]