diff options
author | Vincent Ambo <mail@tazj.in> | 2021-11-05T12·59+0100 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2021-11-05T14·24+0000 |
commit | 4b33401a361c5460e8b2a4f30224228e2c002180 (patch) | |
tree | 3709a1eee86c13db57ccf87f37b082af3d386d67 | |
parent | 4482bc2c829544b62302b2f3417347fb2524a148 (diff) |
refactor(ops/pipelines): Move revision tagging into static pipeline r/3005
This makes the revision number available much earlier (before the rest of the pipeline runs, while Nix eval is happening) which should only be a few seconds after a commit to canon. It is also more readable in this shape. Change-Id: Iccbb17dfef6afe68f54fda41e8d10c4dc52b08c2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3775 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
-rw-r--r-- | ops/pipelines/depot.nix | 14 | ||||
-rw-r--r-- | ops/pipelines/static-pipeline.yaml | 18 |
2 files changed, 18 insertions, 14 deletions
diff --git a/ops/pipelines/depot.nix b/ops/pipelines/depot.nix index 7c72098b9d5e..6d4b69d5b086 100644 --- a/ops/pipelines/depot.nix +++ b/ops/pipelines/depot.nix @@ -116,19 +116,5 @@ let allow_failure = false; }]; }) - - # Create a revision number for the current commit for builds on - # canon. - # - # This writes data back to Gerrit using the Buildkite agent - # credentials injected through a git credentials helper. - # - # Revision numbers are defined as the number of commits in the - # lineage of HEAD, following only the first parent of merges. - ({ - command = "git -c 'credential.helper=/etc/secrets/buildkite-credential-helper' push origin \"HEAD:refs/r/$(git rev-list --count --first-parent HEAD)\""; - label = ":git:"; - "if" = ''build.branch == "refs/heads/canon"''; - }) ]; in (writeText "depot.yaml" (toJSON pipeline)) diff --git a/ops/pipelines/static-pipeline.yaml b/ops/pipelines/static-pipeline.yaml index c428780a0613..7e91a734398f 100644 --- a/ops/pipelines/static-pipeline.yaml +++ b/ops/pipelines/static-pipeline.yaml @@ -16,3 +16,21 @@ steps: nix-build -A ops.pipelines.depot -o depot.yaml --show-trace || fallback buildkite-agent meta-data set 'failure' '0' buildkite-agent pipeline upload depot.yaml || fallback + + # Create a revision number for the current commit for builds on + # canon. + # + # This writes data back to Gerrit using the Buildkite agent + # credentials injected through a git credentials helper. + # + # Revision numbers are defined as the number of commits in the + # lineage of HEAD, following only the first parent of merges. + - label: ":git:" + if: "build.branch == 'refs/heads/canon'" + command: | + readonly REVISION=$(git rev-list --count --first-parent HEAD) + + git -c 'credential.helper=/etc/secrets/buildkite-credential-helper' \ + push origin "HEAD:refs/r/${REVISION}" + + echo "Marked commit as r/${REVISION}" |