cirrus-ci-docs
cirrus-ci-docs copied to clipboard
Repository Metadata
Description
Let's allow to store arbitrary key/value metadata within a repository and display it on the repository page.
Context
This is useful, for example, for reporting test coverage. Some more advance use case might be using GraphQL API to maintain "build number" like #305 via Starlark helpers https://github.com/cirrus-modules/graphql
We can probably also create some default metadata like cache hit rate over the last 100 builds (see #31).
load("github.com/cirrus-modules/graphql", "generate_build_number")
def main(ctx):
return {
"env": {
"CIRRUS_BUILD_NUMBER": generate_build_number()
}
}
Another use case by @lucperkins is to be able to pass some simple values between tasks. This might be a stretch a bit since once can already do pretty much the same with the HTTP Cache by prefixing with :
# task A
curl -s -X POST --data "this is raw data" http://$CIRRUS_HTTP_CACHE_HOST/$CIRRUS_BUILD_ID/nix-sha
# task B
export NIX_SHA="$(curl -fs http://$CIRRUS_HTTP_CACHE_HOST/$CIRRUS_BUILD_ID/nix-sha)"
But there is a good point about TTL. I think we can easily include a TTL option since Datastore natively supports it. I think we can do the regular metadata first and then follow up with the TTL option.
Let's keep it open until TTL is implemented
Closing because the TTL was implemented and deployed (see RepositorySetMetadataInput
's ttlSeconds
field in GraphQL schema).