refactor(ops/pipelines): Move revision tagging into static pipeline
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>
This commit is contained in:
parent
4482bc2c82
commit
4b33401a36
2 changed files with 18 additions and 14 deletions
|
@ -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))
|
||||
|
|
|
@ -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}"
|
||||
|
|
Loading…
Reference in a new issue