diff --git a/docs/configuration/index.md b/docs/configuration/index.md index 5d1482700..41c682c35 100644 --- a/docs/configuration/index.md +++ b/docs/configuration/index.md @@ -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 diff --git a/docs/configuration/jobs.md b/docs/configuration/jobs.md index ff5b7b26b..0a7caa423 100644 --- a/docs/configuration/jobs.md +++ b/docs/configuration/jobs.md @@ -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 @@ -111,6 +141,7 @@ jobs: env: RPM_NAME=kernel ``` +However, using the `_` placeholder key is preferred as it provides more flexibility. ## Configuration keys #### job