-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathexamples.md
681 lines (531 loc) · 13.1 KB
/
examples.md
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
---
title: Examples
date: 2022-09-22
sidebar_position: 4
---
# Configuration examples
## Examples for actions
You can find detailed documentation for actions [here](/docs/configuration/actions).
### Getting version
<details>
<summary>Getting version from specfile</summary>
```yaml
get-current-version:
- grep -oP '^Version:\s+\K\S+' my-package.spec
```
or with a command from `rpm-build` package that will honor the macros:
```yaml
get-current-version:
- rpmspec -q --queryformat "%{VERSION}\n" *spec |head -n1
```
</details>
<details>
<summary>Getting version for Python packages with setup.py</summary>
```yaml
get-current-version:
- python3 setup.py --version
```
</details>
<details>
<summary>Getting version for Ruby packages from the gemspec</summary>
```yaml
get-current-version:
- ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("*.gemspec").first).version'
```
</details>
### Manipulating spec file
<details>
<summary>Downloading specfile from the dist-git repo</summary>
```yaml
post-upstream-clone:
- "wget https://src.fedoraproject.org/rpms/my-package/raw/main/f/my-package.spec -O my-package.spec"
```
</details>
<details>
<summary>Setting the Sources correctly in case of multiple Sources</summary>
```yaml
fix-spec-file:
# define one of the Source variables correctly
- sed -i my_specfile_path -e "s/https.*only-vendor.tar.xz/my_correct_tarball_path/"
# fill in %release as if packit would have done it
- bash -c "sed -i my_specfile_path -r \"s/Release:(\s*)\S+/Release:\1${PACKIT_RPMSPEC_RELEASE}%{?dist}/\""
```
</details>
### Custom archive creation for SRPM
<details>
<summary>Creating archive with custom make target</summary>
```yaml
create-archive:
- make release
- bash -c "ls -1t ./my-package-*.tar.gz | head -n 1"
```
</details>
<details>
<summary>Creating archive for Python packages with setup.py</summary>
```yaml
create-archive:
- python3 setup.py sdist --dist-dir .
- bash -c "ls -1t ./my-package-*.tar.gz | head -n 1"
```
</details>
<details>
<summary>Creating archive with git submodules</summary>
```yaml
create-archive:
- git submodule update --init
# Create an archive file with the ‹pkg› directory prefix
- bash -c 'git ls-files --recurse-submodules | tar --transform "s|^|pkg/|" -caf .packit/pkg.tar.gz -T-'
- echo '.packit/pkg.tar.gz'
```
</details>
### Custom archive creation for release syncing
If you need to generate local archive(s) during release syncing, you can utilise e.g. `pre-sync` action
to place the commands necessary for the creation. You also have to include the archive(s) in the list of files to
be moved to the dist-git repo so that it is then handled by Packit from there.
<details>
<summary>Creating an archive using tito and syncing it to dist-git repo</summary>
```yaml
actions:
pre-sync:
- tito build -o . --tgz
files_to_sync:
- src:
- "<my-package>-*.tar.gz"
dest: .
```
</details>
### Custom changelog generation
<details>
<summary>Using file content as a changelog entry</summary>
```yaml
changelog-entry:
- cat .changelog_entry
```
</details>
<details>
<summary>Using `git log` output as a changelog entry </summary>
```yaml
changelog-entry:
- bash -c 'git log --no-merges --pretty="format:- %s (%an)" $(git describe --tags --abbrev=0 ${PACKIT_PROJECT_UPSTREAM_TAG}^)..${PACKIT_PROJECT_UPSTREAM_TAG} --'
```
</details>
## Examples for jobs
You can find detailed documentation for jobs [here](/docs/configuration#supported-jobs).
### Builds
<details>
<summary>Running builds in Copr for all pull requests</summary>
```yaml
- job: copr_build
trigger: pull_request
targets:
- fedora-all
```
</details>
<details>
<summary>Running builds in Copr for pull requests with 'main' target branch</summary>
```yaml
- job: copr_build
trigger: pull_request
branch: main
targets:
- fedora-all
```
</details>
<details>
<summary>Running builds in custom Copr project for pushes to 'main'</summary>
Configuring building in Copr project `@oamg/convert2rhel`:
```yaml
- job: copr_build
trigger: commit
branch: main
owner: "@oamg"
project: convert2rhel
targets:
- epel-6-x86_64
- epel-7-x86_64
- epel-8-x86_64
```
</details>
<details>
<summary>Running more types of builds in Copr</summary>
```yaml
jobs:
- job: copr_build
trigger: pull_request
identifier: fedora
targets:
- fedora-all
- job: copr_build
trigger: pull_request
specfile_path: epel8/python-specfile.spec
identifier: epel8
actions:
create-archive:
- python3 setup.py sdist --dist-dir ./epel8/
- bash -c "ls -1t ./epel8/*.tar.gz | head -n 1"
targets:
- epel-8
```
</details>
<details>
<summary>Running builds in Koji for all pull requests</summary>
```yaml
- job: upstream_koji_build
trigger: pull_request
targets:
- fedora-all
```
</details>
<details>
<summary>Running builds in Koji for pull requests with 'main' target branch</summary>
```yaml
- job: upstream_koji_build
trigger: pull_request
branch: main
targets:
- fedora-all
```
</details>
<details>
<summary>Utilising custom failure message</summary>
```yaml
- job: copr_build
trigger: pull_request
targets:
- fedora-all
notifications:
failure_comment:
message: >
Some builds failed for commit {commit_sha}.
@admin, please check."
```
</details>
### Tests
<details>
<summary>Running tests in Testing Farm for all pull requests</summary>
```yaml
- job: copr_build
trigger: pull_request
targets:
- fedora-all
- job: tests
trigger: pull_request
targets:
- fedora-all
```
</details>
<details>
<summary>Running tests in Testing Farm for pull requests with 'main' target branch</summary>
```yaml
- job: copr_build
trigger: pull_request
branch: main
targets:
- fedora-all
- job: tests
trigger: pull_request
branch: main
targets:
- fedora-all
```
</details>
<details>
<summary>Running tests in internal Testing Farm instance</summary>
Please, let us know if you want to use the internal Testing Farm;
we have to enable it for you.
```yaml
- job: copr_build
trigger: pull_request
targets:
- epel-8-x86_64
- job: tests
trigger: pull_request
targets:
epel-8-x86_64:
distros: [RHEL-8.8.0-Nightly]
use_internal_tf: True
```
</details>
<details>
<summary>Running only tests (without builds)</summary>
```yaml
- job: tests
trigger: pull_request
targets:
- fedora-all
skip_build: True
```
</details>
<details>
<summary>Defining mapping between build and test targets</summary>
```yaml
- job: copr_build
trigger: pull_request
targets:
- epel-7-x86_64
- epel-8-x86_64
- job: tests
trigger: pull_request
targets:
epel-7-x86_64:
distros: [centos-7, oraclelinux-7]
epel-8-x86_64:
distros: [centos-8, oraclelinux-8]
```
</details>
<details>
<summary>Specifying where the FMF metadata are placed in the current repository</summary>
```yaml
- job: tests
trigger: pull_request
targets:
- fedora-all
fmf_path: .distro/tmt
```
</details>
<details>
<summary>Specifying where the FMF metadata are placed outside the current repository</summary>
```yaml
- job: copr_build
trigger: pull_request
targets:
- fedora-all
- job: tests
trigger: pull_request
targets:
- fedora-all
fmf_url: "https://gitlab.cee.redhat.com/baseos-qe/tmt.git"
fmf_ref: main
```
</details>
<details>
<summary>Running more types of tests with different settings</summary>
```yaml
jobs:
- job: copr_build
trigger: pull_request
targets:
- fedora-all
- job: tests
trigger: pull_request
identifier: "postgres-12-pgoutput"
targets:
- fedora-all
tf_extra_params:
test:
tmt:
name: postgres
environments:
- variables:
POSTGRESQL_VERSION: 12
DECODER_PLUGIN: pgoutput
- job: tests
trigger: pull_request
identifier: "postgres-15-decoderbufs"
targets:
- fedora-all
tf_extra_params:
test:
tmt:
name: postgres
environments:
- variables:
POSTGRESQL_VERSION: 15
DECODER_PLUGIN: decoderbufs
```
</details>
<details>
<summary>Extending timeout of a test pipeline for 24 hours (default is 12 hours)</summary>
```yaml
- job: tests
trigger: pull_request
identifier: "performance"
targets:
- centos-stream-9-x86_64
skip_build: true
manual_trigger: true
labels:
- performance
tf_extra_params:
settings:
pipeline:
timeout: 1440
test:
tmt:
name: performance
```
</details>
<details>
<summary>Providing custom tmt context</summary>
```yaml
- job: copr_build
trigger: pull_request
targets:
- fedora-all
- job: tests
trigger: pull_request
targets:
- fedora-all
tf_extra_params:
environments:
- tmt:
context:
how: "full"
```
</details>
<details>
<summary>Tag cloud resources in Testing Farm</summary>
Tag cloud resources in Testing Farm to a specific Red Hat team or a project. If you are not a Red Hat employee, this section is not relevant for you.
Make sure to update `sst_change_me` to your RHEL SST name or name
of the project. If not set, cloud costs are reported against
`Packit Service`. The `BusinessUnit` key name is required, please
do not change it.
```yaml
- job: copr_build
trigger: pull_request
targets:
- fedora-all
- job: tests
trigger: pull_request
targets:
- fedora-all
# Tag cloud resources for tmt
tf_extra_params:
environments:
- settings:
provisioning:
tags:
BusinessUnit: sst_change_me
```
</details>
<details>
<summary>Providing additional Testing Farm artifacts</summary>
```yaml
- job: copr_build
trigger: pull_request
targets:
- fedora-all
- job: tests
trigger: pull_request
targets:
- fedora-all
tf_extra_params:
environments:
- artifacts:
- type: repository
id: https://my.repo/repository
```
</details>
<details>
<summary>Utilising custom failure message</summary>
```yaml
- job: copr_build
trigger: pull_request
targets:
- fedora-all
- job: tests
identifier: revdeps
trigger: pull_request
targets:
- fedora-all
notifications:
failure_comment:
message: >
Reverse dep tests failed for commit {commit_sha}.
@admin, please check."
```
</details>
### Fedora release automation
<details>
<summary>Creating dist-git pull requests on upstream releases</summary>
```yaml
- job: propose_downstream
trigger: release
dist_git_branches:
- fedora-all
```
</details>
<details>
<summary>Creating dist-git pull requests on upstream releases defined in the dist-git repository</summary>
```yaml
upstream_project_url: https://github.com/packit/packit
jobs:
- job: pull_from_upstream
trigger: release
dist_git_branches:
- fedora-all
```
</details>
<details>
<summary>Creating dist-git pull requests on upstream releases matching specified tag pattern defined in the dist-git repository</summary>
```yaml
upstream_project_url: https://github.com/packit/packit
jobs:
- job: pull_from_upstream
trigger: release
dist_git_branches:
- fedora-all
upstream_tag_include: "^2\\..+"
upstream_tag_exclude: "^.+\\.1\\..+"
```
</details>
<details>
<summary>Creating dist-git pull requests on upstream releases with different configs for branches defined in the dist-git repository</summary>
```yaml
upstream_project_url: https://github.com/packit/packit
jobs:
- job: pull_from_upstream
trigger: release
dist_git_branches:
- fedora-38
upstream_tag_include: "^2\\..+"
upstream_tag_exclude: "^.+\\.1\\..+"
- job: pull_from_upstream
trigger: release
dist_git_branches:
- fedora-rawhide
```
</details>
<details>
<summary>Running Koji builds when the Packit pull requests in dist-git are merged</summary>
```yaml
- job: koji_build
trigger: commit
dist_git_branches:
- fedora-all
```
</details>
<details>
<summary>Running Koji builds as a reaction to merging PRs or committing in dist-git by specified users</summary>
```yaml
- job: koji_build
trigger: commit
dist_git_branches:
- fedora-all
allowed_pr_authors:
- packit
- the-fas-username-to-allow
allowed_committers:
- packit
- another-fas-username-to-allow
```
</details>
<details>
<summary>Creating Bodhi updates automatically for successful Koji builds</summary>
```yaml
- job: bodhi_update
trigger: commit
dist_git_branches:
- fedora-branched # rawhide updates are created automatically
```
</details>
## Get inspired
You can also look directly into configuration files of some other projects using Packit:
- [Systemd](https://github.com/systemd/systemd/blob/main/.packit.yml)
- [Anaconda](https://github.com/rhinstaller/anaconda/blob/master/.packit.yml)
- [Ogr](https://github.com/packit/ogr/blob/main/.packit.yaml)
- [Convert2rhel](https://github.com/oamg/convert2rhel/blob/main/.packit.yaml)
- [Cockpit project](https://github.com/cockpit-project/cockpit/blob/main/packit.yaml)
- [Tmt](https://github.com/teemtee/tmt/blob/main/.packit.yaml)
- [Osbuild](https://github.com/osbuild/osbuild-composer/blob/main/.packit.yaml)
- [Leapp repository](https://github.com/oamg/leapp-repository/blob/master/.packit.yaml)