Skip to content

Commit

Permalink
Replace Travis with GitHub Actions for master/tags (#3398)
Browse files Browse the repository at this point in the history
GitHub Actions has been running unit and integration tests, in parallel
with Travis running those same tests, and also handling master merges
and tags.

This change completes the transtion to GitHub Actions, removing all
references to Travis. Similar to Travis, GitHub Actions now acts on
master merges and tag pushes by pushing Docker images to gcr.io, and
running integration tests against a GKE cluster.

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
  • Loading branch information
siggy committed Sep 6, 2019
1 parent a4b30b4 commit 3be2b41
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 341 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.travis.yml
.git
.github
**/.idea
**/cmake-*
**/CMakeLists.txt
Expand Down
208 changes: 200 additions & 8 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,41 @@ on:
push:
branches:
- master
- refs/tags/edge-[0-9]?.[0-9]?.[0-9]?
- refs/tags/stable-2.[0-9]?.[0-9]?
tags:
- "*"


# Jobs by event type and dependencies:

# Unit tests for every master/tag push and PR
#
# validate_go_deps
# go_unit_tests
# go_lint
# js_unit_tests

# Docker build and integration tests for every master/tag push and linkerd org PR
#
# docker_build
# kind_setup
# -> kind_integration
# -> kind_cleanup

# Docker deploy and cloud integration tests for every master/tag push
#
# -> docker_deploy
# -> cloud_integration
# -> cloud_cleanup

jobs:

#
# Unit tests run for:
# - every master push
# - every tag push
# - every PR
#

validate_go_deps:
name: Validate go deps
runs-on: ubuntu-18.04
Expand Down Expand Up @@ -85,6 +116,13 @@ jobs:
bin/web
bin/web test --reporters=jest-dot-reporter
#
# Docker build and kind integration tests run for:
# - every master push
# - every tag push
# - every PR from a linkerd org member
#

docker_build:
name: Docker build
runs-on: ubuntu-18.04
Expand All @@ -107,7 +145,8 @@ jobs:
env:
DOCKER_HOST: ssh://github@${{ secrets.DOCKER_ADDRESS }}
run: |
PATH="`pwd`/bin:$PATH" DOCKER_TRACE=1 bin/docker-build
export PATH="`pwd`/bin:$PATH"
DOCKER_TRACE=1 bin/docker-build
kind_setup:
strategy:
Expand Down Expand Up @@ -184,10 +223,10 @@ jobs:
TAG="$(CI_FORCE_CLEAN=1 bin/root-tag)"
image="gcr.io/linkerd-io/cli-bin:$TAG"
id=$(bin/docker create $image)
mkdir -p ./target/cli/linux
bin/docker cp "$id:/out/linkerd-linux" "./target/cli/linux/linkerd"
bin/docker cp "$id:/out/linkerd-linux" "$HOME/.linkerd"
$HOME/.linkerd version --client
# validate CLI version matches the repo
[[ "$TAG" == "$(bin/linkerd version --short --client)" ]]
[[ "$TAG" == "$($HOME/.linkerd version --short --client)" ]]
echo "Installed Linkerd CLI version: $TAG"
- name: Run integration tests
if: github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork
Expand All @@ -196,10 +235,10 @@ jobs:
DOCKER_HOST: ssh://github@${{ secrets.DOCKER_ADDRESS }}
GITCOOKIE_SH: ${{ secrets.GITCOOKIE_SH }}
run: |
export PATH="`pwd`/bin:$PATH"
echo "$GITCOOKIE_SH" | bash
# TODO: pin Go version
go version
export PATH="`pwd`/bin:$PATH"
TAG="$(CI_FORCE_CLEAN=1 bin/root-tag)"
export KIND_CLUSTER=github-$TAG-${{ matrix.integration_test }}
# Restore kubeconfig from remote docker host.
Expand All @@ -213,7 +252,7 @@ jobs:
bin/kubectl version --short # Test connection to kind cluster.
(
. bin/_test-run.sh
init_test_run `pwd`/bin/linkerd
init_test_run $HOME/.linkerd
${{ matrix.integration_test }}_integration_tests
)
Expand Down Expand Up @@ -260,3 +299,156 @@ jobs:
TAG="$(CI_FORCE_CLEAN=1 bin/root-tag)"
export KIND_CLUSTER=github-$TAG-${{ matrix.integration_test }}
bin/kind delete cluster --name=$KIND_CLUSTER
#
# Docker deploy and cloud integration tests run for:
# - every master push
# - every tag push
#

docker_deploy:
name: Docker deploy
runs-on: ubuntu-18.04
needs: [validate_go_deps, go_unit_tests, go_lint, js_unit_tests, kind_integration, kind_cleanup]
steps:
- name: Checkout code
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
uses: actions/checkout@v1
- name: Docker SSH setup
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
env:
DOCKER_ADDRESS: ${{ secrets.DOCKER_ADDRESS }}
DOCKER_HOST_PRIVATE_KEY: ${{ secrets.DOCKER_HOST_PRIVATE_KEY }}
run: |
mkdir -p ~/.ssh/
echo "$DOCKER_HOST_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan $DOCKER_ADDRESS >> ~/.ssh/known_hosts
- name: Configure gcloud
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
env:
CLOUDSDK_CORE_DISABLE_PROMPTS: "1"
CLOUD_SDK_SERVICE_ACCOUNT_KEY: ${{ secrets.CLOUD_SDK_SERVICE_ACCOUNT_KEY }}
GCP_PROJECT: ${{ secrets.GCP_PROJECT }}
GCP_ZONE: ${{ secrets.GCP_ZONE }}
GKE_CLUSTER: ${{ secrets.GKE_CLUSTER }}
run: |
# Install gcloud and kubectl.
echo "$CLOUD_SDK_SERVICE_ACCOUNT_KEY" > .gcp.json
dir="${CLOUDSDK_INSTALL_DIR:-${HOME}}/google-cloud-sdk"
(
. bin/_gcp.sh ;
install_gcloud_kubectl "$dir"
# Configure gcloud with a service account.
set_gcloud_config "$GCP_PROJECT" "$GCP_ZONE" "$GKE_CLUSTER"
# Get a kubernetes context.
get_k8s_ctx "$GCP_PROJECT" "$GCP_ZONE" "$GKE_CLUSTER"
)
. "$dir/path.bash.inc"
gcloud auth configure-docker
bin/kubectl version --short
- name: Docker push
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
env:
DOCKER_HOST: ssh://github@${{ secrets.DOCKER_ADDRESS }}
run: |
export PATH="`pwd`/bin:$PATH"
TAG="$(CI_FORCE_CLEAN=1 bin/root-tag)"
bin/docker-push-deps
bin/docker-push $TAG
bin/docker-retag-all $TAG master
bin/docker-push master
cloud_integration:
name: Cloud integration tests
runs-on: ubuntu-18.04
needs: [docker_deploy]
steps:
- name: Checkout code
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
uses: actions/checkout@v1
- name: Configure gcloud
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
env:
CLOUDSDK_CORE_DISABLE_PROMPTS: "1"
CLOUD_SDK_SERVICE_ACCOUNT_KEY: ${{ secrets.CLOUD_SDK_SERVICE_ACCOUNT_KEY }}
GCP_PROJECT: ${{ secrets.GCP_PROJECT }}
GCP_ZONE: ${{ secrets.GCP_ZONE }}
GKE_CLUSTER: ${{ secrets.GKE_CLUSTER }}
run: |
# Install gcloud and kubectl.
echo "$CLOUD_SDK_SERVICE_ACCOUNT_KEY" > .gcp.json
dir="${CLOUDSDK_INSTALL_DIR:-${HOME}}/google-cloud-sdk"
(
. bin/_gcp.sh ;
install_gcloud_kubectl "$dir"
# Configure gcloud with a service account.
set_gcloud_config "$GCP_PROJECT" "$GCP_ZONE" "$GKE_CLUSTER"
# Get a kubernetes context.
get_k8s_ctx "$GCP_PROJECT" "$GCP_ZONE" "$GKE_CLUSTER"
)
. "$dir/path.bash.inc"
gcloud auth configure-docker
bin/kubectl version --short
- name: Install linkerd CLI
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
run: |
TAG="$(CI_FORCE_CLEAN=1 bin/root-tag)"
image="gcr.io/linkerd-io/cli-bin:$TAG"
id=$(bin/docker create $image)
bin/docker cp "$id:/out/linkerd-linux" "$HOME/.linkerd"
$HOME/.linkerd version --client
# validate CLI version matches the repo
[[ "$TAG" == "$($HOME/.linkerd version --short --client)" ]]
echo "Installed Linkerd CLI version: $TAG"
- name: Run integration tests
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
env:
GITCOOKIE_SH: ${{ secrets.GITCOOKIE_SH }}
run: |
export PATH="`pwd`/bin:$PATH"
echo "$GITCOOKIE_SH" | bash
version="$($HOME/.linkerd version --client --short | tr -cd '[:alnum:]-')"
bin/test-run $HOME/.linkerd linkerd-$version
- name: CNI tests
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
run: |
export TAG="$($HOME/.linkerd version --client --short)"
go test -cover -race -v -mod=readonly ./cni-plugin/test -integration-tests
cloud_cleanup:
if: always()
name: Cloud cleanup
runs-on: ubuntu-18.04
needs: [cloud_integration]
steps:
- name: Checkout code
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
uses: actions/checkout@v1
- name: Configure gcloud
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
env:
CLOUDSDK_CORE_DISABLE_PROMPTS: "1"
CLOUD_SDK_SERVICE_ACCOUNT_KEY: ${{ secrets.CLOUD_SDK_SERVICE_ACCOUNT_KEY }}
GCP_PROJECT: ${{ secrets.GCP_PROJECT }}
GCP_ZONE: ${{ secrets.GCP_ZONE }}
GKE_CLUSTER: ${{ secrets.GKE_CLUSTER }}
run: |
# Install gcloud and kubectl.
echo "$CLOUD_SDK_SERVICE_ACCOUNT_KEY" > .gcp.json
dir="${CLOUDSDK_INSTALL_DIR:-${HOME}}/google-cloud-sdk"
(. bin/_gcp.sh ;
install_gcloud_kubectl "$dir"
# Configure gcloud with a service account.
set_gcloud_config "$GCP_PROJECT" "$GCP_ZONE" "$GKE_CLUSTER"
# Get a kubernetes context.
get_k8s_ctx "$GCP_PROJECT" "$GCP_ZONE" "$GKE_CLUSTER"
)
. "$dir/path.bash.inc"
gcloud auth configure-docker
bin/kubectl version --short
- name: Cleanup
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
run: |
export PATH="`pwd`/bin:$PATH"
bin/test-cleanup
Binary file removed .travis.rsa.enc
Binary file not shown.
Loading

0 comments on commit 3be2b41

Please sign in to comment.