aboutsummaryrefslogtreecommitdiff
path: root/bdep/ci.cli
blob: 65ae252e3885666aed1ccd41af711b86dc9d4f90 (plain)
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
// file      : bdep/ci.cli
// license   : MIT; see accompanying LICENSE file

include <bdep/project.cli>;
include <bdep/ci-types.hxx>;

"\section=1"
"\name=bdep-ci"
"\summary=submit project test request to CI server"

namespace bdep
{
  {
    "<options>
     <prj-spec> <prj-dir>
     <pkg-spec> <pkg-dir>
     <cfg-spec> <cfg-name> <cfg-dir>",

    "\h|SYNOPSIS|

     \c{\b{bdep ci} [<options>] [<cfg-spec>] [<pkg-spec>]}

     \c{<cfg-spec> = (\b{@}<cfg-name> | \b{--config}|\b{-c} <cfg-dir>)... | \b{--all}|\b{-a} | \b{--forward}\n
        <pkg-spec> = (\b{--directory}|\b{-d} <pkg-dir>)... | <prj-spec>\n
        <prj-spec> = \b{--directory}|\b{-d} <prj-dir>}

     \h|DESCRIPTION|

     The \cb{ci} command submits the project packages test request to a CI
     server.

     If no project or package directory is specified, then the current working
     directory is assumed. If no configuration is specified, then the default
     configurations are used. If the specified directory is a project
     directory, then all the packages initialized in the configurations are
     submitted, unless the \cb{--forward} option is specified (see below). See
     \l{bdep-projects-configs(1)} for details on specifying projects and
     configurations.

     A CI request consists of the specified packages and their versions as
     well as the project's remote version control repository URL corresponding
     to the current (local) state of the project. The CI server should be able
     to fetch these package versions from this repository as well as any
     dependencies from this repository or its prerequisite/complement
     repositories, according to each package's \cb{repositories.manifest}.

     If the CI server is not explicitly specified with the \cb{--server}
     option, the request is submitted to \cb{ci.cppget.org} by default.

     Unless the remote repository URL is specified with the \cb{--repository}
     option, it will be automatically derived from the version control's
     \"remote\" URL. In case of \cb{git(1)}, it will be based on the
     \cb{remote.origin.url} configuration value unless overridden with
     \cb{remote.origin.build2Url}. The repository URL is then adjusted to
     corresponding to the current (local) state of the project. In case of
     \cb{git(1)}, the current branch and commit id are added as the repository
     URL fragment (see \l{bpkg-repository-types(1)} for details).

     Some package manifest values can be overridden as part of the CI request
     submission using the \cb{--override} and \cb{--overrides-file} options as
     well as their \cb{--builds}, \cb{--build-config}, \cb{--target-config},
     \cb{--package-config}, and \cb{--build-email} shortcuts. This is
     primarily useful for specifying alternative build configurations and/or
     build notification emails. For example:

     \
     $ bdep ci --builds gcc
     $ bdep ci --builds network/gcc
     $ bdep ci --target-config 'linux*-gcc*'
     $ bdep ci --package-config network
     $ bdep ci --build-config 'network/linux*-gcc*'

     $ bdep ci --override \
       'default-build-config: config.foo.cache=true config.foo.buffer=16'

     $ bdep ci --override 'mytest-build-config: config.foo.cache=true' \
       --package-config mytest

     $ bdep ci --override 'build-auxiliary: *-postgresql_16'
     \

     Manifest overrides other than \c{[\b{*-}]\b{build-auxiliary}[\b{-*}]}
     override the entire value group that they belong to. The
     \c{[\b{*-}]\b{build-auxiliary}[\b{-*}]} values only override the matching
     values, which are expected to already be present in the package manifest.
     Currently, the following value groups/values can be overridden. The
     \cb{build-*email} group is overridden by default as if by specifying an
     empty build email.

     \
     build-email build-{warning,error}-email
     builds build-{include,exclude}
     build-bot
     *-builds *-build-{include,exclude}
     *-build-bot
     *-build-config
     *-build-email *-build-{warning,error}-email

     [*-]build-auxiliary[-*]
     \

     For the package configuration-specific build constraint, email,
     auxiliary, and custom bot public key overrides, the corresponding
     configuration must exist in the package manifest. In contrast, the
     package configuration override (\cb{*-build-config}) adds a new
     configuration if it doesn't exist and updates the arguments of the
     existing configuration otherwise. In the former case, all the potential
     build constraint, email, auxiliary, and custom bot public key overrides
     for such a newly added configuration must follow the corresponding
     \cb{*-build-config} override.

     Note that the build constraints group values (both common and build
     package configuration-specific) are overridden hierarchically so that the
     \c{[\b{*-}]\b{build-}{\b{include},\b{exclude}\}} overrides don't affect
     the respective \c{[\b{*-}]\b{builds}} values.

     Note also that the common and build package configuration-specific build
     constraints group value overrides are mutually exclusive. If the common
     build constraints are overridden, then all the configuration-specific
     constraints are removed. Otherwise, if any configuration-specific
     constraints are overridden, then for the remaining configurations the
     build constraints are reset to \cb{builds:\ none}.

     Similar to the build constraints groups, the common and build package
     configuration-specific custom bot public key value overrides are mutually
     exclusive. If the common build custom bot public keys are overridden,
     then all the configuration-specific custom bot public keys are removed.
     Otherwise, if any configuration-specific custom bot public keys are
     overridden, then for the remaining configurations the custom bot public
     keys are left unchanged.

     Similar to the above, the common and build package configuration-specific
     build emails group value overrides are mutually exclusive. If the common
     build emails are overridden, then all the configuration-specific emails
     are removed. Otherwise, if any configuration-specific emails are
     overridden, then for the remaining configurations the build emails are
     reset to the empty values and the build warning and error emails are
     removed (which effectively disables email notifications for such
     configurations).

     If supported by the CI service, a package can be tested interactively
     in a specific build configuration using the \c{\b{--interactive}|\b{-i}}
     option. In this mode the CI service provides the login information for
     the execution environment and pauses the testing at the specified
     breakpoint.

     While the exact interpretation of the CI request depends on the specific
     service, normally, the CI server will respond with a reference that can
     be used to query the results. See \l{brep#ci Package CI} for details on
     the CI request handling.

     If the \cb{--forward} option is specified then the forwarded
     configurations are used instead of the default configurations. In
     particular, this means that in this mode the project doesn't need to be
     initialized and all that's required is for package's source directories
     to be configured to forward to an out of source build configuration (see
     \l{b(1)} for details on forwarded configurations). This, for example, can
     be used to submit packages that don't use the standard version.
     "
  }

  class cmd_ci_options: project_options
  {
    "\h|CI OPTIONS|"

    bool --yes|-y
    {
      "Don't prompt for confirmation before submitting."
    }

    string --interactive|-i
    {
      "<cf>[:<bp>]",
      "Test the package interactively in the specified build configuration,
       pausing the execution at the specified breakpoint. The build
       configuration is a target configuration (\ci{tc}), optionally for a
       specific package configuration (\ci{pc}) and/or for a specific target
       (\ci{tg}):

       \c{<cf> = [\i{pc}\b{/}]\i{tc} | \i{pc}\b{/}\i{tc}\b{/}\i{tg}}

       Refer to the \cb{--build-config} option for details on the build
       configuration component semantics. Note that for interactive testing
       they should identify a single build configuration. Failed that, the
       test request will be aborted.

       Valid breakpoint values are \cb{none} (don't stop), \cb{error} (stop
       after first error), \cb{warning} (stop after first warning), as well as
       the CI service-specific step ids in which case the execution stops
       before performing the specified step (see \l{bbot#arch-worker \cb{bbot}
       worker step ids}). If no breakpoint is specified, then \cb{error} is
       assumed."
    }

    url --server
    {
      "<url>",
      "CI server to submit the request to."
    }

    url --repository
    {
      "<url>",
      "Remote repository URL for the project."
    }

    // Note: the following options are for documentation only (see --overrides
    // below for details).
    //
    strings --override
    {
      "<name>:<value>",
      "Package manifest value override. Repeat this option to override
       multiple values."
    }

    path --overrides-file
    {
      "<file>",
      "Read manifest value overrides from the specified manifest fragment
       file. Repeat this option to specify multiple override files."
    }

    strings --builds
    {
      "[<pc>/]<class-expr>",
      "Shortcut for the following option:

       \c{\b{--override\ }[<pc>\b{-}]\b{builds:}<class-expr>}

       Repeat this option to specify multiple build target configuration
       classes."
    }

    strings --build-config
    {
      "<pc>/<tc>[/<tg>]",
      "Shortcut for the following options sequence:

       \c{\b{--override\ }<pc>\b{-builds:all}}\n
       \c{\b{--override\ }<pc>\b{-build-include:}<tc>[\b{/}<tg>]}\n
       \c{\b{--override\ }<pc>\b{-build-exclude:**}}

       Repeat this option to specify multiple build configurations."
    }

    strings --target-config
    {
      "<tc>[/<tg>]",
      "Shortcut for the following options sequence:

       \c{\b{--override\ builds:all}}\n
       \c{\b{--override\ build-include:}<tc>[\b{/}<tg>]}\n
       \c{\b{--override\ build-exclude:**}}

       Repeat this option to specify multiple build target configurations."
    }

    strings --package-config
    {
      "<pc>",
      "Shortcut for the following options sequence:

       \c{\b{--override\ }<pc>\b{-builds:}...}\n
       \c{\b{--override\ }<pc>\b{-build-include:}...}\n
       \c{\b{--override\ }<pc>\b{-build-exclude:}...}

       Where the override values are the build constraints for the specified
       build package configuration from the package manifest.

       Repeat this option to specify multiple build package configurations."
    }

    string --build-email
    {
      "<email>",
      "Shortcut for the following option:

       \c{\b{--override\ build-email:}<email>}

      "
    }

    // All the overrides-related options are handled with a common parser and
    // are collected in a single manifest value list that is accessible via
    // the --overrides option accessor. The --overrides option is "fake" in
    // that it only serves to collect the values in a single list while
    // preserving their order. Note that for this trick (or hack, if you
    // will) to work, this option should come after all the options it
    // aliases.
    //
    cmd_ci_override --overrides      |
                    --override       |
                    --overrides-file |
                    --builds         |
                    --build-email;

    string --simulate
    {
      "<outcome>",
      "Simulate the specified outcome of the CI process without actually
       performing any externally visible actions (such as testing the packages
       or publishing the result). The commonly used outcome value is
       \cb{success}. For other recognized outcomes refer to the CI service
       documentation."
    }

    bool --forward
    {
      "Use the forwarded configuration for each package instead of the
       default configuration."
    }
  };

  "
   \h|DEFAULT OPTIONS FILES|

   See \l{bdep-default-options-files(1)} for an overview of the default
   options files. For the \cb{ci} command the search start directory is
   the project directory. The following options files are searched for in
   each directory and, if found, loaded in the order listed:

   \
   bdep.options
   bdep-ci.options
   \

   The following \cb{ci} command options cannot be specified in the
   default options files:

   \
   --directory|-d
   \
  "
}