Skip to content

Commit

Permalink
Merge pull request #37 from grafana/36-add-repo-metadata-for-linter-s…
Browse files Browse the repository at this point in the history
…upport

added repo metadata for linter support
  • Loading branch information
szkiba authored Aug 23, 2024
2 parents 883edc5 + 0600bed commit dfec9d4
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 2 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ 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",
"name": "xk6-dashboard",
"owner": "grafana",
"public": true,
"stars": 325,
"timestamp": 1719907965,
"topics": [
"xk6",
"xk6-official",
Expand Down Expand Up @@ -137,13 +139,15 @@ 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",
"name": "xk6-sql",
"owner": "grafana",
"public": true,
"stars": 104,
"timestamp": 1721400602,
"topics": [
"k6",
"sql",
Expand Down Expand Up @@ -175,13 +179,15 @@ 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",
"name": "xk6-disruptor",
"owner": "grafana",
"public": true,
"stars": 88,
"timestamp": 1724358828,
"topics": [
"chaos-engineering",
"fault-injection",
Expand Down Expand Up @@ -228,13 +234,15 @@ 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",
"name": "xk6-faker",
"owner": "szkiba",
"public": true,
"stars": 49,
"timestamp": 1719935566,
"topics": [
"xk6",
"xk6-javascript-k6-x-faker"
Expand Down Expand Up @@ -264,12 +272,14 @@ 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",
"name": "xk6-banner",
"owner": "szkiba",
"public": true,
"timestamp": 1724312566,
"topics": [
"xk6"
],
Expand All @@ -291,13 +301,13 @@ 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",
"name": "k6",
"owner": "grafana",
"public": true,
"stars": 24302,
"topics": [
"es6",
"go",
Expand Down
18 changes: 18 additions & 0 deletions cmd/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -162,6 +168,12 @@ 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())
}

repo.CloneUrl = rep.GetCloneURL()

tags, _, err := client.Repositories.ListTags(ctx, owner, name, &github.ListOptions{PerPage: 100})
if err != nil {
return nil, err
Expand Down Expand Up @@ -207,6 +219,12 @@ 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())
}

if proj.License != nil {
for key := range validLicenses {
if strings.EqualFold(key, proj.License.Key) {
Expand Down
12 changes: 11 additions & 1 deletion docs/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
"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",
"name": "xk6-dashboard",
"owner": "grafana",
"public": true,
"stars": 325,
"timestamp": 1719907965,
"topics": [
"xk6",
"xk6-official",
Expand Down Expand Up @@ -79,13 +81,15 @@
"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",
"name": "xk6-sql",
"owner": "grafana",
"public": true,
"stars": 104,
"timestamp": 1721400602,
"topics": [
"k6",
"sql",
Expand Down Expand Up @@ -117,13 +121,15 @@
"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",
"name": "xk6-disruptor",
"owner": "grafana",
"public": true,
"stars": 88,
"timestamp": 1724358828,
"topics": [
"chaos-engineering",
"fault-injection",
Expand Down Expand Up @@ -170,13 +176,15 @@
"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",
"name": "xk6-faker",
"owner": "szkiba",
"public": true,
"stars": 49,
"timestamp": 1719935566,
"topics": [
"xk6",
"xk6-javascript-k6-x-faker"
Expand Down Expand Up @@ -206,12 +214,14 @@
"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",
"name": "xk6-banner",
"owner": "szkiba",
"public": true,
"timestamp": 1724312566,
"topics": [
"xk6"
],
Expand All @@ -233,13 +243,13 @@
"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",
"name": "k6",
"owner": "grafana",
"public": true,
"stars": 24302,
"topics": [
"es6",
"go",
Expand Down
10 changes: 10 additions & 0 deletions docs/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ 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.

#### 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.
Expand Down
11 changes: 11 additions & 0 deletions docs/registry.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@
"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"
},
"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"
}
}
},
Expand Down
16 changes: 16 additions & 0 deletions docs/registry.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,22 @@ $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.
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"]
Expand Down
18 changes: 18 additions & 0 deletions registry_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions releases/v0.1.13.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit dfec9d4

Please sign in to comment.