cirrus-ci-docs icon indicating copy to clipboard operation
cirrus-ci-docs copied to clipboard

Repository Metadata

Open fkorotkov opened this issue 2 years ago • 2 comments

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

fkorotkov avatar Oct 10 '22 21:10 fkorotkov

We can probably also create some default metadata like cache hit rate over the last 100 builds (see #31).

fkorotkov avatar Oct 11 '22 14:10 fkorotkov

load("github.com/cirrus-modules/graphql", "generate_build_number")

def main(ctx):
  return { 
    "env": {
       "CIRRUS_BUILD_NUMBER": generate_build_number()
    }
  }

fkorotkov avatar Oct 14 '22 14:10 fkorotkov

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.

fkorotkov avatar Oct 31 '22 12:10 fkorotkov

Let's keep it open until TTL is implemented

fkorotkov avatar Nov 06 '22 18:11 fkorotkov

Closing because the TTL was implemented and deployed (see RepositorySetMetadataInput's ttlSeconds field in GraphQL schema).

edigaryev avatar Nov 11 '22 08:11 edigaryev