about summary refs log tree commit diff
path: root/ops
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-08-06 14:33:44 -0700
committerFranck Cuny <franck@fcuny.net>2022-08-07 14:34:07 -0700
commitb6fe3e7ed1eaa517d1d30b89c22cb68277da8774 (patch)
treee5ba5dfc56517f050b134e68016366db20dc6405 /ops
parentfeat(hosts/tahoe): add a token for graphql for buildkite agents (diff)
downloadworld-b6fe3e7ed1eaa517d1d30b89c22cb68277da8774.tar.gz
ci(pipeline): the pipeline to be executed with a new build
This is the pipeline that is executed when a new build starts. It wait
for all the steps to be completed, and if one of them fail, the build is
marked as failed.

Change-Id: I1eb22b27749944de78d44e49586a1db1fe07b460
Reviewed-on: https://cl.fcuny.net/c/world/+/706
Tested-by: CI
Reviewed-by: Franck Cuny <franck@fcuny.net>
Diffstat (limited to '')
-rw-r--r--ops/ci/README.org3
-rw-r--r--ops/ci/default.nix3
-rw-r--r--ops/ci/pipeline.yml25
3 files changed, 28 insertions, 3 deletions
diff --git a/ops/ci/README.org b/ops/ci/README.org
new file mode 100644
index 0000000..0754937
--- /dev/null
+++ b/ops/ci/README.org
@@ -0,0 +1,3 @@
+The default pipeline is managed by [[file:~/workspace/world/ops/buildkite/][ops/buildkite]]. When a new build starts, the buildkite agent uploads the pipeline defined in this directory.
+
+The configuration for the repository is managed with [[file+emacs:pipeline.yml][pipeline.yml]]. All the steps are executed in parallel except for the last one, which wait on the completion of all the previous steps. If one of the previous steps has failed, the build is marked as failed, otherwise we consider it to pass.
diff --git a/ops/ci/default.nix b/ops/ci/default.nix
deleted file mode 100644
index 1638b53..0000000
--- a/ops/ci/default.nix
+++ /dev/null
@@ -1,3 +0,0 @@
-{ pkgs }:
-
-{ }
diff --git a/ops/ci/pipeline.yml b/ops/ci/pipeline.yml
new file mode 100644
index 0000000..4308f6a
--- /dev/null
+++ b/ops/ci/pipeline.yml
@@ -0,0 +1,25 @@
+env:
+  BUILDKITE_TOKEN_PATH: /run/agenix/buildkite/graphql
+steps:
+  - label: ":shell:"
+    command: "nix develop -c pre-commit run --all-files"
+
+  # wait for all previous steps to complete.
+  - wait: null
+    continue_on_failure: true
+
+  - label: ":hammer:"
+    command: |
+      set -ueo pipefail
+
+      readonly FAILED_JOBS=$(curl 'https://graphql.buildkite.com/v1' \
+        --silent \
+        -H "Authorization: Bearer $(cat ${BUILDKITE_TOKEN_PATH})" \
+        -d "{\"query\": \"query BuildStatusQuery { build(uuid: \\\"$BUILDKITE_BUILD_ID\\\") { jobs(passed: false) { count } } }\"}" | \
+        jq -r '.data.build.jobs.count')
+
+      echo "$$FAILED_JOBS build jobs failed."
+
+      if (( $$FAILED_JOBS > 0 )); then
+        exit 1
+      fi