mirror of https://github.com/linkerd/linkerd2.git
314 lines
12 KiB
YAML
314 lines
12 KiB
YAML
---
|
|
dist: xenial
|
|
sudo: false
|
|
|
|
# We do not test pushes to branches, since they are redundant with the pull_request build
|
|
# for each branch. Take that, Big CI!
|
|
branches:
|
|
only:
|
|
- master
|
|
- /^(edge|stable)-\d+\.\d+\.[\w-]+$/ # build version tags
|
|
|
|
stages:
|
|
- name: setup
|
|
- name: test
|
|
- name: docker-deploy
|
|
if: type != pull_request
|
|
- name: integration-test
|
|
if: type != pull_request
|
|
|
|
jobs:
|
|
include:
|
|
# TODO: If any of the jobs in the setup stage fail, clean up all the kind clusters.
|
|
- stage: setup
|
|
name: "Validate go deps"
|
|
language: generic
|
|
script:
|
|
- |
|
|
(
|
|
. bin/_tag.sh
|
|
for f in $( grep -lR --include=Dockerfile\* go-deps: . ) ; do
|
|
validate_go_deps_tag $f
|
|
done
|
|
)
|
|
|
|
- name: "Remote docker build"
|
|
if: fork = false
|
|
language: generic
|
|
cache:
|
|
directories:
|
|
- target/bin
|
|
addons: &addons_ssh_known_hosts
|
|
ssh_known_hosts:
|
|
# Same value as $REMOTE_DOCKER.
|
|
secure: "H44Np1YIvtnGc1PGE72AVS65inamSEimxNGZej3l0au8FbM/z6v1nkEVRQ2N72MXK9cdkjvNdjyYw21KA8vR74uDUpDiTh1duDNZq3sQCwcf4/v6sDDSjA9ZgN7YfrydGbBagCEdL9p1Y22X4lFggXHSi2yYeuK3m2HE+vtaHCcNQb+z1liccD5KkScaMAd8zorwf/dRqSjuJmbnBkNyw6IhSGVYluybPbH0meB8a6CPGRkluNGSu0S4N8QDkJZqhXk3ELYr1u9gfmsJxZ2omB2RBkhhIPEmwZroAcGTfmnqiak6IO7oONJQwAxY3WYmNHZmka8tlFORjhLtm6AGe+k41x3g/sEz8gDN/16AGJqi3MzlLNUrJQuPxIkXrPXEn08nyMDrhz6LuDVikBKeFunflRp07d7hwCoRz7RiFqiJP946XdrV/ozP1054RrZU5RhlcWK17sFUmY9HYgNAYuMpCjfTOWxqKX09aKU5IM9XDV4xXPZIFVBGi9Egk8XRCCf+WHr9eNDBpBHL5eILPH5xrTw9OP86HdkVIKn//AJZ+JxU7hb0bujQbnDJVTXTzG4XkxNfUTba3CivA7gRl0ThtbpVz6/FilR2/IEoTmpjhmRjVW0XGkXsuRw04U53AIL8DIW6P9ramY/+yMEWWm7ppHA5F4lJIofPEMAEDpA="
|
|
env: &env_remote_docker
|
|
# REMOTE_DOCKER=x.x.x.x (not strictly necessary for this "Remote docker build job", but useful to share with subsequent jobs)
|
|
- secure: YAFyiPcsdmM/GhkDiNTmj6pHAWxsqOfHC7NCQixRN+936FSuIbmnmgFy9AWsVva8u7QGcqHNzxoiHZt7T9bokUSRFBWPGWqsA1vEWiihX2vcl/d2nuoZ/fPYfcudobJasjCaQeKCefW/mt6SCRX/2K8FahYHjhK5iyynVKkLFDrmKW4ax3TggQmsOBIKXNB/gUjYugz06o9b5Xgm4zdBa37j7wcXCUVkWTyWvhhPBKOjLMqXKumzCSLDVLoPKbVgFPVKtfC+ftin3W9wFpU4dI0tng0i/6Mysy8K3eU238+WSNizTf+fXwjeunDFJwWl5X8xRpBk/vvvt0CMERQrs5Y+cEq8ME7F265EfoKKkTexRgdI3Id7WrgV7bMJZBwfmMyMF71XAx3nxkbj2JXXwjj3HneZihSf1OmQyQ/nuvlm2jdqKiTOzSruO/2hp3/bJCHZhmD98I1GMXKcuw9dA/pccoNVQvXhDZRgqI35nk5dnviF4UYSqV/wSWhEyCEhR7/G3HZGoOy3WBrL01Em3KAC7CcI54dYsZXO0XvaGqu7HMfgi9uch2n6wbFP9KufKtnHvCWyspPHrenfZMy1c2pAdguyP/fugXZR5JGQl+Tu2y3iOMxlDFJcrXMcEx9N57yVnvlBotUCyL3Jjbx9BXwb4ypLOEtMhdJaOPvKWcg=
|
|
# DOCKER_HOST=ssh://x.x.x.x
|
|
- secure: AP6owqkStO9n0+ZNj4hoIkAmY8tYoG96IrsNjsDAbq5tbh0QaVknLmNXVei0Jk8bRdulXR2DFsHNhV+pkh6BT2/77t2fvvBcBX0IYYB34hlHqafusffXfQRvQ4DIh68Sk0XqMd7OKnb9rNVYQQPdwDO5lHt4borLsOAN20J/pv06V5y+IHiS9QRhRYxNsN7KKgqQKooY5EZbsEjCJaFDsrvn4KwBJEEpxFSivSL8aehrNk0olQygsmbZ7WBwWnuhqvD6PntkOL1kqzgxFcwh7rcZCB50DD5/dItQXI7jomT82MyFGb8diIkxiggHrJVSy7xWWyup51xWOHv+W4CX+m0u0m+sgd7smtOpyl+mlhkdAY6alkBzpoVN8gFubpiZltS4yBnZmubmTo4erQSa8M7d2Cagi6AqxUqYrwBQ5R7jarr6hneVWC5Sy7sPt2EcqrEW8Qy5LwSm1dnprKKHVpxn8naZLTVvQN8l1EBWqX8lhzdkqpqKvdIS37/ql0ZBAema1RluS4AcpnSA+uyobAojScdK3s+LWmn+MEwts2QM7iikOIP8p0DiWPY3aQ4zu3iR7BueWGuuts/zcqkLzQJY4/+RtjKlGLR3BdTVMk9m5RfP/+MdrqVyFz2X6AJeCyO+57kCBJd0T1deXrL4ZrJXVAso9WiRxATpQPMJNb4=
|
|
before_install: &remote_docker_ssh
|
|
- |
|
|
# Set up remote docker host ssh.
|
|
openssl aes-256-cbc -K $encrypted_833c0dff2c1b_key -iv $encrypted_833c0dff2c1b_iv -in .travis.rsa.enc -out /tmp/.travis.rsa -d
|
|
eval "$(ssh-agent -s)"
|
|
chmod 600 /tmp/.travis.rsa
|
|
ssh-add /tmp/.travis.rsa
|
|
script:
|
|
- PATH="`pwd`/bin:$PATH" DOCKER_TRACE=1 bin/docker-build
|
|
|
|
- &kind-setup
|
|
if: fork = false
|
|
name: "Kind cluster setup (deep)"
|
|
language: generic
|
|
cache:
|
|
directories:
|
|
- target/bin
|
|
addons: *addons_ssh_known_hosts
|
|
env: *env_remote_docker
|
|
before_install: *remote_docker_ssh
|
|
before_script:
|
|
- export INTEGRATION_TEST=deep
|
|
script:
|
|
- |
|
|
# kind shells out to docker so we need bin/docker in PATH.
|
|
export PATH="`pwd`/bin:$PATH"
|
|
- |
|
|
# create kind cluster
|
|
export KIND_CLUSTER=travis-$TRAVIS_BUILD_ID-$INTEGRATION_TEST
|
|
bin/kind create cluster --name=$KIND_CLUSTER
|
|
- |
|
|
# Save kubeconfig to remote docker host for kind integration test stages.
|
|
scp $(bin/kind get kubeconfig-path --name=$KIND_CLUSTER) $USER@$REMOTE_DOCKER:/tmp
|
|
after_failure:
|
|
- bin/kind delete cluster --name=$KIND_CLUSTER
|
|
- <<: *kind-setup
|
|
name: "Kind cluster setup (upgrade)"
|
|
before_script:
|
|
- export INTEGRATION_TEST=upgrade
|
|
- <<: *kind-setup
|
|
name: "Kind cluster setup (helm)"
|
|
before_script:
|
|
- export INTEGRATION_TEST=helm
|
|
|
|
- stage: test
|
|
name: "Go unit tests"
|
|
language: go
|
|
# Quote the version number to avoid parsing issues like
|
|
# https://github.com/travis-ci/gimme/issues/132.
|
|
go: "1.12.9"
|
|
go_import_path: github.com/linkerd/linkerd2
|
|
env:
|
|
- GO111MODULE=on
|
|
cache:
|
|
directories:
|
|
- target/bin
|
|
- "$GOPATH/pkg/mod"
|
|
- "$HOME/.cache"
|
|
before_install:
|
|
- echo $GITCOOKIE_SH | base64 -d | bash
|
|
script:
|
|
# TODO decide whether protoc should be committed or not. If so, we shouldn't do
|
|
# this or we should error if it dirties the repo.
|
|
- ./bin/protoc-go.sh
|
|
- go test -cover -race -v -mod=readonly ./...
|
|
- ./bin/lint --verbose
|
|
|
|
- name: "Node.js unit tests"
|
|
language: node_js
|
|
node_js:
|
|
- "10"
|
|
cache: yarn
|
|
before_install:
|
|
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.7.0
|
|
- export PATH="$HOME/.yarn/bin:$PATH"
|
|
- export NODE_ENV=test
|
|
install:
|
|
- ./bin/web
|
|
script:
|
|
- ./bin/web test --reporters=jest-dot-reporter
|
|
|
|
- &kind-test
|
|
if: fork = false
|
|
name: "Kind integration tests (deep)"
|
|
language: generic
|
|
cache:
|
|
directories:
|
|
- target/bin
|
|
- "$GOPATH/pkg/mod"
|
|
- "$HOME/.cache"
|
|
addons: *addons_ssh_known_hosts
|
|
env: *env_remote_docker
|
|
before_install: *remote_docker_ssh
|
|
before_script:
|
|
- export INTEGRATION_TEST=deep
|
|
script:
|
|
- |
|
|
# Install Go.
|
|
curl -sL -o /tmp/go.tar.gz https://dl.google.com/go/go1.12.9.linux-amd64.tar.gz
|
|
rm -rf $GOROOT
|
|
sudo rm -rf /usr/local/go
|
|
sudo tar -C /usr/local -xzf /tmp/go.tar.gz
|
|
export GO111MODULE=on
|
|
export GOROOT=/usr/local/go
|
|
- |
|
|
# Misc env setup.
|
|
export PATH=/usr/local/go/bin:$PATH
|
|
export PATH="`pwd`/bin:$PATH"
|
|
export KIND_CLUSTER=travis-$TRAVIS_BUILD_ID-$INTEGRATION_TEST
|
|
echo $GITCOOKIE_SH | base64 -d | bash
|
|
- |
|
|
# Restore kubeconfig from remote docker host.
|
|
mkdir -p $HOME/.kube
|
|
scp $USER@$REMOTE_DOCKER:/tmp/kind-config-$KIND_CLUSTER $HOME/.kube
|
|
export KUBECONFIG=$(bin/kind get kubeconfig-path --name=$KIND_CLUSTER)
|
|
- |
|
|
# Start ssh tunnel to allow kubectl to connect via localhost.
|
|
export KIND_PORT=$(bin/kubectl config view -o jsonpath="{.clusters[?(@.name=='$KIND_CLUSTER')].cluster.server}" | cut -d':' -f3)
|
|
ssh -4 -N -L $KIND_PORT:localhost:$KIND_PORT $USER@$REMOTE_DOCKER &
|
|
sleep 2 # Wait for ssh tunnel to come up.
|
|
bin/kubectl version --short # Test connection to kind cluster.
|
|
- |
|
|
# Install linkerd cli.
|
|
version="$(CI_FORCE_CLEAN=1 bin/root-tag)"
|
|
image="gcr.io/linkerd-io/cli-bin:$version"
|
|
id=$(bin/docker create $image)
|
|
mkdir -p ./target/cli/linux
|
|
bin/docker cp "$id:/out/linkerd-linux" "./target/cli/linux/linkerd"
|
|
- |
|
|
# Load Linkerd docker images into kind cluster.
|
|
ssh -T $USER@$REMOTE_DOCKER &> /dev/null << EOF
|
|
for IMG in controller grafana proxy web ; do
|
|
# TODO: This is using the kind binary on the remote host.
|
|
kind load docker-image gcr.io/linkerd-io/\$IMG:$version --name=$KIND_CLUSTER
|
|
done
|
|
EOF
|
|
- |
|
|
# Run the integration tests.
|
|
(
|
|
. bin/_test-run.sh
|
|
init_test_run `pwd`/bin/linkerd
|
|
"$INTEGRATION_TEST"_integration_tests
|
|
)
|
|
after_script:
|
|
- bin/kind delete cluster --name=$KIND_CLUSTER
|
|
- <<: *kind-test
|
|
name: "Kind integration tests (upgrade)"
|
|
before_script:
|
|
- export INTEGRATION_TEST=upgrade
|
|
- <<: *kind-test
|
|
name: "Kind integration tests (helm)"
|
|
before_script:
|
|
- export INTEGRATION_TEST=helm
|
|
|
|
# Push container images to Google Container Registry.
|
|
- stage: docker-deploy
|
|
|
|
language: generic
|
|
services:
|
|
- docker
|
|
|
|
cache:
|
|
directories:
|
|
- "$HOME/google-cloud-sdk/"
|
|
- "$HOME/.cache"
|
|
|
|
before_install:
|
|
- docker version
|
|
|
|
- |
|
|
# Install gcloud and kubectl.
|
|
dir="${CLOUDSDK_INSTALL_DIR:-${HOME}}/google-cloud-sdk"
|
|
(. bin/_gcp.sh ; install_gcloud_kubectl "$dir")
|
|
. "$dir/path.bash.inc"
|
|
- |
|
|
# Configure gcloud with a service account.
|
|
openssl aes-256-cbc -K $encrypted_ea955175587c_key -iv $encrypted_ea955175587c_iv -in .gcp.json.enc -out .gcp.json -d
|
|
(. bin/_gcp.sh ; set_gcloud_config "$GCP_PROJECT" "$GCP_ZONE" "$GKE_CLUSTER")
|
|
- |
|
|
# Get a kubernetes context.
|
|
(. bin/_gcp.sh ; get_k8s_ctx "$GCP_PROJECT" "$GCP_ZONE" "$GKE_CLUSTER")
|
|
- gcloud version
|
|
- kubectl version --short
|
|
|
|
before_script:
|
|
- gcloud docker --authorize-only
|
|
- bin/docker-pull-deps
|
|
# Pulling master helps with docker build cache, but may fail if we're
|
|
# adding a new image to the mix.
|
|
- bin/docker-pull master || echo "docker pull failed" >&2
|
|
- |
|
|
export LINKERD_TAG=$(. bin/_tag.sh ; clean_head_root_tag)
|
|
echo "LINKERD_TAG=${LINKERD_TAG}"
|
|
- export BUILD_DEBUG=1 DOCKER_TRACE=1
|
|
|
|
script:
|
|
- bin/docker-build
|
|
|
|
after_success:
|
|
- bin/docker-push-deps
|
|
- bin/docker-push $LINKERD_TAG
|
|
- bin/docker-retag-all $LINKERD_TAG master && bin/docker-push master
|
|
- target/cli/linux/linkerd install --control-plane-version=$LINKERD_TAG |tee linkerd.yml
|
|
- kubectl -n linkerd apply -f linkerd.yml --prune --selector='linkerd.io/control-plane-component'
|
|
|
|
# Run integration tests after container images have been published.
|
|
- stage: integration-test
|
|
|
|
language: go
|
|
go: "1.12.9"
|
|
go_import_path: github.com/linkerd/linkerd2
|
|
env:
|
|
- GO111MODULE=on
|
|
services:
|
|
- docker
|
|
|
|
cache:
|
|
directories:
|
|
- "$GOPATH/pkg/mod"
|
|
- "$HOME/google-cloud-sdk/"
|
|
- "$HOME/.cache"
|
|
|
|
before_install:
|
|
- echo $GITCOOKIE_SH | base64 -d | bash
|
|
|
|
install:
|
|
- |
|
|
# Install gcloud and kubectl.
|
|
dir="${CLOUDSDK_INSTALL_DIR:-${HOME}}/google-cloud-sdk"
|
|
(. bin/_gcp.sh ; install_gcloud_kubectl "$dir")
|
|
. "$dir/path.bash.inc"
|
|
- |
|
|
# Configure gcloud with a service account.
|
|
openssl aes-256-cbc -K $encrypted_ea955175587c_key -iv $encrypted_ea955175587c_iv -in .gcp.json.enc -out .gcp.json -d
|
|
(. bin/_gcp.sh ; set_gcloud_config "$GCP_PROJECT" "$GCP_ZONE" "$GKE_CLUSTER")
|
|
- |
|
|
# Get a kubernetes context.
|
|
(. bin/_gcp.sh ; get_k8s_ctx "$GCP_PROJECT" "$GCP_ZONE" "$GKE_CLUSTER")
|
|
- |
|
|
# Install linkerd cli.
|
|
version="$(CI_FORCE_CLEAN=1 bin/root-tag)"
|
|
image="gcr.io/linkerd-io/cli-bin:$version"
|
|
id=$(docker create $image)
|
|
docker cp "$id:/out/linkerd-linux" "./linkerd"
|
|
- gcloud version
|
|
- kubectl version --short
|
|
- ./linkerd version --client
|
|
|
|
script:
|
|
- |
|
|
# Run integration tests.
|
|
version="$(./linkerd version --client --short | tr -cd '[:alnum:]-')"
|
|
./bin/test-run `pwd`/linkerd linkerd-$version
|
|
- |
|
|
# Run linkerd-cni integration tests.
|
|
TAG="$(./linkerd version --client --short)" go test -cover -race -v -mod=readonly ./cni-plugin/test -integration-tests
|
|
after_script:
|
|
- |
|
|
# Cleanup after integration test run.
|
|
./bin/test-cleanup
|
|
|
|
notifications:
|
|
email:
|
|
on_success: never
|