diff --git a/Dispatchfile b/Dispatchfile new file mode 100644 index 0000000000..d0880e2c7a --- /dev/null +++ b/Dispatchfile @@ -0,0 +1,71 @@ +#!starlark +# vi:syntax=python +# + +git = "src-git" + +def secretVar(name, key): + return k8s.corev1.EnvVarSource(secretKeyRef=k8s.corev1.SecretKeySelector(localObjectReference=k8s.corev1.LocalObjectReference(name=name), key=key)) + +gitResource(git, + url="$(context.git.url)", + revision="$(context.git.commit)") + +dindTask("publish", inputs=[git], steps=[ + v1.Container( + name = "publish-charts", + workingDir = "/workspace/src-git", + args = [ + "/bin/bash", "-c", + """ + apt-get update + apt-get install -qq git build-essential + git fetch origin master --unshallow + export GIT_REMOTE_URL=https://mesosphere:${GITHUB_USER_TOKEN}@github.com/mesosphere/charts.git + make publish + """ + ], + env=[k8s.corev1.EnvVar(name="GITHUB_USER_TOKEN", valueFrom=secretVar("scmtoken", "password"))] + ) +]) + +dindTask("lint", inputs=[git], steps=[ + v1.Container( + name = "lint-charts", + workingDir = "/workspace/src-git", + args = [ + "/bin/bash", "-c", + """ + apt-get update + apt-get install -qq git build-essential + git fetch origin master --unshallow + make lint + """ + ] + ) +]) + +dindTask("test", inputs=[git], deps=["lint"], steps=[ + v1.Container( + name = "test-charts", + workingDir = "/workspace/src-git", + args = [ + "/bin/bash", "-c", + """ + apt-get update + apt-get install -qq git build-essential + git fetch origin master --unshallow + make test + """ + ], + resources = k8s.corev1.ResourceRequirements( + limits = { + "cpu": k8s.resource_quantity("1000m"), + "memory": k8s.resource_quantity("6Gi") + } + ) + ) +]) + +action(tasks=["test"], on=pullRequest(branches=["*"])) +action(tasks=["publish"], on=push(branches=["master"])) diff --git a/test/e2e-kind.sh b/test/e2e-kind.sh index 6e6ba7a365..f82657757b 100755 --- a/test/e2e-kind.sh +++ b/test/e2e-kind.sh @@ -3,6 +3,7 @@ set -o errexit set -o nounset set -o pipefail +set -x readonly KIND_VERSION=v0.6.1 readonly CLUSTER_NAME=chart-testing @@ -45,8 +46,18 @@ create_kind_cluster() { "https://github.com/kubernetes-sigs/kind/releases/download/$KIND_VERSION/kind-$(uname)-amd64" chmod +x "${tmp}/kind" + curl -sSLo "${tmp}/entrypoint.sh" "https://raw.githubusercontent.com/mesosphere/dispatch/f74d477930e8cf05b84eb8a0f98c3866b66e1125/docker/kind/entrypoint.sh?token=ACIQJHWXERD34NEOUHGOWIS6KWQO6" + chmod +x "${tmp}/entrypoint.sh" + + cat << EOF > tmp_dockerfile +FROM kindest/node:$K8S_VERSION +ADD ./entrypoint.sh /usr/local/bin/entrypoint +EOF + + docker build -t tmp-dispatch-kind:latest -f tmp_dockerfile "${tmp}" + "${tmp}/kind" create cluster --name "$CLUSTER_NAME" \ - --config test/kind-config.yaml --image "kindest/node:$K8S_VERSION" \ + --config test/kind-config.yaml --image "mesosphere/dispatch-kind:v0.5.2" \ --wait 60s docker_exec mkdir -p /root/.kube diff --git a/test/kind-config.yaml b/test/kind-config.yaml index cebee6d5b9..8dd75af599 100644 --- a/test/kind-config.yaml +++ b/test/kind-config.yaml @@ -3,3 +3,22 @@ apiVersion: kind.x-k8s.io/v1alpha4 nodes: - role: control-plane - role: worker +# These kubeadm config patches are required for running Kind inside a docker container. +# We started running Kind in a kubernetes pod as part of the CI transition to Dispatch. +kubeadmConfigPatches: +- | + apiVersion: kubeadm.k8s.io/v1beta2 + kind: JoinConfiguration + metadata: + name: config + nodeRegistration: + kubeletExtraArgs: + cgroup-root: "/kubelet" +- | + apiVersion: kubeadm.k8s.io/v1beta2 + kind: InitConfiguration + metadata: + name: config + nodeRegistration: + kubeletExtraArgs: + cgroup-root: "/kubelet"