Skip to content

Commit

Permalink
Add Dispatchfile
Browse files Browse the repository at this point in the history
  • Loading branch information
cprovencher committed Feb 14, 2020
1 parent a9307cb commit d746c13
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
72 changes: 72 additions & 0 deletions Dispatchfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!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",
image = "mesosphere/dispatch-dind:mesosphere-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"]))
3 changes: 2 additions & 1 deletion test/e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,7 +47,7 @@ create_kind_cluster() {
chmod +x "${tmp}/kind"

"${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
Expand Down
17 changes: 17 additions & 0 deletions test/kind-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,20 @@ apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
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"

0 comments on commit d746c13

Please sign in to comment.