Skip to content

Commit

Permalink
Document the _ placeholder (#971)
Browse files Browse the repository at this point in the history
Document the `_` placeholder

Related to packit/packit/pull/2378

Reviewed-by: Cristian Le <[email protected]>
Reviewed-by: Matej Focko
  • Loading branch information
softwarefactory-project-zuul[bot] authored Nov 15, 2024
2 parents 47527e8 + 479cd9d commit 1718cd4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
7 changes: 7 additions & 0 deletions docs/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ You should place the file in the root of your upstream repo. Packit accepts thes

Both Packit Service and Packit CLI use this configuration file.

:::tip Writing complex configurations

See the [Packit Service jobs configuration](/docs/configuration/jobs.md) section for some tips on how to configure
complex config files.

:::

## Top-level keys

Here you can see a list of options that can be defined at the top-level and
Expand Down
43 changes: 37 additions & 6 deletions docs/configuration/jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,43 @@ jobs:
  branch: main
```

Note that in case of more complex scenarios, it can be useful to create also
a template job, that should not be triggered in Packit at all.
This is typically useful when creating a number of tests which needs various
parameters, but many parameters stay same. In such a case set the
`trigger` to `ignore` in the template job and use the expected trigger in real jobs.
Do not forget that you can also define common Packit config options at the
top level (such as `targets` or `actions`) and only override them when
needed in the `jobs` or `packages` section.

For more complex structures it can be useful to have yaml-anchors that are ignored,
in which case you can use the top-level `_` key, for example:
```yaml
_:
basic-test: &template-basic-test
job: tests
trigger: pull_request
targets:
  - centos-stream-8-x86_64
  - centos-stream-9-x86_64
  - fedora-all
jobs:
Please see the example:
- <<: *template-basic-test
identifier: kernel-rt-sanity
labels:
- kernel-rt
env:
RPM_NAME=kernel-rt
- <<: *template-basic-test
identifier: kernel-sanity
labels:
- kernel
env:
RPM_NAME=kernel
```

This is typically useful when creating a number of tests which needs various
parameters, but many parameters stay same. For compatibility reasons, you can
also define a job that is not executed by setting `trigger` to `ignore`. The
above example can be rewritten as:
```yaml
jobs:
- &template-basic-test
Expand All @@ -111,6 +141,7 @@ jobs:
env:
RPM_NAME=kernel
```
However, using the `_` placeholder key is preferred as it provides more flexibility.

## Configuration keys
#### job
Expand Down

0 comments on commit 1718cd4

Please sign in to comment.