Skip to content

Commit ecf99b9

Browse files
committed
Split-up the README and update for obo-cli
This splits the single readme into three, a top-level one with all the useful shared info, and much smaller project-specific ones with the relevant setup.
1 parent ee554cd commit ecf99b9

File tree

3 files changed

+248
-155
lines changed

3 files changed

+248
-155
lines changed

README.md

Lines changed: 78 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,18 @@
1-
# OBS GitLab Runner
1+
# OBS Build Orchestrator
22

3-
This is a custom [GitLab Runner](https://docs.gitlab.com/runner/) implementation
4-
exposing a custom command language for starting, monitoring, and cleaning up
5-
builds on [OBS](https://build.opensuse.org/), specifically targeting Debian
6-
packages.
3+
This repo contains tools for starting, monitoring, and cleaning up builds on
4+
[OBS](https://build.opensuse.org/), specifically targeting Debian packages).
5+
It's usable in two forms:
76

8-
## Usage
9-
10-
### Sending Jobs
11-
12-
In order to send commands in a job to the runner, set the job's `tags:` to
13-
include the tag you used during [the deployment](#deployment), e.g.:
14-
15-
```yaml
16-
my-job:
17-
tags:
18-
- obs-runner # <-- set to run on runners tagged "obs-runner"
19-
stage: some-stage
20-
script:
21-
# [...]
22-
```
23-
24-
This will run all the commands inside `before_script`, `script`, and
25-
`after_script` with the runner.
26-
27-
### Supported Syntax
28-
29-
A subset of shell syntax is supported for commands:
30-
31-
- Commands are split at spaces, but parts can be quoted, just like in the shell:
32-
```bash
33-
some-command this-is-argument-1 "this entire string is argument 2"
34-
```
35-
- Variable substitution is supported, as well as the `${VARIABLE:-DEFAULT}`
36-
syntax to use the value `DEFAULT` if `$VARIABLE` is unset:
37-
```bash
38-
some-command $a_variable ${a_variable_with_default:-this is used if unset}
39-
```
40-
The variables are sourced from the pipeline-wide and job-specific variables
41-
set.
42-
- A significant departure from shell argument parsing is that **variable
43-
contents are auto-quoted, thus spaces inside a variable do not split
44-
arguments**. For example, given `MYVAR=a b c`, this:
45-
```bash
46-
some-command $MYVAR
47-
```
48-
is interpreted as:
49-
```bash
50-
some-command 'a b c'
51-
```
52-
*not*:
53-
```bash
54-
some-command a b c
55-
```
56-
There is no way to use a variable without auto-quoting its contents.
57-
58-
#### Flags
7+
- [obo-cli](obo-cli/README.md), a standalone CLI.
8+
- [obs-gitlab-runner](obs-gitlab-runner/README.md), a custom [GitLab
9+
Runner](https://docs.gitlab.com/runner/).
5910

60-
Any flag arguments shown below can also explicitly take a true/false value, e.g.
61-
`--rebuild-if-unchanged`, `--rebuild-if-unchanged=true`, and
62-
`--rebuild-if-unchanged=false`. This is primarily useful to conditionally set
63-
the value for a flag; you can set `SOME_VARIABLE=true/false` in your GitLab
64-
pipeline, then use that variable in a flag value as `--flag=$SOME_VARIABLE`.
11+
## Usage
6512

6613
### Required Environment
6714

68-
In order to connect to OBS, three variables must be set (generally within the
69-
"CI/CD" section of the settings):
15+
In order to connect to OBS, three enviroment variables must be set:
7016

7117
- `OBS_SERVER`: The URL of the OBS instance, e.g. `https://obs.somewhere.com/`.
7218
- `OBS_USER`: The username used to authenticate with OBS (any commits created
@@ -75,6 +21,24 @@ In order to connect to OBS, three variables must be set (generally within the
7521
there are no places where this value should be logged, **for safety purposes,
7622
it is highly recommended to mark this variable as *Masked*.**.
7723

24+
For obs-gitlab-runner, these should generally be configured within the "CI/CD"
25+
section of the repository / group settings. **For safety purposes, it is highly
26+
recommended to mark the `OBS_PASSWORD` variable as *Masked*.**. (It should not
27+
be logged anywhere regardless, but that will provide insulation against
28+
mistakes.)
29+
30+
For obo-cli, you can additionally use the `--obs-server`, `--obs-user`, and
31+
`--obs-password` options, but care should be taken to avoid accidentally saving
32+
the values into shell history or other tenuous locations.
33+
34+
### Flag syntax
35+
36+
Any flag arguments shown below can also explicitly take a true/false value, e.g.
37+
`--rebuild-if-unchanged`, `--rebuild-if-unchanged=true`, and
38+
`--rebuild-if-unchanged=false`. This is primarily useful to conditionally set
39+
the value for a flag; you can set `SOME_VARIABLE=true/false` in your CI
40+
pipeline, then use that variable in a flag value as `--flag=$SOME_VARIABLE`.
41+
7842
### Commands
7943

8044
#### `dput`
@@ -124,7 +88,7 @@ Note that, if `--branch-to` was specified, this will, in practice, never be
12488
triggered: due to the way metadata files are handled, right after a branching
12589
operation, there will *always* be a change to upload.
12690

127-
#### `generate-monitor`
91+
#### `generate-monitor` (*obs-gitlab-runner version*)
12892

12993
```bash
13094
generate-monitor RUNNER_TAG
@@ -229,6 +193,56 @@ Changes the expiration of the build results & logs.
229193

230194
Changes the filename each monitoring job will save the build log into.
231195

196+
#### `generate-monitor` (*obo-cli version*)
197+
198+
```bash
199+
generate-monitor
200+
[--download-build-results-to BUILD_RESULTS_DIR]
201+
[--build-info BUILD_INFO_FILE=build-info.json]
202+
[--monitor-out MONITOR_OUT=obs-monitor.json]
203+
[--build-log-out BUILD_LOG_FILE=build.log]
204+
```
205+
206+
Generates a JSON file `MONITOR_OUT` structured as:
207+
208+
```json5
209+
{
210+
"entries": [
211+
{
212+
"repo": "REPO",
213+
"arch": "ARCH",
214+
"commands": {
215+
"monitor": "monitor [...]",
216+
"download-binaries": "download-binaries [...]",
217+
}
218+
},
219+
// ...
220+
]
221+
}
222+
```
223+
224+
`entries` contains a list of OBS repository + architecture combinations, along
225+
with the subcommands to run to monitor a build and download the results (to be
226+
used as `obo THE_SUBCOMMAND`).
227+
228+
##### `--download-build-results-to BUILD_RESULTS_DIR`
229+
230+
Fills in `entries[*].commands.download-binaries` with a command that will
231+
download the build results from OBS to the given `BUILD_RESULTS_DIR`. If this
232+
option is not given, `commands.download-binaries` will be `null`.
233+
234+
##### `--build-info BUILD_INFO_FILE=build-info.json`
235+
236+
Specifies the name of the build info file to read. In particular, if a different
237+
build info filename was used with `dput` via
238+
[`--build-info-out`](#--build-info-out), then `--build-info` should be used here
239+
to specify the same filename.
240+
241+
##### `--build-log-out BUILD_LOG_FILE=build.log`
242+
243+
Changes the filename each subcommand in `entries[*].commands.monitor` will save
244+
the build log into.
245+
232246
#### `prune`
233247

234248
```bash
@@ -261,94 +275,3 @@ is written.
261275
Only run the prune if a previous command in the same job failed. This is
262276
primarily useful if `prune` is used inside of `after_script`, to only remove the
263277
branched project/package if e.g. the upload failed.
264-
265-
## Deployment
266-
267-
### Registering the Runner
268-
269-
In order to use the runner, you must first register it with your GitLab
270-
instance. This requires the use of a registration token, which can be obtained
271-
via the following steps:
272-
273-
- Enter the GitLab admin area.
274-
- Navigate to Overview -> Runners.
275-
- Click "Register an instance runner".
276-
- Copy the registration token within.
277-
278-
(Per-group/-project registration tokens can also be retrieved from the CI/CD
279-
settings of the group or project.)
280-
281-
With this token, you can now register the runner via the [GitLab
282-
API](https://docs.gitlab.com/ee/api/runners.html#register-a-new-runner).
283-
284-
Example using curl:
285-
286-
```bash
287-
curl --request POST "https://$GITLAB_SERVER_URL/api/v4/runners" \
288-
--form description='OBS runner' \
289-
--form run_untagged=false \
290-
--form tag_list=obs-runner \
291-
--form token="$REGISTRATION_TOKEN"
292-
```
293-
294-
httpie:
295-
296-
```bash
297-
http --form POST "https://$GITLAB_SERVER_URL/api/v4/runners" \
298-
description='OBS runner' \
299-
run_untagged=false \
300-
tag_list=obs-runner \
301-
token="$REGISTRATION_TOKEN"
302-
```
303-
304-
**It is critical that you set `run_untagged=false`,** otherwise this runner
305-
will be used for *all* jobs that don't explicitly set a tag, rather than just
306-
the jobs explicitly targeting the runner.
307-
308-
This API call will return a JSON object containing a `token` key, whose value
309-
is a _runner token_ that is used by the runner to connect to GitLab.
310-
311-
### Docker
312-
313-
Docker images are built on every commit, available at
314-
`ghcr.io/collabora/obs-gitlab-runner:main`. The entry point takes two arguments:
315-
316-
- The GitLab server URL.
317-
- The runner token acquired previously.
318-
319-
Simple example usage via the Docker CLI:
320-
321-
```bash
322-
$ docker run --rm -it ghcr.io/collabora/obs-gitlab-runner:main \
323-
"$GITLAB_SERVER_URL" "$GITLAB_RUNNER_TOKEN"
324-
```
325-
326-
In addition, you can instead opt to set the `GITLAB_URL` and `GITLAB_TOKEN`
327-
environment variables:
328-
329-
```bash
330-
$ docker run --rm -it \
331-
-e GITLAB_URL="$GITLAB_SERVER_URL" \
332-
-e GITLAB_TOKEN="$GITLAB_RUNNER_TOKEN" \
333-
ghcr.io/collabora/obs-gitlab-runner:main
334-
```
335-
336-
### Kubernetes
337-
338-
A [Helm](https://helm.sh/) chart has been provided in the `chart/` directory,
339-
installable via:
340-
341-
```bash
342-
$ helm install \
343-
--set-string gitlab.url="$GITLAB_SERVER_URL" \
344-
--set-string gitlab.token="$GITLAB_RUNNER_TOKEN" \
345-
obs-gitlab-runner chart
346-
```
347-
348-
Upgrades can skip setting `gitlab.token` to re-use the previously set value:
349-
350-
```bash
351-
$ helm upgrade \
352-
--set-string gitlab.url="$GITLAB_SERVER_URL" \
353-
obs-gitlab-runner chart
354-
```

obo-cli/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# obo-cli
2+
3+
This is a CLI for starting, monitoring, and cleaning up builds on
4+
[OBS](https://build.opensuse.org/), specifically targeting Debian packages.
5+
6+
## Usage
7+
8+
For information on OBS authentication and the commands supported, see [the
9+
project-wide README](../README.md).
10+
11+
Docker images are built on every commit, available at
12+
`ghcr.io/collabora/obo-cli:main`. The entry point directly takes the
13+
subcommands, e.g:
14+
15+
```
16+
docker run --rm -it -v $PWD:/work -w /work ghcr.io/collabora/obo-cli:main prune
17+
```
18+
19+
will mount the current directory as `/work` and then run the `prune` command
20+
from within.

0 commit comments

Comments
 (0)