Skip to content

Commit dfec9d4

Browse files
authored
Merge pull request #37 from grafana/36-add-repo-metadata-for-linter-support
added repo metadata for linter support
2 parents 883edc5 + 0600bed commit dfec9d4

File tree

8 files changed

+102
-2
lines changed

8 files changed

+102
-2
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,15 @@ Registry generated from the source above.
7171
"oss"
7272
],
7373
"repo": {
74+
"clone_url": "https://github.com/grafana/xk6-dashboard.git",
7475
"description": "A k6 extension that makes k6 metrics available on a web-based dashboard.",
7576
"homepage": "https://github.com/grafana/xk6-dashboard",
7677
"license": "AGPL-3.0",
7778
"name": "xk6-dashboard",
7879
"owner": "grafana",
7980
"public": true,
8081
"stars": 325,
82+
"timestamp": 1719907965,
8183
"topics": [
8284
"xk6",
8385
"xk6-official",
@@ -137,13 +139,15 @@ Registry generated from the source above.
137139
"oss"
138140
],
139141
"repo": {
142+
"clone_url": "https://github.com/grafana/xk6-sql.git",
140143
"description": "k6 extension to load test RDBMSs (PostgreSQL, MySQL, MS SQL and SQLite3)",
141144
"homepage": "https://github.com/grafana/xk6-sql",
142145
"license": "Apache-2.0",
143146
"name": "xk6-sql",
144147
"owner": "grafana",
145148
"public": true,
146149
"stars": 104,
150+
"timestamp": 1721400602,
147151
"topics": [
148152
"k6",
149153
"sql",
@@ -175,13 +179,15 @@ Registry generated from the source above.
175179
"oss"
176180
],
177181
"repo": {
182+
"clone_url": "https://github.com/grafana/xk6-disruptor.git",
178183
"description": "Extension for injecting faults into k6 tests",
179184
"homepage": "https://k6.io/docs/javascript-api/xk6-disruptor/",
180185
"license": "AGPL-3.0",
181186
"name": "xk6-disruptor",
182187
"owner": "grafana",
183188
"public": true,
184189
"stars": 88,
190+
"timestamp": 1724358828,
185191
"topics": [
186192
"chaos-engineering",
187193
"fault-injection",
@@ -228,13 +234,15 @@ Registry generated from the source above.
228234
"oss"
229235
],
230236
"repo": {
237+
"clone_url": "https://github.com/szkiba/xk6-faker.git",
231238
"description": "Random fake data generator for k6.",
232239
"homepage": "http://ivan.szkiba.hu/xk6-faker/",
233240
"license": "AGPL-3.0",
234241
"name": "xk6-faker",
235242
"owner": "szkiba",
236243
"public": true,
237244
"stars": 49,
245+
"timestamp": 1719935566,
238246
"topics": [
239247
"xk6",
240248
"xk6-javascript-k6-x-faker"
@@ -264,12 +272,14 @@ Registry generated from the source above.
264272
"oss"
265273
],
266274
"repo": {
275+
"clone_url": "https://gitlab.com/szkiba/xk6-banner.git",
267276
"description": "Print ASCII art banner from k6 test.",
268277
"homepage": "https://gitlab.com/szkiba/xk6-banner",
269278
"license": "MIT",
270279
"name": "xk6-banner",
271280
"owner": "szkiba",
272281
"public": true,
282+
"timestamp": 1724312566,
273283
"topics": [
274284
"xk6"
275285
],
@@ -291,13 +301,13 @@ Registry generated from the source above.
291301
"oss"
292302
],
293303
"repo": {
304+
"clone_url": "https://github.com/grafana/k6.git",
294305
"description": "A modern load testing tool, using Go and JavaScript - https://k6.io",
295306
"homepage": "https://github.com/grafana/k6",
296307
"license": "AGPL-3.0",
297308
"name": "k6",
298309
"owner": "grafana",
299310
"public": true,
300-
"stars": 24302,
301311
"topics": [
302312
"es6",
303313
"go",

cmd/load.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ func loadRepository(ctx context.Context, module string) (*k6registry.Repository,
100100
return nil, err
101101
}
102102

103+
// Some unused metadata in the k6 repository changes too often
104+
if strings.HasPrefix(module, k6Module) {
105+
repo.Stars = 0
106+
repo.Timestamp = 0
107+
}
108+
103109
return repo, nil
104110
}
105111

@@ -162,6 +168,12 @@ func loadGitHub(ctx context.Context, module string) (*k6registry.Repository, err
162168

163169
repo.Public = rep.GetVisibility() == "public"
164170

171+
if ts := rep.GetPushedAt(); !ts.IsZero() {
172+
repo.Timestamp = float64(ts.Unix())
173+
}
174+
175+
repo.CloneUrl = rep.GetCloneURL()
176+
165177
tags, _, err := client.Repositories.ListTags(ctx, owner, name, &github.ListOptions{PerPage: 100})
166178
if err != nil {
167179
return nil, err
@@ -207,6 +219,12 @@ func loadGitLab(ctx context.Context, module string) (*k6registry.Repository, err
207219
repo.Topics = proj.Topics
208220
repo.Public = len(proj.Visibility) == 0 || proj.Visibility == gitlab.PublicVisibility
209221

222+
repo.CloneUrl = proj.HTTPURLToRepo
223+
224+
if proj.LastActivityAt != nil {
225+
repo.Timestamp = float64(proj.LastActivityAt.Unix())
226+
}
227+
210228
if proj.License != nil {
211229
for key := range validLicenses {
212230
if strings.EqualFold(key, proj.License.Key) {

docs/example.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
"oss"
1414
],
1515
"repo": {
16+
"clone_url": "https://github.com/grafana/xk6-dashboard.git",
1617
"description": "A k6 extension that makes k6 metrics available on a web-based dashboard.",
1718
"homepage": "https://github.com/grafana/xk6-dashboard",
1819
"license": "AGPL-3.0",
1920
"name": "xk6-dashboard",
2021
"owner": "grafana",
2122
"public": true,
2223
"stars": 325,
24+
"timestamp": 1719907965,
2325
"topics": [
2426
"xk6",
2527
"xk6-official",
@@ -79,13 +81,15 @@
7981
"oss"
8082
],
8183
"repo": {
84+
"clone_url": "https://github.com/grafana/xk6-sql.git",
8285
"description": "k6 extension to load test RDBMSs (PostgreSQL, MySQL, MS SQL and SQLite3)",
8386
"homepage": "https://github.com/grafana/xk6-sql",
8487
"license": "Apache-2.0",
8588
"name": "xk6-sql",
8689
"owner": "grafana",
8790
"public": true,
8891
"stars": 104,
92+
"timestamp": 1721400602,
8993
"topics": [
9094
"k6",
9195
"sql",
@@ -117,13 +121,15 @@
117121
"oss"
118122
],
119123
"repo": {
124+
"clone_url": "https://github.com/grafana/xk6-disruptor.git",
120125
"description": "Extension for injecting faults into k6 tests",
121126
"homepage": "https://k6.io/docs/javascript-api/xk6-disruptor/",
122127
"license": "AGPL-3.0",
123128
"name": "xk6-disruptor",
124129
"owner": "grafana",
125130
"public": true,
126131
"stars": 88,
132+
"timestamp": 1724358828,
127133
"topics": [
128134
"chaos-engineering",
129135
"fault-injection",
@@ -170,13 +176,15 @@
170176
"oss"
171177
],
172178
"repo": {
179+
"clone_url": "https://github.com/szkiba/xk6-faker.git",
173180
"description": "Random fake data generator for k6.",
174181
"homepage": "http://ivan.szkiba.hu/xk6-faker/",
175182
"license": "AGPL-3.0",
176183
"name": "xk6-faker",
177184
"owner": "szkiba",
178185
"public": true,
179186
"stars": 49,
187+
"timestamp": 1719935566,
180188
"topics": [
181189
"xk6",
182190
"xk6-javascript-k6-x-faker"
@@ -206,12 +214,14 @@
206214
"oss"
207215
],
208216
"repo": {
217+
"clone_url": "https://gitlab.com/szkiba/xk6-banner.git",
209218
"description": "Print ASCII art banner from k6 test.",
210219
"homepage": "https://gitlab.com/szkiba/xk6-banner",
211220
"license": "MIT",
212221
"name": "xk6-banner",
213222
"owner": "szkiba",
214223
"public": true,
224+
"timestamp": 1724312566,
215225
"topics": [
216226
"xk6"
217227
],
@@ -233,13 +243,13 @@
233243
"oss"
234244
],
235245
"repo": {
246+
"clone_url": "https://github.com/grafana/k6.git",
236247
"description": "A modern load testing tool, using Go and JavaScript - https://k6.io",
237248
"homepage": "https://github.com/grafana/k6",
238249
"license": "AGPL-3.0",
239250
"name": "k6",
240251
"owner": "grafana",
241252
"public": true,
242-
"stars": 24302,
243253
"topics": [
244254
"es6",
245255
"go",

docs/registry.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ The `true` value of the `archived` flag indicates that the repository is archive
174174

175175
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.
176176

177+
#### Timestamp
178+
179+
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).
180+
181+
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.
182+
183+
#### Clone URL
184+
185+
The `clone_url` property contains a (typically HTTP) URL, which is used to clone the repository.
186+
177187
## Registry Processing
178188

179189
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.

docs/registry.schema.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@
153153
"type": "boolean",
154154
"default": "false",
155155
"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"
156+
},
157+
"timestamp": {
158+
"type": "number",
159+
"default": 0,
160+
"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"
161+
},
162+
"clone_url": {
163+
"type": "string",
164+
"format": "uri",
165+
"default": "",
166+
"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"
156167
}
157168
}
158169
},

docs/registry.schema.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,22 @@ $defs:
215215
A `true` value indicates that the repository is archived, read only.
216216
217217
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.
218+
timestamp:
219+
type: number
220+
default: 0
221+
description: |
222+
Last modification timestamp.
223+
224+
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).
225+
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.
226+
clone_url:
227+
type: string
228+
format: uri
229+
default: ""
230+
description: |
231+
URL for the git clone operation.
232+
233+
The clone_url property contains a (typically HTTP) URL, which is used to clone the repository.
218234
tier:
219235
type: string
220236
enum: ["official", "partner", "community"]

registry_gen.go

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

releases/v0.1.13.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
k6registry `v0.1.13` is here 🎉!
2+
3+
This is an internal maintenance release.
4+
5+
## Add repo metadata for linter support
6+
7+
Add last modification (`timestamp`) and git clone URL (`clone_url`) repository metadata to support implementation of extension linter.

0 commit comments

Comments
 (0)