-
Notifications
You must be signed in to change notification settings - Fork 54
Kayode dev #1063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kayodegigz
wants to merge
4
commits into
packit:main
Choose a base branch
from
kayodegigz:kayode-dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Kayode dev #1063
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,108 @@ | ||||||
--- | ||||||
title: test | ||||||
date: 2025-09-15 | ||||||
sidebar_position: 8 | ||||||
--- | ||||||
|
||||||
# `packit test` | ||||||
|
||||||
Run tmt tests locally using content from the upstream repository, mimicking the behavior of the tmt functionality. | ||||||
|
||||||
By default, if no RPM paths are passed, packit builds RPMs from the current repository's source code using `mock`, then runs tmt tests in a container environment. This enables local debugging and iteration without requiring commits or CI pipeline triggers. | ||||||
|
||||||
You can override test behavior and build configuration directly from the command line using various options like `--target`, `--plans`, `--rpm-paths`, and `--clean-before`/`--no-clean-before`. | ||||||
|
||||||
The command supports two main workflows: | ||||||
|
||||||
- Auto-build workflow: Build RPMs from source code and run tmt tests on the built RPM. This is triggered when there's no `--rpm-paths` passed via the CLI. | ||||||
- Pre-built RPM workflow: Test existing RPM files, Paths to the RPMs are passed with the `--rpm-paths` option. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
## Requirements | ||||||
|
||||||
* Upstream project is using git. | ||||||
* Packit config file placed in the upstream repository. | ||||||
* `tmt` (Test Management Tool) available in the system. | ||||||
* Mock build system configured (for auto-build workflow). | ||||||
|
||||||
## Tutorial | ||||||
|
||||||
1. Place a config file for packit in the root of your upstream repository. | ||||||
|
||||||
|
||||||
2. Basic local testing (auto-build workflow): | ||||||
``` | ||||||
$ packit test | ||||||
Building SRPM... | ||||||
Running mock build for target fedora-rawhide-x86_64... | ||||||
Generated RPMs: my-package-1.0-1.fc40.x86_64.rpm | ||||||
Running tmt tests... | ||||||
summary: 3 tests executed, 3 passed | ||||||
``` | ||||||
|
||||||
|
||||||
3. Auto build workflow with Test on specific target: | ||||||
``` | ||||||
$ packit test --target fedora:39 | ||||||
Building SRPM... | ||||||
Running mock build for target fedora-39-x86_64... | ||||||
Generated RPMs: my-package-1.0-1.fc39.x86_64.rpm | ||||||
Running tmt tests on fedora:39... | ||||||
summary: 3 tests executed, 3 passed | ||||||
``` | ||||||
|
||||||
4. Test pre-built RPMs: | ||||||
|
||||||
``` | ||||||
$ packit test --rpm-paths ./my-package-1.0-1.rpm | ||||||
Running tmt tests with provided RPMs... | ||||||
summary: 3 tests executed, 3 passed | ||||||
``` | ||||||
|
||||||
5. Test specific plans only: | ||||||
|
||||||
``` | ||||||
$ packit test --plans smoke-tests | ||||||
Building SRPM... | ||||||
Running mock build for target fedora-rawhide-x86_64... | ||||||
Generated RPMs: my-package-1.0-1.fc40.x86_64.rpm | ||||||
Running tmt plans: smoke-tests, integration... | ||||||
summary: 5 tests executed, 5 passed | ||||||
``` | ||||||
|
||||||
6. Skip cleanup of tmt artifacts for faster iteration: | ||||||
``` | ||||||
$ packit test --no-clean-before --target centos:stream9 | ||||||
Skipping tmt cleanup... | ||||||
Building SRPM... | ||||||
Running mock build for target centos-stream-9-x86_64... | ||||||
Generated RPMs: my-package-1.0-1.el9.x86_64.rpm | ||||||
Running tmt tests on centos:stream9... | ||||||
summary: 3 tests executed, 3 passed | ||||||
``` | ||||||
NB: This may cause some side effects like disk space exhaustion. | ||||||
|
||||||
## Help | ||||||
|
||||||
Usage: packit test [OPTIONS] | ||||||
|
||||||
Run tmt tests locally using content from the upstream repository. | ||||||
|
||||||
This command builds RPMs from the current repository state and runs | ||||||
tests in containerized environments, mimicking Packit's testing service | ||||||
behavior for local debugging and development. | ||||||
|
||||||
Options: | ||||||
--rpm-paths PATH Path to RPM file(s) to test. Can be used | ||||||
multiple times. If not provided, RPMs will | ||||||
be built automatically from source. | ||||||
--target TEXT Container image for testing environment | ||||||
(e.g., 'fedora:39', 'centos:stream9'). | ||||||
Defaults to 'fedora:rawhide'. | ||||||
--plans TEXT tmt plan name(s) to execute. Can be used | ||||||
multiple times to run specific plans only. | ||||||
If not specified, all plans are executed. | ||||||
--clean-before / --no-clean-before | ||||||
Run 'tmt clean --all' before starting the | ||||||
test. Defaults to disabled for clean test | ||||||
environments. | ||||||
-h, --help Show this message and exit. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.