diff --git a/.circleci/Dockerfile b/.circleci/Dockerfile new file mode 100644 index 000000000..d485a9249 --- /dev/null +++ b/.circleci/Dockerfile @@ -0,0 +1,34 @@ +# Use the JDK image to avoid installing it again. +FROM circleci/openjdk:latest + +# this will install the latest version of bazel - unfortunately it won't +# work, since they break backward compat on every single release. +# Proxy is currently requiring 0.7. +#RUN \ +# sudo sh -c 'echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" > /etc/apt/sources.list.d/bazel.list ' && \ +# curl https://storage.googleapis.com/bazel-apt/doc/apt-key.pub.gpg | sudo apt-key add - + + +RUN sudo apt-get update && \ + sudo apt-get -y install \ + wget software-properties-common make cmake python python-pip \ + zlib1g-dev bash-completion bc libtool automake zip time g++-6 gcc-6 \ + rsync + +# ~100M, depends on g++, zlib1g-dev, bash-completions +RUN curl -Lo /tmp/bazel.deb https://github.com/bazelbuild/bazel/releases/download/0.7.0/bazel_0.7.0-linux-x86_64.deb && \ + sudo dpkg -i /tmp/bazel.deb && rm /tmp/bazel.deb + + +# Instead of "apt-get -y install golang" +RUN cd /tmp && \ + wget https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-amd64.tar.gz && \ + sudo rm -rf /usr/local/go && \ + sudo tar -C /usr/local -xzf go1.9.2.linux-amd64.tar.gz && \ + sudo chown -R circleci /usr/local/go && \ + sudo ln -s /usr/local/go/bin/go /usr/local/bin + +RUN bazel version + +# For circleci unit test integration, "go test -v 2>&1 | go-junit-report > report.xml" +RUN go get -u github.com/jstemmer/go-junit-report diff --git a/.circleci/Makefile b/.circleci/Makefile new file mode 100644 index 000000000..9a0483819 --- /dev/null +++ b/.circleci/Makefile @@ -0,0 +1,21 @@ +HUB ?= +PROJECT ?= istio + +# Using same naming convention as istio/istio +VERSION ?= go1.9-bazel0.7 +IMG ?= ci + +# Build a local image, can be used for testing with circleci command line. +image: + docker build -t ${HUB}$(PROJECT)/${IMG}:$(VERSION) -f Dockerfile . + +# Push the image to docker +push: + docker push "${HUB}$(PROJECT)/${IMG}:$(VERSION)" + +# Run the image locally, as current user, for debug. +run: + cd $TOP && docker run -it --rm -u $(id -u) -it \ + -v $PWD:$TOP -w $TOP -e USER=$USER ${HUB}$(PROJECT)/${IMG}:$(VERSION) /bin/bash + +.PHONY: image push latest diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..f9343148a --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,43 @@ +version: 2 + +jobs: + build: + environment: + docker: + - image: istio/ci:go1.9-bazel0.7 + resource_class: xlarge + steps: + - checkout + - restore_cache: + keys: + - bazel-cache-{{ checksum "WORKSPACE" }} + - restore_cache: + keys: + - repo-cache-{{ checksum "WORKSPACE" }} + # To build docker containers or run tests in a docker + - setup_remote_docker + - run: make deb BAZEL_BUILD_ARGS="-j 4" + - run: make test_envoy + - save_cache: + key: repo-cache-{{ checksum "WORKSPACE" }} + paths: + - /home/circleci/.repo + - save_cache: + key: bazel-cache-{{ checksum "WORKSPACE" }} + paths: + - /home/circleci/.cache/bazel + - store_artifacts: + path: /home/circleci/project/bazel-bin/tools/deb/istio-proxy.deb + destination: /proxy/deb + - store_artifacts: + path: /home/circleci/project/bazel-bin/src/envoy/mixer/envoy + destination: /proxy/bin + + + + +workflows: + version: 2 + all: + jobs: + - build diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 000000000..452e99325 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,20 @@ +clone: + git: + image: plugins/git +pipeline: + build: + image: costinm/proxy-builder:0.4.4 + commands: + - id + - env + - sudo chown -R circleci /drone/src + - HOME=/drone/src make build_envoy + test: + image: costinm/proxy-builder:0.4.4 + commands: + - id + - env + - sudo chown -R circleci /drone/src + - HOME=/drone/src make test_envoy + + diff --git a/Makefile b/Makefile index 5ded8c575..dc33a0bc0 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,8 @@ ## See the License for the specific language governing permissions and ## limitations under the License. +TOP := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) + SHELL := /bin/bash LOCAL_ARTIFACTS_DIR ?= $(abspath artifacts) ARTIFACTS_DIR ?= $(LOCAL_ARTIFACTS_DIR) @@ -24,12 +26,19 @@ TAG ?= build: @bazel $(BAZEL_STARTUP_ARGS) build $(BAZEL_BUILD_ARGS) //... +# Build only envoy - fast +build_envoy: + bazel $(BAZEL_STARTUP_ARGS) build $(BAZEL_BUILD_ARGS) //src/envoy/mixer:envoy + clean: @bazel clean test: @bazel $(BAZEL_STARTUP_ARGS) test $(BAZEL_TEST_ARGS) //... +test_envoy: + @bazel $(BAZEL_STARTUP_ARGS) test $(BAZEL_TEST_ARGS) //src/envoy/mixer/... + check: @script/check-license-headers @script/check-style @@ -37,4 +46,8 @@ check: artifacts: build @script/push-debian.sh -c opt -p $(ARTIFACTS_DIR) +deb: + bazel build tools/deb:istio-proxy ${BAZEL_BUILD_ARGS} + + .PHONY: build clean test check artifacts