From 52ed31f27f4dbb71a2a4ebb56199f4e9fed33e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20SZKIBA?= Date: Fri, 23 Aug 2024 10:52:14 +0200 Subject: [PATCH 1/3] feat: add timestamprepository metadata --- README.md | 6 +++++- cmd/load.go | 14 ++++++++++++++ docs/example.json | 6 +++++- docs/registry.md | 6 ++++++ docs/registry.schema.json | 5 +++++ docs/registry.schema.yaml | 8 ++++++++ registry_gen.go | 11 +++++++++++ 7 files changed, 54 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d27ab33..cecbe26 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ Registry generated from the source above. "owner": "grafana", "public": true, "stars": 325, + "timestamp": 1719907965, "topics": [ "xk6", "xk6-official", @@ -144,6 +145,7 @@ Registry generated from the source above. "owner": "grafana", "public": true, "stars": 104, + "timestamp": 1721400602, "topics": [ "k6", "sql", @@ -182,6 +184,7 @@ Registry generated from the source above. "owner": "grafana", "public": true, "stars": 88, + "timestamp": 1724358828, "topics": [ "chaos-engineering", "fault-injection", @@ -235,6 +238,7 @@ Registry generated from the source above. "owner": "szkiba", "public": true, "stars": 49, + "timestamp": 1719935566, "topics": [ "xk6", "xk6-javascript-k6-x-faker" @@ -270,6 +274,7 @@ Registry generated from the source above. "name": "xk6-banner", "owner": "szkiba", "public": true, + "timestamp": 1724312566, "topics": [ "xk6" ], @@ -297,7 +302,6 @@ Registry generated from the source above. "name": "k6", "owner": "grafana", "public": true, - "stars": 24302, "topics": [ "es6", "go", diff --git a/cmd/load.go b/cmd/load.go index afb5237..725dc23 100644 --- a/cmd/load.go +++ b/cmd/load.go @@ -100,6 +100,12 @@ func loadRepository(ctx context.Context, module string) (*k6registry.Repository, return nil, err } + // Some unused metadata in the k6 repository changes too often + if strings.HasPrefix(module, k6Module) { + repo.Stars = 0 + repo.Timestamp = 0 + } + return repo, nil } @@ -162,6 +168,10 @@ func loadGitHub(ctx context.Context, module string) (*k6registry.Repository, err repo.Public = rep.GetVisibility() == "public" + if ts := rep.GetPushedAt(); !ts.IsZero() { + repo.Timestamp = float64(ts.Unix()) + } + tags, _, err := client.Repositories.ListTags(ctx, owner, name, &github.ListOptions{PerPage: 100}) if err != nil { return nil, err @@ -207,6 +217,10 @@ func loadGitLab(ctx context.Context, module string) (*k6registry.Repository, err repo.Topics = proj.Topics repo.Public = len(proj.Visibility) == 0 || proj.Visibility == gitlab.PublicVisibility + if proj.LastActivityAt != nil { + repo.Timestamp = float64(proj.LastActivityAt.Unix()) + } + if proj.License != nil { for key := range validLicenses { if strings.EqualFold(key, proj.License.Key) { diff --git a/docs/example.json b/docs/example.json index 84d3e22..ab3132d 100644 --- a/docs/example.json +++ b/docs/example.json @@ -20,6 +20,7 @@ "owner": "grafana", "public": true, "stars": 325, + "timestamp": 1719907965, "topics": [ "xk6", "xk6-official", @@ -86,6 +87,7 @@ "owner": "grafana", "public": true, "stars": 104, + "timestamp": 1721400602, "topics": [ "k6", "sql", @@ -124,6 +126,7 @@ "owner": "grafana", "public": true, "stars": 88, + "timestamp": 1724358828, "topics": [ "chaos-engineering", "fault-injection", @@ -177,6 +180,7 @@ "owner": "szkiba", "public": true, "stars": 49, + "timestamp": 1719935566, "topics": [ "xk6", "xk6-javascript-k6-x-faker" @@ -212,6 +216,7 @@ "name": "xk6-banner", "owner": "szkiba", "public": true, + "timestamp": 1724312566, "topics": [ "xk6" ], @@ -239,7 +244,6 @@ "name": "k6", "owner": "grafana", "public": true, - "stars": 24302, "topics": [ "es6", "go", diff --git a/docs/registry.md b/docs/registry.md index e2abace..71bdd99 100644 --- a/docs/registry.md +++ b/docs/registry.md @@ -174,6 +174,12 @@ The `true` value of the `archived` flag indicates that the repository is archive If a repository is archived, it usually means that the owner has no intention of maintaining it. Such extensions should be removed from the registry. +#### Timestamp + +The `timestamp` property contains the timestamp of the last modification of the repository in UNIX time format (the number of non-leap seconds that have elapsed since 00:00:00 UTC on 1st January 1970). + +Its value depends on the repository manager, in the case of GitHub it contains the time of the last push operation, in the case of GitLab the time of the last repository activity. + ## Registry Processing The source of the registry is a YAML file optimized for human use. Since collecting extension metadata is a complicated and time-consuming task, it is advisable to extract this step into a registry generator CLI tool. The output of this tool is an extension registry in JSON format. diff --git a/docs/registry.schema.json b/docs/registry.schema.json index 7904352..6ad5952 100644 --- a/docs/registry.schema.json +++ b/docs/registry.schema.json @@ -153,6 +153,11 @@ "type": "boolean", "default": "false", "description": "Archived repository flag.\n\nA `true` value indicates that the repository is archived, read only.\n\nIf a repository is archived, it usually means that the owner has no intention of maintaining it. Such extensions should be removed from the registry.\n" + }, + "timestamp": { + "type": "number", + "default": 0, + "description": "Last modification timestamp.\n\nThe timestamp property contains the timestamp of the last modification of the repository in UNIX time format (the number of non-leap seconds that have elapsed since 00:00:00 UTC on 1st January 1970).\nIts value depends on the repository manager, in the case of GitHub it contains the time of the last push operation, in the case of GitLab the time of the last repository activity.\n" } } }, diff --git a/docs/registry.schema.yaml b/docs/registry.schema.yaml index bd6ed23..c6bf8f1 100644 --- a/docs/registry.schema.yaml +++ b/docs/registry.schema.yaml @@ -215,6 +215,14 @@ $defs: A `true` value indicates that the repository is archived, read only. If a repository is archived, it usually means that the owner has no intention of maintaining it. Such extensions should be removed from the registry. + timestamp: + type: number + default: 0 + description: | + Last modification timestamp. + + The timestamp property contains the timestamp of the last modification of the repository in UNIX time format (the number of non-leap seconds that have elapsed since 00:00:00 UTC on 1st January 1970). + Its value depends on the repository manager, in the case of GitHub it contains the time of the last push operation, in the case of GitLab the time of the last repository activity. tier: type: string enum: ["official", "partner", "community"] diff --git a/registry_gen.go b/registry_gen.go index 5d048c4..2da323b 100644 --- a/registry_gen.go +++ b/registry_gen.go @@ -200,6 +200,17 @@ type Repository struct { // Stars int `json:"stars,omitempty" yaml:"stars,omitempty" mapstructure:"stars,omitempty"` + // Last modification timestamp. + // + // The timestamp property contains the timestamp of the last modification of the + // repository in UNIX time format (the number of non-leap seconds that have + // elapsed since 00:00:00 UTC on 1st January 1970). + // Its value depends on the repository manager, in the case of GitHub it contains + // the time of the last push operation, in the case of GitLab the time of the last + // repository activity. + // + Timestamp float64 `json:"timestamp,omitempty" yaml:"timestamp,omitempty" mapstructure:"timestamp,omitempty"` + // Repository topics. // // Topics make it easier to find the repository. It is recommended to set the xk6 From 78fa470daa54e388432ce839569f90b88b028ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20SZKIBA?= Date: Fri, 23 Aug 2024 11:07:27 +0200 Subject: [PATCH 2/3] feat: add clone_url metadata --- README.md | 6 ++++++ cmd/load.go | 4 ++++ docs/example.json | 6 ++++++ docs/registry.md | 4 ++++ docs/registry.schema.json | 6 ++++++ docs/registry.schema.yaml | 8 ++++++++ registry_gen.go | 7 +++++++ 7 files changed, 41 insertions(+) diff --git a/README.md b/README.md index cecbe26..8b8b220 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ Registry generated from the source above. "oss" ], "repo": { + "clone_url": "https://github.com/grafana/xk6-dashboard.git", "description": "A k6 extension that makes k6 metrics available on a web-based dashboard.", "homepage": "https://github.com/grafana/xk6-dashboard", "license": "AGPL-3.0", @@ -138,6 +139,7 @@ Registry generated from the source above. "oss" ], "repo": { + "clone_url": "https://github.com/grafana/xk6-sql.git", "description": "k6 extension to load test RDBMSs (PostgreSQL, MySQL, MS SQL and SQLite3)", "homepage": "https://github.com/grafana/xk6-sql", "license": "Apache-2.0", @@ -177,6 +179,7 @@ Registry generated from the source above. "oss" ], "repo": { + "clone_url": "https://github.com/grafana/xk6-disruptor.git", "description": "Extension for injecting faults into k6 tests", "homepage": "https://k6.io/docs/javascript-api/xk6-disruptor/", "license": "AGPL-3.0", @@ -231,6 +234,7 @@ Registry generated from the source above. "oss" ], "repo": { + "clone_url": "https://github.com/szkiba/xk6-faker.git", "description": "Random fake data generator for k6.", "homepage": "http://ivan.szkiba.hu/xk6-faker/", "license": "AGPL-3.0", @@ -268,6 +272,7 @@ Registry generated from the source above. "oss" ], "repo": { + "clone_url": "https://gitlab.com/szkiba/xk6-banner.git", "description": "Print ASCII art banner from k6 test.", "homepage": "https://gitlab.com/szkiba/xk6-banner", "license": "MIT", @@ -296,6 +301,7 @@ Registry generated from the source above. "oss" ], "repo": { + "clone_url": "https://github.com/grafana/k6.git", "description": "A modern load testing tool, using Go and JavaScript - https://k6.io", "homepage": "https://github.com/grafana/k6", "license": "AGPL-3.0", diff --git a/cmd/load.go b/cmd/load.go index 725dc23..9c8bdcd 100644 --- a/cmd/load.go +++ b/cmd/load.go @@ -172,6 +172,8 @@ func loadGitHub(ctx context.Context, module string) (*k6registry.Repository, err repo.Timestamp = float64(ts.Unix()) } + repo.CloneUrl = rep.GetCloneURL() + tags, _, err := client.Repositories.ListTags(ctx, owner, name, &github.ListOptions{PerPage: 100}) if err != nil { return nil, err @@ -217,6 +219,8 @@ func loadGitLab(ctx context.Context, module string) (*k6registry.Repository, err repo.Topics = proj.Topics repo.Public = len(proj.Visibility) == 0 || proj.Visibility == gitlab.PublicVisibility + repo.CloneUrl = proj.HTTPURLToRepo + if proj.LastActivityAt != nil { repo.Timestamp = float64(proj.LastActivityAt.Unix()) } diff --git a/docs/example.json b/docs/example.json index ab3132d..86a253b 100644 --- a/docs/example.json +++ b/docs/example.json @@ -13,6 +13,7 @@ "oss" ], "repo": { + "clone_url": "https://github.com/grafana/xk6-dashboard.git", "description": "A k6 extension that makes k6 metrics available on a web-based dashboard.", "homepage": "https://github.com/grafana/xk6-dashboard", "license": "AGPL-3.0", @@ -80,6 +81,7 @@ "oss" ], "repo": { + "clone_url": "https://github.com/grafana/xk6-sql.git", "description": "k6 extension to load test RDBMSs (PostgreSQL, MySQL, MS SQL and SQLite3)", "homepage": "https://github.com/grafana/xk6-sql", "license": "Apache-2.0", @@ -119,6 +121,7 @@ "oss" ], "repo": { + "clone_url": "https://github.com/grafana/xk6-disruptor.git", "description": "Extension for injecting faults into k6 tests", "homepage": "https://k6.io/docs/javascript-api/xk6-disruptor/", "license": "AGPL-3.0", @@ -173,6 +176,7 @@ "oss" ], "repo": { + "clone_url": "https://github.com/szkiba/xk6-faker.git", "description": "Random fake data generator for k6.", "homepage": "http://ivan.szkiba.hu/xk6-faker/", "license": "AGPL-3.0", @@ -210,6 +214,7 @@ "oss" ], "repo": { + "clone_url": "https://gitlab.com/szkiba/xk6-banner.git", "description": "Print ASCII art banner from k6 test.", "homepage": "https://gitlab.com/szkiba/xk6-banner", "license": "MIT", @@ -238,6 +243,7 @@ "oss" ], "repo": { + "clone_url": "https://github.com/grafana/k6.git", "description": "A modern load testing tool, using Go and JavaScript - https://k6.io", "homepage": "https://github.com/grafana/k6", "license": "AGPL-3.0", diff --git a/docs/registry.md b/docs/registry.md index 71bdd99..270b787 100644 --- a/docs/registry.md +++ b/docs/registry.md @@ -180,6 +180,10 @@ The `timestamp` property contains the timestamp of the last modification of the Its value depends on the repository manager, in the case of GitHub it contains the time of the last push operation, in the case of GitLab the time of the last repository activity. +#### Clone URL + +The `clone_url` property contains a (typically HTTP) URL, which is used to clone the repository. + ## Registry Processing The source of the registry is a YAML file optimized for human use. Since collecting extension metadata is a complicated and time-consuming task, it is advisable to extract this step into a registry generator CLI tool. The output of this tool is an extension registry in JSON format. diff --git a/docs/registry.schema.json b/docs/registry.schema.json index 6ad5952..52aff50 100644 --- a/docs/registry.schema.json +++ b/docs/registry.schema.json @@ -158,6 +158,12 @@ "type": "number", "default": 0, "description": "Last modification timestamp.\n\nThe timestamp property contains the timestamp of the last modification of the repository in UNIX time format (the number of non-leap seconds that have elapsed since 00:00:00 UTC on 1st January 1970).\nIts value depends on the repository manager, in the case of GitHub it contains the time of the last push operation, in the case of GitLab the time of the last repository activity.\n" + }, + "clone_url": { + "type": "string", + "format": "uri", + "default": "", + "description": "URL for the git clone operation.\n\nThe clone_url property contains a (typically HTTP) URL, which is used to clone the repository.\n" } } }, diff --git a/docs/registry.schema.yaml b/docs/registry.schema.yaml index c6bf8f1..93578b6 100644 --- a/docs/registry.schema.yaml +++ b/docs/registry.schema.yaml @@ -223,6 +223,14 @@ $defs: The timestamp property contains the timestamp of the last modification of the repository in UNIX time format (the number of non-leap seconds that have elapsed since 00:00:00 UTC on 1st January 1970). Its value depends on the repository manager, in the case of GitHub it contains the time of the last push operation, in the case of GitLab the time of the last repository activity. + clone_url: + type: string + format: uri + default: "" + description: | + URL for the git clone operation. + + The clone_url property contains a (typically HTTP) URL, which is used to clone the repository. tier: type: string enum: ["official", "partner", "community"] diff --git a/registry_gen.go b/registry_gen.go index 2da323b..d200978 100644 --- a/registry_gen.go +++ b/registry_gen.go @@ -163,6 +163,13 @@ type Repository struct { // Archived bool `json:"archived,omitempty" yaml:"archived,omitempty" mapstructure:"archived,omitempty"` + // URL for the git clone operation. + // + // The clone_url property contains a (typically HTTP) URL, which is used to clone + // the repository. + // + CloneUrl string `json:"clone_url,omitempty" yaml:"clone_url,omitempty" mapstructure:"clone_url,omitempty"` + // Repository description. // Description string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` From 0600bed5785d1ea858c70a82d7c1f2336bd2476c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20SZKIBA?= Date: Fri, 23 Aug 2024 11:07:37 +0200 Subject: [PATCH 3/3] docs: release notes --- releases/v0.1.13.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 releases/v0.1.13.md diff --git a/releases/v0.1.13.md b/releases/v0.1.13.md new file mode 100644 index 0000000..9833c9b --- /dev/null +++ b/releases/v0.1.13.md @@ -0,0 +1,7 @@ +k6registry `v0.1.13` is here 🎉! + +This is an internal maintenance release. + +## Add repo metadata for linter support + +Add last modification (`timestamp`) and git clone URL (`clone_url`) repository metadata to support implementation of extension linter.