Examples

Configuration examples #

Examples for actions #

You can find detailed documentation for actions here.

Getting version #

Getting version from specfile
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:

get-current-version:
  - rpmspec -q --queryformat "%{VERSION}\n" *spec |head -n1
Getting version for Python packages with setup.py
get-current-version:
  - python3 setup.py --version
Getting version for Ruby packages from the gemspec
get-current-version:
  - ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("*.gemspec").first).version'

Manipulating spec file #

Downloading specfile from the dist-git repo
post-upstream-clone:
  - "wget https://src.fedoraproject.org/rpms/my-package/raw/main/f/my-package.spec -O my-package.spec"
Setting the Sources correctly in case of multiple Sources
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}/\""

Custom archive creation #

Creating archive with custom make target
create-archive:
  - make release
  - bash -c "ls -1t ./my-package-*.tar.gz | head -n 1"
Creating archive for Python packages with setup.py
create-archive:
  - python3 setup.py sdist --dist-dir .
  - bash -c "ls -1t ./my-package-*.tar.gz | head -n 1"

Custom changelog generation #

Using changelog entry from a file
changelog-entry:
  - cat .changelog_entry

Examples for jobs #

You can find detailed documentation for jobs here.

Builds #

Running builds in Copr
- job: copr_build
  trigger: pull_request
  targets:
    - fedora-all
Running builds in custom Copr project

Configuring building in Copr project @oamg/convert2rhel:

- job: copr_build
  trigger: commit
  branch: main
  owner: "@oamg"
  project: convert2rhel
  targets:
    - epel-6-x86_64
    - epel-7-x86_64
    - epel-8-x86_64
Running more types of builds in Copr
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
Running builds in Koji
- job: upstream_koji_build
  trigger: pull_request
  targets:
    - fedora-all

Tests #

Running tests in Testing Farm
- job: tests
  trigger: pull_request
  targets:
    - fedora-all
Running tests in internal Testing Farm instance

Please, let us know if you want to use the internal Testing Farm; we have to enable it for you.

- job: tests
  targets:
    centos-stream-9-x86_64:
      distros: [RHEL-9.3.0-Nightly]
  use_internal_tf: True
Running only tests (without builds)
- job: tests
  targets:
    - fedora-all
  skip_build: True
Defining mapping between build and test targets
- job: tests
  targets:
    epel-7-x86_64:
      distros: [centos-7, oraclelinux-7]
    epel-8-x86_64:
      distros: [centos-8, oraclelinux-8]
Specifying where the FMF metadata are placed (other than default)
- job: tests
  trigger: pull_request
  targets:
    - fedora-all
  fmf_url: "https://gitlab.cee.redhat.com/baseos-qe/tmt.git"
  fmf_ref: main
Running more types of tests
jobs:
- job: tests
  trigger: pull_request
  targets:
    - fedora-all

- job: tests
  trigger: pull_request
  identifier: "internal-tests"
  targets:
    - fedora-all
  use_internal_tf: True
Providing custom tmt context
- job: tests
  trigger: pull_request
  targets:
    - fedora-all
  tf_extra_params:
    environments:
      - tmt:
          context:
            how: "full"

Fedora release automation #

Creating dist-git pull requests on upstream releases
- job: propose_downstream
  trigger: release
  dist_git_branches: 
    - fedora-all
Creating dist-git pull requests on upstream releases defined in the dist-git repository
upstream_project_url: https://github.com/packit/packit
...
jobs:
- job: pull_from_upstream
  trigger: release
  dist_git_branches: 
    - fedora-all
Running Koji builds when the Packit pull requests in dist-git are merged
- job: koji_build
  trigger: commit
  dist_git_branches:
    - fedora-all
Running Koji builds as a reaction to merging PRs or committing in dist-git by specified users
- 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
Creating Bodhi updates automatically for successful Koji builds
- job: bodhi_update
  trigger: commit
  dist_git_branches:
    - fedora-branched # rawhide updates are created automatically

Get inspired #

You can also look directly into configuration files of some other projects using Packit: