Enable dynamic pipelines

This runs jobs in parallel for real now!  Should be much faster when the
cluster is idle.

This only works with the webhook pass/fail detection.

Change-Id: I1380ebcc53030b92ad8e01d534054fbc2746baa0
diff --git a/tools/ci/buildkite.yaml b/tools/ci/buildkite.yaml
new file mode 100644
index 0000000..42f6ebe
--- /dev/null
+++ b/tools/ci/buildkite.yaml
@@ -0,0 +1,21 @@
+env:
+  STARTUP: --max_idle_secs=0 --watchfs
+  COMMON: -c opt --stamp=no --curses=no --color=no --symlink_prefix=/ --disk_cache=~/.cache/bazel/disk_cache/
+  TARGETS: //... @com_github_google_glog//... @com_google_ceres_solver//...
+  M4F_TARGETS: //...
+  # Sanity check that we are able to build the y2020 roborio code, which confirms
+  # that we have the platform compatibility for the roborio set up correctly.
+  ROBORIO_TARGETS: ${TARGETS} //y2020:download_stripped
+
+steps:
+  - label: "x86_64"
+    command: tools/bazel ${STARTUP} --output_base=../k8_output_base test ${COMMON} --config=k8 --config=eigen ${TARGETS}
+
+  - label: "roborio"
+    command: tools/bazel ${STARTUP} --output_base=../roborio_output_base build ${COMMON} --config=roborio ${ROBORIO_TARGETS}
+
+  - label: "armhf-debian"
+    command: tools/bazel ${STARTUP} --output_base=../armhf-debian_output_base build ${COMMON} --config=armhf-debian ${TARGETS}
+
+  - label: "cortex-m4f"
+    command: tools/bazel ${STARTUP} --output_base=../cortex-m4f_output_base build ${COMMON} --config=cortex-m4f ${M4F_TARGETS}
diff --git a/tools/ci/run-tests.sh b/tools/ci/run-tests.sh
index c0f9c93..867e9c3 100755
--- a/tools/ci/run-tests.sh
+++ b/tools/ci/run-tests.sh
@@ -5,6 +5,11 @@
 # No need to pass this through.  It hurts caching.
 unset SSH_AUTH_SOCK
 
+if [ -n ${BUILDKITE+x} ]; then
+  buildkite-agent pipeline upload tools/ci/buildkite.yaml
+  exit 0
+fi
+
 readonly TARGETS='//... @com_github_google_glog//... @com_google_ceres_solver//...'
 readonly M4F_TARGETS='//...'
 # Sanity check that we are able to build the y2020 roborio code, which confirms