forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbatch_spec.schema.json
More file actions
401 lines (401 loc) · 16.2 KB
/
batch_spec.schema.json
File metadata and controls
401 lines (401 loc) · 16.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
{
"$id": "batch_spec.schema.json#",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "BatchSpec",
"description": "A batch specification, which describes the batch change and what kinds of changes to make (or what existing changesets to track).",
"type": "object",
"additionalProperties": false,
"required": ["name"],
"properties": {
"name": {
"type": "string",
"description": "The name of the batch change, which is unique among all batch changes in the namespace. A batch change's name is case-preserving.",
"pattern": "^[\\w.-]+$"
},
"description": {
"type": "string",
"description": "The description of the batch change."
},
"on": {
"type": ["array", "null"],
"description": "The set of repositories (and branches) to run the batch change on, specified as a list of search queries (that match repositories) and/or specific repositories.",
"items": {
"title": "OnQueryOrRepository",
"oneOf": [
{
"title": "OnQuery",
"type": "object",
"description": "A Sourcegraph search query that matches a set of repositories (and branches). Each matched repository branch is added to the list of repositories that the batch change will be run on.",
"additionalProperties": false,
"required": ["repositoriesMatchingQuery"],
"properties": {
"repositoriesMatchingQuery": {
"type": "string",
"description": "A Sourcegraph search query that matches a set of repositories (and branches). If the query matches files, symbols, or some other object inside a repository, the object's repository is included.",
"examples": ["file:README.md"]
}
}
},
{
"title": "OnRepository",
"type": "object",
"description": "A specific repository (and branch) that is added to the list of repositories that the batch change will be run on.",
"additionalProperties": false,
"required": ["repository"],
"properties": {
"repository": {
"type": "string",
"description": "The name of the repository (as it is known to Sourcegraph).",
"examples": ["github.com/foo/bar"]
},
"branch": {
"description": "The repository branch to propose changes to. If unset, the repository's default branch is used. If this field is defined, branches cannot be.",
"type": "string"
},
"branches": {
"description": "The repository branches to propose changes to. If unset, the repository's default branch is used. If this field is defined, branch cannot be.",
"type": "array",
"items": {
"type": "string"
}
}
},
"$comment": "This is a convoluted way of saying either `branch` or `branches` can be provided, but not both at once, and neither are required.",
"anyOf": [
{
"oneOf": [
{
"required": ["branch"]
},
{
"required": ["branches"]
}
]
},
{
"not": {
"required": ["branch", "branches"]
}
}
]
}
]
}
},
"workspaces": {
"type": ["array", "null"],
"description": "Individual workspace configurations for one or more repositories that define which workspaces to use for the execution of steps in the repositories.",
"items": {
"title": "WorkspaceConfiguration",
"type": "object",
"description": "Configuration for how to setup workspaces in repositories",
"additionalProperties": false,
"required": ["rootAtLocationOf"],
"properties": {
"rootAtLocationOf": {
"type": "string",
"description": "The name of the file that sits at the root of the desired workspace.",
"examples": ["package.json", "go.mod", "Gemfile", "Cargo.toml", "README.md"]
},
"in": {
"type": "string",
"description": "The repositories in which to apply the workspace configuration. Supports globbing.",
"examples": ["github.com/sourcegraph/src-cli", "github.com/sourcegraph/*"]
},
"onlyFetchWorkspace": {
"type": "boolean",
"description": "If this is true only the files in the workspace (and additional .gitignore) are downloaded instead of an archive of the full repository.",
"default": false
}
}
}
},
"steps": {
"type": ["array", "null"],
"description": "The sequence of commands to run (for each repository branch matched in the `on` property) to produce the workspace changes that will be included in the batch change.",
"items": {
"title": "Step",
"type": "object",
"description": "A command to run (as part of a sequence) in a repository branch to produce the required changes.",
"additionalProperties": false,
"required": ["run", "container"],
"properties": {
"run": {
"type": "string",
"description": "The shell command to run in the container. It can also be a multi-line shell script. The working directory is the root directory of the repository checkout."
},
"container": {
"type": "string",
"description": "The Docker image used to launch the Docker container in which the shell command is run.",
"examples": ["alpine:3"]
},
"outputs": {
"type": ["object", "null"],
"description": "Output variables of this step that can be referenced in the changesetTemplate or other steps via outputs.<name-of-output>",
"additionalProperties": {
"title": "OutputVariable",
"type": "object",
"required": ["value"],
"properties": {
"value": {
"type": "string",
"description": "The value of the output, which can be a template string.",
"examples": ["hello world", "${{ step.stdout }}", "${{ repository.name }}"]
},
"format": {
"type": "string",
"description": "The expected format of the output. If set, the output is being parsed in that format before being stored in the var. If not set, 'text' is assumed to the format.",
"enum": ["json", "yaml", "text"]
}
}
}
},
"env": {
"description": "Environment variables to set in the step environment.",
"oneOf": [
{
"type": "null"
},
{
"type": "object",
"description": "Environment variables to set in the step environment.",
"additionalProperties": {
"type": "string"
}
},
{
"type": "array",
"items": {
"oneOf": [
{
"type": "string",
"description": "An environment variable to set in the step environment: the value will be passed through from the environment src is running within."
},
{
"type": "object",
"description": "An environment variable to set in the step environment: the key is used as the environment variable name and the value as the value.",
"additionalProperties": {
"type": "string"
},
"minProperties": 1,
"maxProperties": 1
}
]
}
}
]
},
"files": {
"type": ["object", "null"],
"description": "Files that should be mounted into or be created inside the Docker container.",
"additionalProperties": {
"type": "string"
}
},
"if": {
"oneOf": [
{
"type": "boolean"
},
{
"type": "string"
},
{
"type": "null"
}
],
"description": "A condition to check before executing steps. Supports templating. The value 'true' is interpreted as true.",
"examples": [
"true",
"${{ matches repository.name \"github.com/my-org/my-repo*\" }}",
"${{ outputs.goModFileExists }}",
"${{ eq previous_step.stdout \"success\" }}"
]
},
"mount": {
"description": "Files that are mounted to the Docker container.",
"type": ["array", "null"],
"items": {
"type": "object",
"additionalProperties": false,
"required": ["path", "mountpoint"],
"properties": {
"path": {
"type": "string",
"description": "The path on the local machine to mount. The path must be in the same directory or a subdirectory of the batch spec.",
"examples": ["local/path/to/file.text", "local/path/to/directory"]
},
"mountpoint": {
"type": "string",
"description": "The path in the container to mount the path on the local machine to.",
"examples": ["path/to/file.txt", "path/to/directory"]
}
}
}
}
}
}
},
"transformChanges": {
"type": ["object", "null"],
"description": "Optional transformations to apply to the changes produced in each repository.",
"additionalProperties": false,
"properties": {
"group": {
"type": ["array", "null"],
"description": "A list of groups of changes in a repository that each create a separate, additional changeset for this repository, with all ungrouped changes being in the default changeset.",
"items": {
"title": "TransformChangesGroup",
"type": "object",
"additionalProperties": false,
"required": ["directory", "branch"],
"properties": {
"directory": {
"type": "string",
"description": "The directory path (relative to the repository root) of the changes to include in this group.",
"minLength": 1
},
"branch": {
"type": "string",
"description": "The branch on the repository to propose changes to. If unset, the repository's default branch is used.",
"minLength": 1
},
"repository": {
"type": "string",
"description": "Only apply this transformation in the repository with this name (as it is known to Sourcegraph).",
"examples": ["github.com/foo/bar"]
}
}
}
}
}
},
"importChangesets": {
"type": ["array", "null"],
"description": "Import existing changesets on code hosts.",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["repository", "externalIDs"],
"properties": {
"repository": {
"type": "string",
"description": "The repository name as configured on your Sourcegraph instance."
},
"externalIDs": {
"type": ["array", "null"],
"description": "The changesets to import from the code host. For GitHub this is the PR number, for GitLab this is the MR number, for Bitbucket Server this is the PR number.",
"uniqueItems": true,
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"examples": [120, "120"]
}
}
}
},
"changesetTemplate": {
"type": "object",
"description": "A template describing how to create (and update) changesets with the file changes produced by the command steps.",
"additionalProperties": false,
"required": ["title", "branch", "commit"],
"properties": {
"title": {
"type": "string",
"description": "The title of the changeset."
},
"body": {
"type": "string",
"description": "The body (description) of the changeset."
},
"branch": {
"type": "string",
"description": "The name of the Git branch to create or update on each repository with the changes."
},
"fork": {
"type": "boolean",
"description": "Whether to publish the changeset to a fork of the target repository. If omitted, the changeset will be published to a branch directly on the target repository, unless the global `batches.enforceFork` setting is enabled. If set, this property will override any global setting."
},
"commit": {
"title": "ExpandedGitCommitDescription",
"type": "object",
"description": "The Git commit to create with the changes.",
"additionalProperties": false,
"required": ["message"],
"properties": {
"message": {
"type": "string",
"description": "The Git commit message."
},
"author": {
"title": "GitCommitAuthor",
"type": "object",
"description": "The author of the Git commit.",
"additionalProperties": false,
"required": ["name", "email"],
"properties": {
"name": {
"type": "string",
"description": "The Git commit author name."
},
"email": {
"type": "string",
"format": "email",
"description": "The Git commit author email."
}
}
}
}
},
"published": {
"description": "Whether to publish the changeset. An unpublished changeset can be previewed on Sourcegraph by any person who can view the batch change, but its commit, branch, and pull request aren't created on the code host. A published changeset results in a commit, branch, and pull request being created on the code host. If omitted, the publication state is controlled from the Batch Changes UI.",
"oneOf": [
{
"type": "null"
},
{
"oneOf": [
{
"type": "boolean"
},
{
"type": "string",
"pattern": "^draft$"
}
],
"description": "A single flag to control the publishing state for the entire batch change."
},
{
"type": "array",
"description": "A list of glob patterns to match repository names. In the event multiple patterns match, the last matching pattern in the list will be used.",
"items": {
"type": "object",
"description": "An object with one field: the key is the glob pattern to match against repository names; the value will be used as the published flag for matching repositories.",
"additionalProperties": {
"oneOf": [
{
"type": "boolean"
},
{
"type": "string",
"pattern": "^draft$"
}
]
},
"minProperties": 1,
"maxProperties": 1
}
}
]
}
}
}
}
}