Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ install:
matrix:
fast_finish: true
env:
- TEST_TYPE=debug
- TEST_TYPE=bazel.release
- TEST_TYPE=bazel.asan
- TEST_TYPE=bazel.coverage
- TEST_TYPE=bazel.debug
- TEST_TYPE=normal
- TEST_TYPE=asan
- TEST_TYPE=check_format
- TEST_TYPE=docs
script: ./ci/ci_steps.sh

Expand Down
7 changes: 0 additions & 7 deletions Makefile

This file was deleted.

3 changes: 3 additions & 0 deletions bazel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ report is available in `generated/coverage/coverage.html`.
Envoy proper. To remove the artifacts for the external dependencies run
`bazel clean --expunge`.

If something goes really wrong and none of the above work to resolve a stale build issue, you can
always remove your Bazel cache completely. It is likely located in `~/.cache/bazel`.

# Adding or maintaining Envoy build rules

See the [developer guide for writing Envoy Bazel rules](DEVELOPER.md).
Expand Down
2 changes: 1 addition & 1 deletion bazel/cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def _crosstool_content(repository_ctx, cc, cpu_value, darwin):
"builtin_sysroot": "",
"compiler": _get_env_var(repository_ctx, "BAZEL_COMPILER", "compiler", False),
"host_system_name": _get_env_var(repository_ctx, "BAZEL_HOST_SYSTEM", "local", False),
"needsPic": True,
"needsPic": False,
"supports_gold_linker": supports_gold_linker,
"supports_incremental_linker": False,
"supports_fission": False,
Expand Down
9 changes: 5 additions & 4 deletions bazel/envoy_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def envoy_package():
native.package(default_visibility = ["//visibility:public"])

# Compute the final copts based on various options.
def envoy_copts(repository):
def envoy_copts(repository, test = False):
return [
# TODO(htuch): Remove this when Bazel bringup is done.
"-DBAZEL_BRINGUP",
Expand All @@ -17,7 +17,7 @@ def envoy_copts(repository):
"-std=c++0x",
] + select({
# Bazel adds an implicit -DNDEBUG for opt.
repository + "//bazel:opt_build": ["-ggdb3"],
repository + "//bazel:opt_build": [] if test else ["-ggdb3"],
repository + "//bazel:fastbuild_build": [],
repository + "//bazel:dbg_build": ["-ggdb3"],
}) + select({
Expand Down Expand Up @@ -166,7 +166,7 @@ def envoy_cc_test(name,
)
native.cc_test(
name = name,
copts = envoy_copts(repository),
copts = envoy_copts(repository, test = True),
# TODO(mattklein123): It's not great that we universally link against the following libs.
# In particular, -latomic is not needed on all platforms. Make this more granular.
linkopts = ["-pthread", "-latomic"],
Expand Down Expand Up @@ -195,7 +195,7 @@ def envoy_cc_test_library(name,
srcs = srcs,
hdrs = hdrs,
data = data,
copts = envoy_copts(repository),
copts = envoy_copts(repository, test = True),
testonly = 1,
deps = deps + [envoy_external_dep_path(dep) for dep in external_deps] + [
envoy_external_dep_path('googletest'),
Expand Down Expand Up @@ -263,6 +263,7 @@ def envoy_proto_library(name, srcs = [], deps = []):
default_runtime = "//external:protobuf",
protoc = "//external:protoc",
deps = deps,
linkstatic = 1,
)
# We can't use include_prefix directly in cc_proto_library, since it
# confuses protoc. Instead, we create a shim cc_library that performs the
Expand Down
2 changes: 1 addition & 1 deletion ci/Dockerfile-envoy-image
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:14.04

ADD build_normal/source/exe/envoy /usr/local/bin/envoy
ADD build_release/envoy /usr/local/bin/envoy
RUN apt-get update && apt-get install -y \
build-essential
RUN strip /usr/local/bin/envoy
Expand Down
71 changes: 14 additions & 57 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,71 +13,28 @@ binary built from the latest tip of master that passed tests.

## Alpine envoy image

Minimal images based on alpine Linux allow for quicker deployment of Envoy. Two alpine based images are built,
Minimal images based on Alpine Linux allow for quicker deployment of Envoy. Two Alpine based images are built,
one with an Envoy binary with debug (`lyft/envoy-alpine-debug`) symbols and one stripped of them (`lyft/envoy-alpine`).
Both images are pushed with two different tags: `<hash>` and `latest`. Parallel to the Ubuntu images above, `<hash>` corresponds to the
master commit at which the binary was compiled, and `latest` corresponds to a binary built from the latest tip of master that passed tests.

# Building a debug image
An example basic invocation to build a debug image and run all tests is:
# Building and running tests as a developer

```bash
docker pull lyft/envoy-build:latest && docker run -t -i -u $(id -u):$(id -g) -v <BUILD_DIR>:/build -v <SOURCE_DIR>:/source lyft/envoy-build:latest /bin/bash -c "cd /source && ci/do_ci.sh debug"
```

On OSX using the command below may work better. Unlike on Linux, users are not
synced between the container and OS. Additionally, the bind mount will not
create artifacts with the same ownership as in the container ([read more about
osxfs][osxfs]).

```bash
docker pull lyft/envoy-build:latest && docker run -t -i -u root:root -v <BUILD_DIR>:/build -v <SOURCE_DIR>:/source lyft/envoy-build:latest /bin/bash -c "cd /source && ci/do_ci.sh debug"
```

This bind mounts `<SOURCE_DIR>`, which allows for changes on the local
filesystem to be consumed and outputs build artifacts in `<SOURCE_DIR>/build`.
The static Envoy binary can be found in `<SOURCE_DIR>/build_debug/source/exe/envoy`.

The `do_ci.sh` targets are:

* `asan` &mdash; build and run tests with [AddressSanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer).
* `coverage` &mdash; build and run tests, generating coverage information in `<SOURCE_DIR>/build_coverage/coverage.html`.
* `debug` &mdash; build debug binary and run tests.
* `bazel.coverage` &mdash; build and run tests with Bazel, generating coverage information in `<SOURCE_DIR>/generated/coverage/coverage.html`.
* `bazel.debug` &mdash; build debug binary and run tests with Bazel.
* `fix_format`&mdash; run `clang-format` 3.6 on entire source tree.
* `normal` &mdash; build unstripped optimized binary and run tests .
* `server_only` &mdash; build stripped optimized binary only.

A convenient shell function to define is:
An example basic invocation to build the Envoy static binary (using the Bazel `fastbuild` type) is:

```bash
run_envoy_docker() { docker pull lyft/envoy-build:latest && docker run -t -i -u $(id -u):$(id -g) -v /tmp/envoy-docker-build:/build -v $PWD:/source lyft/envoy-build:latest /bin/bash -c "cd /source && $*";}
./ci/run_envoy_docker.sh './ci/do_ci.sh bazel.fastbuild'
```

Or on OSX.

```bash
run_envoy_docker() { docker pull lyft/envoy-build:latest && docker run -t -i -u root:root -v /tmp/envoy-docker-build:/build -v $PWD:/source lyft/envoy-build:latest /bin/bash -c "cd /source && $*";}
```

This then allows for a simple invocation of `run_envoy_docker './ci/do_ci.sh debug'` from the
Envoy source tree.

## Advanced developer features

* Any parameters following the `do_ci.sh` target are passed in as command-line
arguments to the `envoy-test` binary during unit test execution. This allows
for [GTest](https://github.com/google/googletest) flags to be passed, e.g.
`run_envoy_docker './ci/do_ci.sh debug --gtest_filter="*Dns*"'`.

* A `UNIT_TEST_ONLY` environment variable is available to control test execution to limit testing to
just unit tests, e.g. `run_envoy_docker 'UNIT_TEST_ONLY=1 ./ci/do_ci.sh debug --gtest_filter="*Dns*"'`.

* A `RUN_TEST_UNDER` environment variable is available to specify an executable to run the tests
under. For example, to run a subset of tests under `gdb`: `run_envoy_docker 'RUN_TEST_UNDER="gdb --args" UNIT_TEST_ONLY=1 ./ci/do_ci.sh debug --gtest_filter="*Dns*"'`.

* A `SKIP_CHECK_FORMAT` environment variable is available to skip `clang-format` checks while developing locally, e.g. `run_envoy_docker 'SKIP_CHECK_FORMAT=1 ./ci/do_ci.sh debug'`.
The output artifacts can be found in `/build/envoy/bazel-bin/source/exe/envoy-static` in the
container.

The `./ci/run_envoy_docker.sh './ci/do_ci.sh <TARGET>'` targets are:

[osxfs]: https://docs.docker.com/docker-for-mac/osxfs/
* `bazel.asan` &mdash; build and run tests under `-c dbg --config=asan`.
* `bazel.fastbuild` &mdash; build Envoy static binary under `-c fastbuild`.
* `bazel.fastbuild.test` &mdash; build and run tests under `-c fastbuild`.
* `bazel.release` &mdash; build Envoy static binary and run tests under `-c opt`.
* `bazel.coverage` &mdash; build and run tests under `-c dbg`, generating coverage information in `<SOURCE_DIR>/generated/coverage/coverage.html`.
* `check_format`&mdash; run `clang-format` 3.6 and `buildifier` on entire source tree.
* `fix_format`&mdash; run and enforce `clang-format` 3.6 and `buildifier` on entire source tree.
11 changes: 6 additions & 5 deletions ci/build_alpine_container/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
PHONY: all

ENVOY_TAG?="latest"
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
ENVOY_TAG ?= "latest"
ENVOY_BUILD_DIR ?= "/tmp/envoy-docker-build"
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

all: binary container test

Expand All @@ -11,9 +12,9 @@ binary:
mkdir -p ./bin/stripped
mkdir -p ./bin/debug
mkdir -p ./bin/configs
docker run -t -i --name build-envoy-alpine-ct -v ${ROOT_DIR}/../../:/source lyft/envoy-build:latest /bin/bash -c \
"set -x && cd /source && /source/ci/do_ci.sh server_only && \
cp /source/build_normal/source/exe/envoy /tmp/ && \
docker run -t -i --name build-envoy-alpine-ct -v ${ROOT_DIR}/../../:/source -v $(ENVOY_BUILD_DIR):/build lyft/envoy-build:latest /bin/bash -c \
"set -x && cd /source &&
cp /build/envoy/source/exe/envoy /tmp/envoy && \
cd /tmp/ && strip envoy && \
mv /tmp/envoy /source/ci/build_alpine_container/bin/stripped/ && \
cp /source/build_normal/source/exe/envoy /source/ci/build_alpine_container/bin/debug/ && \
Expand Down
17 changes: 0 additions & 17 deletions ci/build_alpine_container/README.md

This file was deleted.

169 changes: 0 additions & 169 deletions ci/build_amazon_linux/build_amazon_linux.sh

This file was deleted.

Loading