From 7f40317399f5540dab9212452d55e5db0e219e5b Mon Sep 17 00:00:00 2001 From: Haytham AbuelFutuh Date: Wed, 27 May 2020 16:54:26 -0700 Subject: [PATCH] Run end2end tests on PRs (#136) This is an initial release that enables End2end tests on any PR as well as merges to master. It's also possible for any fork to run the same CI steps. This adds two additional github actions steps: - Setup a [KinD](https://kind.sigs.k8s.io/) cluster (Kubernetes in Docker) - Run `end2end_execute`: - Clone flyte repo master - Replace propeller image with git sha's image - Run `make end2end_execute` from flyte repo. This deploys `flyte` manifests and run `endtoend.yaml` pod and waits for all workflows to finish executing as expected. --- .github/workflows/master.yml | 11 +++++++++++ .github/workflows/pull_request.yml | 15 +++++++++++++++ .gitignore | 1 + Makefile | 1 + boilerplate/lyft/end2end/Makefile | 8 ++++++++ boilerplate/lyft/end2end/end2end.sh | 28 ++++++++++++++++++++++++++++ 6 files changed, 64 insertions(+) create mode 100644 boilerplate/lyft/end2end/Makefile create mode 100755 boilerplate/lyft/end2end/end2end.sh diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 374fe8150b..6b718c627c 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -29,3 +29,14 @@ jobs: push_git_tag: true registry: docker.pkg.github.com build_extra_args: "--compress=true" + - uses: engineerd/setup-kind@v0.4.0 + - name: End2End + env: + DOCKER_USERNAME: ${{ github.actor }} + DOCKER_PASSWORD: "${{ secrets.GITHUB_TOKEN }}" + run: | + kubectl cluster-info + kubectl get pods -n kube-system + echo "current-context:" $(kubectl config current-context) + echo "environment-kubeconfig:" ${KUBECONFIG} + PROPELLER=${{ secrets.flytegithub_repo }}/operator:${{ github.sha }} make end2end_execute diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index b87963a5f1..725668e051 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -6,6 +6,10 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + go-version: [1.13] steps: - uses: actions/checkout@v1 - name: Push Docker Image to Github Registry @@ -17,3 +21,14 @@ jobs: image_tag: ${{ github.sha }} push_git_tag: true registry: docker.pkg.github.com + - uses: engineerd/setup-kind@v0.4.0 + - name: End2End + env: + DOCKER_USERNAME: ${{ github.actor }} + DOCKER_PASSWORD: "${{ secrets.GITHUB_TOKEN }}" + run: | + kubectl cluster-info + kubectl get pods -n kube-system + echo "current-context:" $(kubectl config current-context) + echo "environment-kubeconfig:" ${KUBECONFIG} + PROPELLER=${{ secrets.flytegithub_repo }}/operator:${{ github.sha }} make end2end_execute diff --git a/.gitignore b/.gitignore index 9ccd65b879..426b90e2df 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ vendor bin .DS_Store _test +boilerplate/lyft/end2end/tmp diff --git a/Makefile b/Makefile index 04e0ca1964..45a6447858 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ export REPOSITORY=flytepropeller include boilerplate/lyft/docker_build/Makefile include boilerplate/lyft/golang_test_targets/Makefile +include boilerplate/lyft/end2end/Makefile .PHONY: update_boilerplate update_boilerplate: diff --git a/boilerplate/lyft/end2end/Makefile b/boilerplate/lyft/end2end/Makefile new file mode 100644 index 0000000000..1d8397f230 --- /dev/null +++ b/boilerplate/lyft/end2end/Makefile @@ -0,0 +1,8 @@ +# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES. +# ONLY EDIT THIS FILE FROM WITHIN THE 'LYFT/BOILERPLATE' REPOSITORY: +# +# TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst + +.PHONY: end2end_execute +end2end_execute: + ./boilerplate/lyft/end2end/end2end.sh diff --git a/boilerplate/lyft/end2end/end2end.sh b/boilerplate/lyft/end2end/end2end.sh new file mode 100755 index 0000000000..2096b16084 --- /dev/null +++ b/boilerplate/lyft/end2end/end2end.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES. +# ONLY EDIT THIS FILE FROM WITHIN THE 'LYFT/BOILERPLATE' REPOSITORY: +# +# TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst + +set -e + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" + +OUT="${DIR}/tmp" +rm -rf ${OUT} +git clone https://github.com/lyft/flyte.git "${OUT}" + +# TODO: load all images +echo "Loading github docker images into 'kind' cluster to workaround this issue: https://github.com/containerd/containerd/issues/3291#issuecomment-631746985" +docker login --username ${DOCKER_USERNAME} --password ${DOCKER_PASSWORD} docker.pkg.github.com +docker pull docker.pkg.github.com/${PROPELLER} +kind load docker-image docker.pkg.github.com/${PROPELLER} + +pushd ${OUT} +# TODO: Only replace propeller if it's passed in +# TODO: Support replacing other images too +sed -i.bak -e "s_docker.io/lyft/flytepropeller:.*_docker.pkg.github.com/${PROPELLER}_g" ${OUT}/kustomize/base/propeller/deployment.yaml +make kustomize +make end2end_execute +popd