Skip to content

Commit

Permalink
Big CI/CD and contributing docs rework
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed Oct 13, 2019
0 parents commit 59addce
Showing 1 changed file with 109 additions and 0 deletions.
109 changes: 109 additions & 0 deletions ci/common
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/bin/bash

## common - source this file with ". ./ci/common" to set environment
## variables and make useful functions available.

mkdir -p bin
export PATH="$PWD/bin:$PATH"

## NOTE: export HUB_API_URL is required for it to be accessible from pytest
##
export HUB_API_URL=http://127.0.0.1:8080/hub/api

## NOTE: We need to allow our CI system to override these env. variables
##
if [ -z ${KUBE_VERSION:-} ]; then
## NOTE: KUBE_VERSION is limited by the available kindest/node images
##
## ref: https://hub.docker.com/r/kindest/node/tags
## ref: https://github.com/kubernetes/kubernetes/releases
export KUBE_VERSION=1.13.10
fi
if [ -z ${KIND_VERSION:-} ]; then
## ref: https://github.com/kubernetes-sigs/kind/releases
export KIND_VERSION=0.5.1
fi
if [ -z ${HELM_VERSION:-} ]; then
## ref: https://github.com/helm/helm/releases
export HELM_VERSION=2.14.3
fi
if [ -z ${KUBEVAL_VERSION:-} ]; then
## ref: https://github.com/instrumenta/kubeval/releases
export KUBEVAL_VERSION=0.14.0
fi

## Valid versions to list under LINT_KUBE_VERSIONS are those in the
## kubernetes-json-schema repoistory, used by kubeval.
##
## ref: https://github.com/instrumenta/kubernetes-json-schema
##
if [ -z ${LINT_KUBE_VERSIONS:-} ]; then
export LINT_KUBE_VERSIONS=1.11.0,1.12.0,1.13.0,1.14.0,1.15.0
fi

## NOTE: The setup_... functions cache downloads but ensure the correct version
##
setup_kubectl () {
echo "setup kubectl ${KUBE_VERSION}"
if ! [ -f "bin/kubectl-${KUBE_VERSION}" ]; then
curl -Lo "bin/kubectl-${KUBE_VERSION}" "https://storage.googleapis.com/kubernetes-release/release/v${KUBE_VERSION}/bin/linux/amd64/kubectl"
chmod +x "bin/kubectl-${KUBE_VERSION}"
fi
cp "bin/kubectl-${KUBE_VERSION}" bin/kubectl
}

setup_kind () {
echo "setup kind ${KIND_VERSION}"
if ! [ -f "bin/kind-${KIND_VERSION}" ]; then
curl -Lo "bin/kind-${KIND_VERSION}" "https://github.com/kubernetes-sigs/kind/releases/download/v${KIND_VERSION}/kind-linux-amd64"
chmod +x "bin/kind-${KIND_VERSION}"
fi
cp "bin/kind-${KIND_VERSION}" bin/kind
}

setup_helm () {
echo "setup helm ${HELM_VERSION}"
if ! [ -f "bin/helm-${HELM_VERSION}" ]; then
curl -Lo "bin/helm-${HELM_VERSION}.tar.gz" "https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-linux-amd64.tar.gz"
tar -xf "bin/helm-${HELM_VERSION}.tar.gz" --directory bin --strip-components 1 linux-amd64/helm
rm "bin/helm-${HELM_VERSION}.tar.gz"
mv bin/helm "bin/helm-${HELM_VERSION}"
fi
cp bin/helm-${HELM_VERSION} bin/helm
}

setup_kubeval () {
echo "setup kubeval ${KUBEVAL_VERSION}"
if ! [ -f "bin/kubeval-${KUBEVAL_VERSION}" ]; then
curl -Lo "bin/kubeval-${KUBEVAL_VERSION}.tar.gz" "https://github.com/instrumenta/kubeval/releases/download/${KUBEVAL_VERSION}/kubeval-linux-amd64.tar.gz"
tar -xf "bin/kubeval-${KUBEVAL_VERSION}.tar.gz" --directory bin
rm "bin/kubeval-${KUBEVAL_VERSION}.tar.gz"
mv bin/kubeval "bin/kubeval-${KUBEVAL_VERSION}"
fi
cp bin/kubeval-${KUBEVAL_VERSION} bin/kubeval
}

setup_git_crypt () {
GIT_CRYPT_VERSION=0.5.0
GIT_CRYPT_VERSION_SHA=46c288cc849c23a28239de3386c6050e5c7d7acd50b1d0248d86e6efff09c61b
echo "setup git-crypt ${GIT_CRYPT_VERSION}"
if ! [ -f "bin/git-crypt-${GIT_CRYPT_VERSION}" ]; then
curl -Lo "bin/git-crypt-${GIT_CRYPT_VERSION}" https://github.com/minrk/git-crypt-bin/releases/download/${GIT_CRYPT_VERSION}/git-crypt
chmod +x "bin/git-crypt-${GIT_CRYPT_VERSION}"
echo "${GIT_CRYPT_VERSION_SHA} bin/git-crypt-${GIT_CRYPT_VERSION}" | shasum -a 256 -c -
fi
cp bin/git-crypt-${GIT_CRYPT_VERSION} bin/git-crypt
}

if [ "$1" = "ci" ]; then
export KIND_CLUSTER=jh-ci-${KUBE_VERSION}
export KUBECONFIG=~/.kube/kind-config-${KIND_CLUSTER}
else
setup_kubectl
setup_kind
setup_helm
setup_kubeval

export KIND_CLUSTER=dev
export KUBECONFIG=~/.kube/kind-config-${KIND_CLUSTER}
fi

0 comments on commit 59addce

Please sign in to comment.