Skip to content
Snippets Groups Projects
Commit 78ca72e9 authored by Serge Bazanski's avatar Serge Bazanski
Browse files

Build using Bazel

This change integrates the Bazel build system into bio-rd.

We also add support for:
  - running go dep from vendored libraries
  - running goveralls from vendored libraries
  - running bazel-based coverage from travis
parent 168cce5d
No related branches found
No related tags found
No related merge requests found
Showing
with 613 additions and 9 deletions
# This is from Bazel's former travis setup, to avoid blowing up the RAM usage.
startup --host_jvm_args=-Xmx2500m
startup --host_jvm_args=-Xms2500m
startup --batch
test --ram_utilization_factor=10
# This is so we understand failures better
build --verbose_failures
# Disable curses to get nicer log
build --curses=no
test --curses=no
# This is so we don't use sandboxed execution. Sandboxed execution
# runs stuff in a container, and since Travis already runs its script
# in a container (unless you require sudo in your .travis.yml) this
# fails to run tests.
build --spawn_strategy=standalone --genrule_strategy=standalone
test --test_strategy=standalone
# Below this line, .travis.yml will cat the default bazelrc.
# This is needed so Bazel starts with the base workspace in its
# package path.
......@@ -17,4 +17,8 @@
.idea/
*.iml
# 'go build' binary
bio-rd
# bazel directories
/bazel-*
7b14e4fc76bf85c4abf805833e99f560f124a3b96d56e0712c693e94e19d1376 bazel-0.14.1-installer-linux-x86_64.sh
language: go
go:
- "1.9.2"
- master
dist: trusty
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- wget
- pkg-config
- zip
- g++
- zlib1g-dev
- unzip
- python
before_install:
- mkdir -p $GOPATH/src/github.com/bio-routing
- ln -s $TRAVIS_BUILD_DIR $HOME/gopath/src/github.com/bio-routing/ || true
- go get github.com/mattn/goveralls
- wget https://github.com/bazelbuild/bazel/releases/download/0.14.1/bazel-0.14.1-installer-linux-x86_64.sh
- sha256sum -c .travis.bazel-0.14.1-installer-linux-x86_64.sh.sha256
- bash bazel-0.14.1-installer-linux-x86_64.sh --user
script:
- goveralls -v
- mkdir -p $HOME/gopath/src/github.com/bio-routing/
- ln -s $TRAVIS_BUILD_DIR $HOME/gopath/src/github.com/bio-routing/bio-rd || true
- cp .bazelrc.travis .bazelrc
- bazel coverage //...
- bazel build //vendor/github.com/mattn/goveralls
- bazel-bin/vendor/github.com/mattn/goveralls/linux_amd64_stripped/goveralls -coverprofile=$(find bazel-testlogs/ -name coverage.dat | paste -sd "," -)
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@bazel_gazelle//:def.bzl", "gazelle")
# gazelle:prefix github.com/bio-routing/bio-rd
gazelle(
name = "gazelle",
external = "vendored",
prefix = "github.com/bio-routing/bio-rd",
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "github.com/bio-routing/bio-rd",
visibility = ["//visibility:private"],
deps = [
"//config:go_default_library",
"//net:go_default_library",
"//protocols/bgp/server:go_default_library",
"//routingtable:go_default_library",
"//routingtable/filter:go_default_library",
"//routingtable/locRIB:go_default_library",
"//vendor/github.com/sirupsen/logrus:go_default_library",
],
)
go_binary(
name = "bio-rd",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
branch = "parse-constraints-with-dash-in-pre"
name = "github.com/Masterminds/semver"
packages = ["."]
revision = "a93e51b5a57ef416dac8bb02d11407b6f55d8929"
source = "https://github.com/carolynvs/semver.git"
[[projects]]
name = "github.com/Masterminds/vcs"
packages = ["."]
revision = "6f1c6d150500e452704e9863f68c2559f58616bf"
version = "v1.12.0"
[[projects]]
branch = "master"
name = "github.com/armon/go-radix"
packages = ["."]
revision = "1fca145dffbcaa8fe914309b1ec0cfc67500fe61"
[[projects]]
name = "github.com/boltdb/bolt"
packages = ["."]
revision = "2f1ce7a837dcb8da3ec595b1dac9d0632f0f99e8"
version = "v1.3.1"
[[projects]]
name = "github.com/davecgh/go-spew"
packages = ["spew"]
revision = "346938d642f2ec3594ed81d874461961cd0faa76"
version = "v1.1.0"
[[projects]]
name = "github.com/go-yaml/yaml"
packages = ["."]
revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183"
version = "v2.2.1"
[[projects]]
name = "github.com/golang/dep"
packages = [
".",
"gps",
"gps/internal/pb",
"gps/paths",
"gps/pkgtree",
"internal/fs"
]
revision = "37d9ea0ac16f0e0a05afc3b60e1ac8c364b6c329"
version = "v0.4.1"
[[projects]]
branch = "master"
name = "github.com/golang/protobuf"
packages = ["proto"]
revision = "9eb2c01ac278a5d89ce4b2be68fe4500955d8179"
[[projects]]
name = "github.com/jmank88/nuts"
packages = ["."]
revision = "8b28145dffc87104e66d074f62ea8080edfad7c8"
version = "v0.3.0"
[[projects]]
name = "github.com/mattn/goveralls"
packages = ["."]
revision = "b71a1e4855f87991aff01c2c833a75a07059c61c"
version = "v0.0.2"
[[projects]]
branch = "master"
name = "github.com/nightlyone/lockfile"
packages = ["."]
revision = "0ad87eef1443f64d3d8c50da647e2b1552851124"
[[projects]]
name = "github.com/pelletier/go-toml"
packages = ["."]
revision = "c01d1270ff3e442a8a57cddc1c92dc1138598194"
version = "v1.2.0"
[[projects]]
name = "github.com/pkg/errors"
packages = ["."]
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
version = "v0.8.0"
[[projects]]
name = "github.com/pmezard/go-difflib"
packages = ["difflib"]
revision = "792786c7400a136282c1664665ae0a8db921c6c2"
version = "v1.0.0"
[[projects]]
branch = "master"
name = "github.com/sdboyer/constext"
packages = ["."]
revision = "836a144573533ea4da4e6929c235fd348aed1c80"
[[projects]]
name = "github.com/sirupsen/logrus"
packages = ["."]
......@@ -37,6 +123,18 @@
packages = ["ssh/terminal"]
revision = "b0697eccbea9adec5b7ba8008f4c33d98d733388"
[[projects]]
branch = "master"
name = "golang.org/x/net"
packages = ["context"]
revision = "afe8f62b1d6bbd81f31868121a50b06d8188e1f9"
[[projects]]
branch = "master"
name = "golang.org/x/sync"
packages = ["errgroup"]
revision = "1d60e4601c6fd243af51cc01ddf169918a5407ca"
[[projects]]
branch = "master"
name = "golang.org/x/sys"
......@@ -46,9 +144,15 @@
]
revision = "bb9c189858d91f42db229b04d45a4c3d23a7662a"
[[projects]]
branch = "master"
name = "golang.org/x/tools"
packages = ["cover"]
revision = "25b95b48224cce18163c7d49dcfb89a2d5ecd209"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "073c66875ae5e826b99de44a296f0ad013f1ba03c3b3b5e6fe6fe812fb0b6722"
inputs-digest = "54ddfce69bb4724edb07fa628b5a6ae7a4fb1af7ba00b2a64fe043d967d2fdff"
solver-name = "gps-cdcl"
solver-version = 1
......@@ -19,9 +19,15 @@
# name = "github.com/x/y"
# version = "2.4.0"
required = ["github.com/golang/dep", "github.com/mattn/goveralls", "github.com/go-yaml/yaml"]
[prune]
go-tests = true
unused-packages = true
[[prune.project]]
name = "github.com/golang/dep"
unused-packages = false
[[constraint]]
name = "github.com/sirupsen/logrus"
......
......@@ -3,3 +3,44 @@
[![Build Status](https://travis-ci.org/bio-routing/bio-rd.svg?branch=master)](https://travis-ci.org/bio-routing/bio-rd)
[![Coverage Status](https://coveralls.io/repos/bio-routing/bio-rd/badge.svg?branch=master&service=github)](https://coveralls.io/github/bio-routing/bio-rd?branch=master)
[![Go ReportCard](http://goreportcard.com/badge/bio-routing/bio-rd)](http://goreportcard.com/report/bio-routing/bio-rd)
Building
========
We use [Bazel](https://bazel.io) to build bio-rd.
Build
-----
bazel build //:bio-rd
bazel-bin/linux_amd64_stripped/bio-rd -arguments go -here
or
bazel run //:bio-rd -- -arguments go -here
Run Tests
---------
bazel test //...
Update Bazel BUILD files
------------------------
To regenerate BUILD files (for both the project and vendored libraries), you will need to run the following:
bazel run //:gazelle -- update
Be sure to commit the changes.
Update vendor/dependencies
---------------------------
After updating Gopkg.toml, run
bazel build //vendor/github.com/golang/dep/cmd/dep
bazel-bin/vendor/github.com/golang/dep/cmd/dep/linux_amd64_stripped/dep
# hack: dep of dep gives us these, and it breaks gazelle
rm -rf vendor/github.com/golang/dep/cmd/dep/testdata
rm -rf vendor/github.com/golang/dep/internal/fs/testdata/symlinks/dir-symlink
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Bazel Go rules
http_archive(
name = "io_bazel_rules_go",
urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.12.1/rules_go-0.12.1.tar.gz"],
sha256 = "8b68d0630d63d95dacc0016c3bb4b76154fe34fca93efd65d1c366de3fcb4294",
)
# Bazel Gazelle integration
http_archive(
name = "bazel_gazelle",
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/0.12.0/bazel-gazelle-0.12.0.tar.gz"],
sha256 = "ddedc7aaeb61f2654d7d7d4fd7940052ea992ccdb031b8f9797ed143ac7e8d43",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
gazelle_dependencies()
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"peer.go",
"server.go",
],
importpath = "github.com/bio-routing/bio-rd/config",
visibility = ["//visibility:public"],
deps = [
"//routingtable:go_default_library",
"//routingtable/filter:go_default_library",
"//vendor/github.com/taktv6/tflow2/convert:go_default_library",
],
)
go_test(
name = "go_default_test",
srcs = ["server_test.go"],
embed = [":go_default_library"],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"helper.go",
"prefix.go",
],
importpath = "github.com/bio-routing/bio-rd/net",
visibility = ["//visibility:public"],
deps = ["//vendor/github.com/taktv6/tflow2/convert:go_default_library"],
)
go_test(
name = "go_default_test",
srcs = [
"helper_test.go",
"prefix_test.go",
],
embed = [":go_default_library"],
deps = ["//vendor/github.com/stretchr/testify/assert:go_default_library"],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"bgp.go",
"community.go",
"decoder.go",
"encoder.go",
"large_community.go",
"nlri.go",
"parameters.go",
"path_attribute_flags.go",
"path_attributes.go",
],
importpath = "github.com/bio-routing/bio-rd/protocols/bgp/packet",
visibility = ["//visibility:public"],
deps = ["//vendor/github.com/taktv6/tflow2/convert:go_default_library"],
)
go_test(
name = "go_default_test",
srcs = [
"community_test.go",
"decoder_test.go",
"encoder_test.go",
"large_community_benchmark_test.go",
"large_community_test.go",
"nlri_test.go",
"path_attributes_test.go",
],
embed = [":go_default_library"],
deps = [
"//net:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/github.com/taktv6/tflow2/convert:go_default_library",
],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"fsm2.go",
"fsm_active.go",
"fsm_cease.go",
"fsm_connect.go",
"fsm_established.go",
"fsm_idle.go",
"fsm_manager.go",
"fsm_open_confirm.go",
"fsm_open_sent.go",
"peer.go",
"server.go",
"sockopt.go",
"tcplistener.go",
"update_helper.go",
"update_sender.go",
"update_sender_add_path.go",
"util.go",
"withdraw.go",
],
importpath = "github.com/bio-routing/bio-rd/protocols/bgp/server",
visibility = ["//visibility:public"],
deps = [
"//config:go_default_library",
"//net:go_default_library",
"//protocols/bgp/packet:go_default_library",
"//route:go_default_library",
"//routingtable:go_default_library",
"//routingtable/adjRIBIn:go_default_library",
"//routingtable/adjRIBOut:go_default_library",
"//routingtable/adjRIBOutAddPath:go_default_library",
"//routingtable/filter:go_default_library",
"//vendor/github.com/sirupsen/logrus:go_default_library",
],
)
go_test(
name = "go_default_test",
srcs = [
"update_helper_test.go",
"withdraw_test.go",
],
embed = [":go_default_library"],
deps = [
"//net:go_default_library",
"//protocols/bgp/packet:go_default_library",
"//route:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"bgp.go",
"bgp_path_manager.go",
"path.go",
"route.go",
"static.go",
],
importpath = "github.com/bio-routing/bio-rd/route",
visibility = ["//visibility:public"],
deps = [
"//net:go_default_library",
"//vendor/github.com/taktv6/tflow2/convert:go_default_library",
],
)
go_test(
name = "go_default_test",
srcs = [
"path_test.go",
"route_test.go",
],
embed = [":go_default_library"],
deps = [
"//net:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"client_interface.go",
"client_manager.go",
"neighbor.go",
"rib_interface.go",
"table.go",
"trie.go",
"update_helper.go",
],
importpath = "github.com/bio-routing/bio-rd/routingtable",
visibility = ["//visibility:public"],
deps = [
"//net:go_default_library",
"//protocols/bgp/packet:go_default_library",
"//route:go_default_library",
"//vendor/github.com/sirupsen/logrus:go_default_library",
],
)
go_test(
name = "go_default_test",
srcs = [
"client_manager_test.go",
"table_test.go",
"trie_test.go",
"update_helper_test.go",
],
embed = [":go_default_library"],
deps = [
"//net:go_default_library",
"//route:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = ["adj_rib_in.go"],
importpath = "github.com/bio-routing/bio-rd/routingtable/adjRIBIn",
visibility = ["//visibility:public"],
deps = [
"//net:go_default_library",
"//route:go_default_library",
"//routingtable:go_default_library",
"//vendor/github.com/sirupsen/logrus:go_default_library",
],
)
go_test(
name = "go_default_test",
srcs = ["adj_rib_in_test.go"],
embed = [":go_default_library"],
deps = [
"//net:go_default_library",
"//route:go_default_library",
"//routingtable:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["adj_rib_out.go"],
importpath = "github.com/bio-routing/bio-rd/routingtable/adjRIBOut",
visibility = ["//visibility:public"],
deps = [
"//net:go_default_library",
"//route:go_default_library",
"//routingtable:go_default_library",
"//vendor/github.com/sirupsen/logrus:go_default_library",
],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"adj_rib_out_add_path.go",
"path_id_manager.go",
],
importpath = "github.com/bio-routing/bio-rd/routingtable/adjRIBOutAddPath",
visibility = ["//visibility:public"],
deps = [
"//net:go_default_library",
"//route:go_default_library",
"//routingtable:go_default_library",
"//vendor/github.com/sirupsen/logrus:go_default_library",
],
)
go_test(
name = "go_default_test",
srcs = ["path_id_manager_test.go"],
embed = [":go_default_library"],
deps = ["//vendor/github.com/stretchr/testify/assert:go_default_library"],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"community_filter.go",
"filter.go",
"helper.go",
"large_community_filter.go",
"prefix_list.go",
"prefix_matcher.go",
"route_filter.go",
"term.go",
"term_condition.go",
],
importpath = "github.com/bio-routing/bio-rd/routingtable/filter",
visibility = ["//visibility:public"],
deps = [
"//net:go_default_library",
"//protocols/bgp/packet:go_default_library",
"//route:go_default_library",
"//routingtable:go_default_library",
"//routingtable/filter/actions:go_default_library",
],
)
go_test(
name = "go_default_test",
srcs = [
"filter_test.go",
"helper_test.go",
"route_filter_test.go",
"term_condition_test.go",
"term_test.go",
],
embed = [":go_default_library"],
deps = [
"//net:go_default_library",
"//protocols/bgp/packet:go_default_library",
"//route:go_default_library",
"//routingtable:go_default_library",
"//routingtable/filter/actions:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"accept_action.go",
"add_community_action.go",
"add_large_community_action.go",
"as_path_prepend_action.go",
"filter_action.go",
"reject_action.go",
"set_local_pref_action.go",
"set_nexthop_action.go",
],
importpath = "github.com/bio-routing/bio-rd/routingtable/filter/actions",
visibility = ["//visibility:public"],
deps = [
"//net:go_default_library",
"//protocols/bgp/packet:go_default_library",
"//route:go_default_library",
],
)
go_test(
name = "go_default_test",
srcs = [
"add_community_action_test.go",
"add_large_community_action_test.go",
"as_path_prepend_action_test.go",
"set_local_pref_action_test.go",
"set_nexthop_action_test.go",
],
embed = [":go_default_library"],
deps = [
"//net:go_default_library",
"//protocols/bgp/packet:go_default_library",
"//route:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
],
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment