Skip to content

Commit

Permalink
Document the _ placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
LecrisUT committed Nov 13, 2024
1 parent 47527e8 commit 785d17c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
6 changes: 6 additions & 0 deletions docs/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ 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 [](/docs/configuration/jobs.md) 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 use the top-level keys to store common keys like
`targets` and `actions` and only override them as 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 785d17c

Please sign in to comment.