~sircmpwn/builds.sr.ht

builds.sr.ht/api/graph/schema.graphqls -rw-r--r-- 7.3 KiB
48fa5794Dhruvin Gandhi alpine: run setup-timezone conditionally 6 days ago
                                                                                
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
# This schema definition is available in the public domain, or under the terms
# of CC-0, at your choice.
scalar Time   # %Y-%m-%dT%H:%M:%SZ
scalar Binary # base64'd string
scalar Cursor
scalar File

"Used to provide a human-friendly description of an access scope"
directive @scopehelp(details: String!) on ENUM_VALUE

enum AccessScope {
  PROFILE @scopehelp(details: "profile information")
  JOBS    @scopehelp(details: "build jobs")
  LOGS    @scopehelp(details: "build logs")
  SECRETS @scopehelp(details: "stored secrets")
}

enum AccessKind {
  RO @scopehelp(details: "read")
  RW @scopehelp(details: "read and write")
}

"""
Decorates fields for which access requires a particular OAuth 2.0 scope with
read or write access.
"""
directive @access(scope: AccessScope!, kind: AccessKind!) on FIELD_DEFINITION

"""
This used to decorate private resolvers which are only accessible to build
workers, and are used to faciliate the build process.
"""
directive @worker on FIELD_DEFINITION

# https://semver.org
type Version {
  major: Int!
  minor: Int!
  patch: Int!

  """
  If this API version is scheduled for deprecation, this is the date on which
  it will stop working; or null if this API version is not scheduled for
  deprecation.
  """
  deprecationDate: Time

  # Config settings
  settings: Settings!
}

# Instance specific settings
type Settings {
  sshUser: String!
  buildTimeout: String!
}

interface Entity {
  id: Int!
  created: Time!
  updated: Time!
  """
  The canonical name of this entity. For users, this is their username
  prefixed with '~'. Additional entity types will be supported in the future.
  """
  canonicalName: String!
}

type User implements Entity {
  id: Int!
  created: Time!
  updated: Time!
  canonicalName: String!
  username: String!
  email: String!
  url: String
  location: String
  bio: String

  "Jobs submitted by this user."
  jobs(cursor: Cursor): JobCursor! @access(scope: JOBS, kind: RO)
}

enum JobStatus {
  PENDING
  QUEUED
  RUNNING
  SUCCESS
  FAILED
  TIMEOUT
  CANCELLED
}

type Job {
  id: Int!
  created: Time!
  updated: Time!
  status: JobStatus!
  manifest: String!
  note: String
  tags: [String!]!

  "Name of the build image"
  image: String!

  """
  Name of the build runner which picked up this job, or null if the job is
  pending or queued.
  """
  runner: String

  owner: Entity! @access(scope: PROFILE, kind: RO)
  group: JobGroup
  tasks: [Task!]!
  artifacts: [Artifact!]!

  "The job's top-level log file, not associated with any tasks"
  log: Log @access(scope: LOGS, kind: RO)

  "List of secrets available to this job, or null if they were disabled"
  secrets: [Secret!] @access(scope: SECRETS, kind: RO)
}

type Log {
  "The most recently written 128 KiB of the build log."
  last128KiB: String!
  """
  The URL at which the full build log can be downloaded with a GET request
  (text/plain).
  """
  fullURL: String!
}

type Artifact {
  id: Int!
  created: Time!
  "Original path in the guest"
  path: String!
  "Size in bytes"
  size: Int!
  "URL at which the artifact may be downloaded, or null if pruned"
  url: String
}

"""
A cursor for enumerating a list of jobs

If there are additional results available, the cursor object may be passed
back into the same endpoint to retrieve another page. If the cursor is null,
there are no remaining results to return.
"""
type JobCursor {
  results: [Job!]!
  cursor: Cursor
}

type JobGroup {
  id: Int!
  created: Time!
  note: String
  owner: Entity! @access(scope: PROFILE, kind: RO)
  jobs: [Job!]!
  triggers: [Trigger!]!
}

enum TaskStatus {
  PENDING
  RUNNING
  SUCCESS
  FAILED
  SKIPPED
}

type Task {
  id: Int!
  created: Time!
  updated: Time!
  name: String!
  status: TaskStatus!
  log: Log @access(scope: LOGS, kind: RO)
  job: Job!
}

enum TriggerCondition {
  SUCCESS
  FAILURE
  ALWAYS
}

"""
Triggers run upon the completion of all of the jobs in a job group. Note that
these triggers are distinct from the ones defined by an individual job's
build manifest, but are similar in functionality.
"""
interface Trigger {
  condition: TriggerCondition!
}

type EmailTrigger implements Trigger {
  condition: TriggerCondition!
  to: String!
  cc: String
  inReplyTo: String
}

type WebhookTrigger implements Trigger {
  condition: TriggerCondition!
  url: String!
}

interface Secret {
  id: Int!
  created: Time!
  uuid: String!
  name: String
}

"""
A cursor for enumerating a list of secrets

If there are additional results available, the cursor object may be passed
back into the same endpoint to retrieve another page. If the cursor is null,
there are no remaining results to return.
"""
type SecretCursor {
  results: [Secret!]!
  cursor: Cursor
}

type SSHKey implements Secret {
  id: Int!
  created: Time!
  uuid: String!
  name: String
  privateKey: Binary! @worker
}

type PGPKey implements Secret {
  id: Int!
  created: Time!
  uuid: String!
  name: String
  privateKey: Binary! @worker
}

type SecretFile implements Secret {
  id: Int!
  created: Time!
  uuid: String!
  name: String
  path: String!
  mode: Int!
  data: Binary! @worker
}

type Query {
  "Returns API version information."
  version: Version!

  "Returns the authenticated user."
  me: User! @access(scope: PROFILE, kind: RO)

  "Returns a specific user."
  userByID(id: Int!): User @access(scope: PROFILE, kind: RO)
  userByName(username: String!): User @access(scope: PROFILE, kind: RO)

  "Returns jobs submitted by the authenticated user."
  jobs(cursor: Cursor): JobCursor! @access(scope: JOBS, kind: RO)

  "Returns information about a specific job."
  job(id: Int!): Job @access(scope: JOBS, kind: RO)

  "Returns secrets owned by the authenticated user."
  secrets(cursor: Cursor): SecretCursor! @access(scope: SECRETS, kind: RO)
}

enum TriggerType {
  EMAIL
  WEBHOOK
}

input EmailTriggerInput {
  to: String!
  cc: String
  inReplyTo: String
}

input WebhookTriggerInput {
  url: String!
}

input TriggerInput {
  type: TriggerType!
  condition: TriggerCondition!
  email: EmailTriggerInput
  webhook: WebhookTriggerInput
}

type Mutation {
  """
  Submits a new job to the queue.

  'secrets' may be set to false to disable secrets for this build. Secrets
  are enabled if unspecified.

  'execute' may be set to false to defer queueing this job. Builds are
  executed immediately if unspecified.
  """
  submit(manifest: String!, tags: [String!] note: String, secrets: Boolean,
    execute: Boolean): Job! @access(scope: JOBS, kind: RW)

  "Queues a pending job."
  start(jobID: Int!): Job @access(scope: JOBS, kind: RW)

  "Cancels a submitted job."
  cancel(jobId: Int!): Job @access(scope: JOBS, kind: RW)

  """
  Creates a job group from several pending jobs.

  'execute' may be set to false to defer queueing this job. The job group is
  executed immediately if unspecified.
  """
  createGroup(jobIds: [Int!]!  triggers: [TriggerInput!],
    execute: Boolean, note: String): JobGroup! @access(scope: JOBS, kind: RW)

  "Starts a pending job group."
  startGroup(groupId: Int!): JobGroup @access(scope: JOBS, kind: RW)

  ###
  ### The following resolvers are for internal worker use

  "Claims a job."
  claim(jobId: Int!): Job @worker

  "Updates job status."
  updateJob(jobId: Int!, status: JobStatus!): Job @worker

  "Updates task status."
  updateTask(taskId: Int!, status: TaskStatus!): Job @worker

  "Uploads a build artifact."
  createArtifact(jobId: Int!, path: String!, contents: File!): Artifact @worker
}