Skip to content

Commit

Permalink
Add an adjust example for enabling custom repo
Browse files Browse the repository at this point in the history
Let's add one more context adjust example demonstrating a
real-life use case of enabling a custom dnf repository using the
context dimension value for setting the repository url.
  • Loading branch information
psss committed Nov 7, 2023
1 parent ce71f45 commit 4f084b1
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions spec/core/adjust.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,21 @@ description: |
__ https://fmf.readthedocs.io/en/latest/context.html#syntax
__ https://docs.fedoraproject.org/en-US/ci/test-case-relevancy

example: |
example:
- |
# Disable a test for older distros
enabled: true
adjust:
enabled: false
when: distro < fedora-33
because: the feature was added in Fedora 33

- |
# Adjust the required package name
require: procps-ng
adjust:
- require: procps
when: distro == centos-6

- |
# Extend the environment variables, use multiple rules
adjust:
- environment+:
Expand All @@ -69,7 +70,7 @@ example: |
continue: true
- when: distro < centos-6
enabled: false

- |
# Install the fresh pytest from pip on older distros
adjust:
prepare+:
Expand All @@ -78,6 +79,20 @@ example: |
order: 90
script: 'python3 -m pip install -U pytest'
when: distro < rhel-8
- |
# Enable a custom dnf repository based on the context value
adjust:
- when: repo is defined
prepare+:
- script: |
cat > /etc/yum.repos.d/custom-repo.repo <<EOF
[custom-repo]
baseurl=$@repo
gpgcheck=0
EOF

# The corresponding command line can look like this
tmt --context repo=https://custom.url/fedora-38-x86_64 run ...

link:
- implemented-by: /tmt/base.py
Expand Down

0 comments on commit 4f084b1

Please sign in to comment.