### Containerized Development Example Source: https://github.com/packit/packit.dev/blob/main/README.md Example command to enter a distrobox container and run the local development server, assuming necessary tools like make and yarn are installed within the container. ```shell distrobox-enter js -- make run-dev ``` -------------------------------- ### Get Version for Python (setup.py) Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/examples.md Extracts the version of a Python package by executing the setup.py script with the --version argument. This is a standard way to get version information for Python projects. ```yaml get-current-version: - python3 setup.py --version ``` -------------------------------- ### Packit Configuration Example Source: https://github.com/packit/packit.dev/blob/main/docs/cli/sync-from-downstream.md An example of the packit.yaml configuration file, demonstrating how to set necessary API tokens for interacting with GitHub and Fedora Dist-git services. ```yaml # you can obtain the token over here: https://github.com/settings/tokens github_token: 123 # and this one right here: https://src.fedoraproject.org/settings#nav-api-tab pagure_user_token: 456 ``` -------------------------------- ### Get Version from Specfile (grep) Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/examples.md Retrieves the version from a .spec file by parsing lines starting with 'Version:'. This method uses grep with specific options to extract the version string directly. ```yaml get-current-version: - grep -oP '^Version:\s+\K\S+' my-package.spec ``` -------------------------------- ### Packit Installation Methods Source: https://github.com/packit/packit.dev/blob/main/weekly/2019.md Provides commands for installing the Packit tool using different package managers like DNF and pip, including options for user installation or direct from source. ```bash $ dnf install --enablerepo=updates-testing packit ``` ```bash $ pip3 install --user packitos ``` ```bash $ pip3 install --user git+https://github.com/packit-service/packit ``` -------------------------------- ### Start Local Development Server Source: https://github.com/packit/packit.dev/blob/main/README.md Starts a local development server for live preview of website changes. Optionally accepts a --no-open flag to prevent automatic browser opening. ```shell $ yarn start # or $ make run-dev ``` ```shell $ yarn start --no-open ``` -------------------------------- ### Copr Build for All Pull Requests Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/examples.md Configures a Copr build job to run for all incoming pull requests, targeting all Fedora distributions. This is a basic setup for continuous integration. ```yaml - job: copr_build trigger: pull_request targets: - fedora-all ``` -------------------------------- ### Run tests in Testing Farm for all pull requests Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/examples.md This configuration defines CI jobs, `copr_build` and `tests`, that are triggered by any pull request and target all Fedora distributions. It's a basic setup for comprehensive testing on pull requests. ```yaml - job: copr_build trigger: pull_request targets: - fedora-all - job: tests trigger: pull_request targets: - fedora-all ``` -------------------------------- ### Install specfile library Source: https://github.com/packit/packit.dev/blob/main/posts/specfile-introduction/index.md Installs the specfile library using package managers. On Fedora and EPEL systems, dnf is used. On other systems, pip is the recommended method, requiring RPM Python bindings. ```bash dnf install python3-specfile ``` ```bash pip install specfile ``` -------------------------------- ### Run tests with different settings and parameters Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/examples.md This configuration shows how to run tests with custom identifiers and pass specific parameters to the testing framework (TMT). It includes examples for setting PostgreSQL versions and decoder plugins, and extending pipeline timeouts. ```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 - 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 ``` -------------------------------- ### Packit Configuration: Dist-git Only Example Source: https://github.com/packit/packit.dev/blob/main/docs/fedora-releases-guide/dist-git-onboarding.md A comprehensive example of a Packit configuration file for dist-git workflows, defining jobs for pull_from_upstream, koji_build, and bodhi_update with their respective triggers and branches. ```YAML jobs: - job: pull_from_upstream trigger: release dist_git_branches: - fedora-rawhide - job: koji_build trigger: commit dist_git_branches: - fedora-rawhide - job: bodhi_update trigger: commit dist_git_branches: - fedora-branched # rawhide updates are created automatically ``` -------------------------------- ### Install Dependencies Source: https://github.com/packit/packit.dev/blob/main/README.md Installs project dependencies, including yarn and JS dependencies for the webpage, and imports deployment and research documentation. ```shell $ make install-dependencies ``` -------------------------------- ### Packit Authentication Configuration Example Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/index.md An example demonstrating the structure of the authentication dictionary for configuring tokens for services like GitHub and Pagure. ```YAML authentication: github.com: token: mnbvcxz123456 pagure: token: qwertyuiop098765 instance_url: https://src.fedoraproject.org ``` -------------------------------- ### VM Image Build Job Configuration Example Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/upstream/vm_image_build.md An example YAML configuration for the `vm_image_build` job, demonstrating how to specify image parameters, distribution, and Copr project details. ```yaml jobs: - job: vm_image_build trigger: pull_request image_request: architecture: x86_64 image_type: aws upload_request: type: aws options: share_with_accounts: ["123456789"] image_customizations: packages: [foo-bar] image_distribution: fedora-36 owner: john-foo project: foo-bar-martini copr_chroot: fedora-36-x86_64 ``` -------------------------------- ### Koji Build Configuration Example Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/downstream/koji_build.md An example YAML configuration snippet demonstrating how to set up a 'koji_build' job. It specifies the trigger, allowed committers, and target dist-git branches for builds. ```yaml issue_repository: https://github.com/my-username/packit-notifications jobs: - job: koji_build trigger: commit allowed_committers: ["jsmith"] dist_git_branches: - fedora-all - epel-8 ``` -------------------------------- ### Packit Configuration Example Source: https://github.com/packit/packit.dev/blob/main/posts/aws-and-image-builder/index.md A comprehensive example of a .packit.yaml file demonstrating the structure for defining jobs, triggers, and specific build configurations for COPR and VM image builds. ```yaml --- jobs: - job: copr_build trigger: pull_request targets: - fedora-all - job: vm_image_build trigger: pull_request image_request: architecture: x86_64 image_type: aws upload_request: type: aws options: share_with_accounts: - < shared-aws-account-id > image_distribution: fedora-39 copr_chroot: fedora-39-x86_64 image_customizations: packages: [hello-world] ``` -------------------------------- ### Install JS Dependencies Source: https://github.com/packit/packit.dev/blob/main/README.md Installs JavaScript dependencies required for the webpage using yarn. ```shell $ yarn ``` -------------------------------- ### Provide custom TMT context Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/examples.md This example shows how to provide custom context information to the TMT (Test Management Tool) execution. The `tf_extra_params` with `environments.tmt.context` allows passing specific attributes like 'how' to the test execution. ```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" ``` -------------------------------- ### Provide additional Testing Farm artifacts Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/examples.md This example shows how to specify additional artifacts to be collected from the Testing Farm. The `artifacts` parameter within `tf_extra_params.environments` allows defining artifact types and their IDs, such as a custom repository URL. ```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 ``` -------------------------------- ### Packit Status Command Example Source: https://github.com/packit/packit.dev/blob/main/weekly/2019.md Demonstrates the usage of the 'packit status' command to display upstream and downstream information for a project. ```bash $ packit status Cloning repo: https://src.fedoraproject.org/rpms/packit.git -> /tmp/tmp84we_6n8 Downstream PRs: No open PRs. f29: 0.2.0 f30: 0.2.0 master: 0.2.0 ``` -------------------------------- ### tmt Command Output Example Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/upstream/tests.md Demonstrates the typical output when running the 'tmt' command, showing the discovery of tests and plans within a project structure. ```shell $ tmt Found 3 tests: /tests/full, /tests/smoke and /tests_recording. Found 4 plans: /plans/full, /plans/rpmlint, /plans/session-recording and /plans/smoke. Found 0 stories. $ ls -1 plans/ full.fmf main.fmf rpmlint.fmf session-recording.fmf smoke.fmf ``` -------------------------------- ### Packit Sync-from-downstream Execution Example Source: https://github.com/packit/packit.dev/blob/main/docs/cli/sync-from-downstream.md Demonstrates the typical workflow of cloning a repository, navigating into it, and executing the packit sync-from-downstream command, showing sample output including PR creation. ```shell $ git clone https://github.com/user-cont/colin.git $ cd colin $ packit sync-from-downstream upstream active branch master Cloning repo: https://src.fedoraproject.org/rpms/colin.git -> /tmp/tmph9npe78e using master dist-git branch syncing /tmp/tmph9npe78e/colin.spec PR created: https://api.github.com/repos/phracek/colin/pulls/3 ``` -------------------------------- ### Create Archive for Python (setup.py sdist) Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/examples.md Builds a source distribution (sdist) for a Python package using 'python setup.py sdist'. The resulting tarball is placed in the current directory. ```yaml create-archive: - python3 setup.py sdist --dist-dir . - bash -c "ls -1t ./my-package-*.tar.gz | head -n 1" ``` -------------------------------- ### Get Version for Ruby (gemspec) Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/examples.md Retrieves the version from a Ruby gemspec file using a Ruby one-liner. It loads the specification and accesses its version attribute. ```yaml get-current-version: - ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("*.gemspec").first).version' ``` -------------------------------- ### Packit Configuration Example Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/actions.md A sample .packit.yaml configuration file showing how to define specfile path, files to sync, upstream/downstream package names, dist-git URL, and various actions with bash commands. ```yaml specfile_path: package.spec files_to_sync: - packit.yaml - package.spec upstream_package_name: package downstream_package_name: package dist_git_url: https://src.fedoraproject.org/rpms/package.git actions: prepare-files: "make prepare" create-archive: - "make archive" - bash -c "ls -1 ./package-*.tar.gz" changelog-entry: - bash -c 'echo "- New release ${PACKIT_PROJECT_VERSION}"' ``` -------------------------------- ### Initialize Source-Git Repository Source: https://github.com/packit/packit.dev/blob/main/source-git/work-with-source-git/create-source-git.md Commands to add the `.distro` directory to the staging area and commit it as the initial setup for a source-git repository. The output shows the files created and the commit hash. ```shell $ git add .distro/ $ git commit -m'Initialize as a source-git repository' ``` -------------------------------- ### Execute Shell Commands for Integration Test Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/upstream/tests.md Sets up the execute step to run a series of shell commands, including package installation, service start, file manipulation, and verification with curl. ```yaml execute: script: - dnf -y install httpd curl - systemctl start httpd - echo foo > /var/www/html/index.html - curl http://localhost/ | grep foo ``` -------------------------------- ### Packit Basic Configuration Example Source: https://github.com/packit/packit.dev/blob/main/docs/guide.md Demonstrates basic Packit configuration for syncing files and defining upstream/downstream package names. This sets up essential project metadata for Packit's operations. ```yaml files_to_sync: - package.spec - .packit.yaml upstream_package_name: package downstream_package_name: package ``` -------------------------------- ### Get Version from Specfile (rpmspec) Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/examples.md Fetches the version from a .spec file using the rpmspec command, which correctly interprets RPM macros. This is a more robust method for RPM-related version extraction. ```yaml get-current-version: - rpmspec -q --queryformat "%{VERSION}\n" --srpm *spec ``` -------------------------------- ### fix-spec-file Action Example Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/actions.md Demonstrates how to use sed and bash commands to manually update spec files for archive references, %setup macro, and Version/Release fields when the default fix-spec-file action is insufficient. ```yaml actions: 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 -r \"s/Release:(\s*)\S+/Release:\1${PACKIT_RPMSPEC_RELEASE}%{?dist}/\" my_specfile_path" ``` -------------------------------- ### Run Commands in Packit Sandbox (Podman) Source: https://github.com/packit/packit.dev/blob/main/docs/reproduce-locally.md Demonstrates how to launch the production Packit sandbox image using Podman and bind-mount the project directory. This allows for reproducing the build environment locally to debug issues. ```shell podman run -ti --rm --memory 768MB -v $PWD:/src -w /src quay.io/packit/sandcastle:prod bash ``` -------------------------------- ### Packit Setup and Configuration Source: https://github.com/packit/packit.dev/blob/main/posts/aws-and-image-builder/index.md Steps to set up Packit for your project, including creating a Fedora Account System (FAS) account, installing the GitHub application or configuring a GitLab webhook, and approving your FAS username. ```APIDOC Packit Setup: 1. Create a Fedora Account System (FAS) account. - Required for agreeing to Fedora license and interacting with COPR. 2. Install Packit GitHub Application or configure GitLab webhook. - GitHub: Install from GitHub Marketplace. - GitLab: Configure webhook via Packit documentation. 3. Approve FAS username with Packit. - Automated on GitHub. - Contact Packit support for GitLab. ``` -------------------------------- ### Install Packit from Source (GitHub) Source: https://github.com/packit/packit.dev/blob/main/docs/cli/index.md Installs Packit directly from its GitHub repository using pip. Requires development packages to be installed first. ```shell $ pip install --user git+https://github.com/packit/packit ``` -------------------------------- ### Packit CLI Command Example Source: https://github.com/packit/packit.dev/blob/main/docs/guide.md Demonstrates a core Packit command-line interface usage for creating a source RPM locally. This command is fundamental for testing Packit's build process outside the service. ```markdown All the logic is baked inside the `packit` command - so once `packit srpm` (the command to create a source RPM locally from the current snapshot of the project) starts passing for you, it should work inside packit service as well. ``` -------------------------------- ### Install Packit Dependencies on Fedora for PyPI Source: https://github.com/packit/packit.dev/blob/main/docs/cli/index.md Installs necessary development packages on Fedora before installing Packit from PyPI, as some dependencies require compilation. ```shell $ sudo dnf install gcc python3-devel libcurl-devel krb5-devel openssl-devel ``` -------------------------------- ### Install Packit with Pip Source: https://github.com/packit/packit.dev/blob/main/weekly/2019.md Installs the Packit tool using pip, suitable for user-level installation. ```shell $ pip3 install --user packitos ``` -------------------------------- ### Create and Populate .distro Directory Source: https://github.com/packit/packit.dev/blob/main/source-git/work-with-source-git/create-source-git.md Demonstrates the shell commands required to create the .distro subdirectory and populate it with distribution-specific packaging files using rsync. It also shows how to verify the contents with tree and reset gitignore rules. ```shell mkdir .distro rsync --archive --delete \ --filter 'exclude *.patch' \ --filter 'exclude sources' \ --filter 'exclude .git*' \ ../../rpms/acl/ .distro/ tree -a .distro/ cat > .distro/.gitignore # Reset gitignore rules !* ``` -------------------------------- ### Install Packit on Fedora Source: https://github.com/packit/packit.dev/blob/main/docs/cli/index.md Installs the Packit CLI using the DNF package manager on Fedora Linux. ```shell $ sudo dnf install packit ``` -------------------------------- ### Sync Archive using Tito Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/examples.md Uses the 'tito build' command to create an archive during the pre-sync action. The generated archive is then included in the files_to_sync list for Packit to handle. ```yaml actions: pre-sync: - tito build -o . --tgz files_to_sync: - src: - "-*.tar.gz" dest: . ``` -------------------------------- ### Install Packit from Fedora Copr (Development Snapshot) Source: https://github.com/packit/packit.dev/blob/main/docs/cli/index.md Installs the latest development snapshot of Packit from a Copr repository on Fedora-based systems. ```shell $ sudo dnf copr enable packit/packit-dev $ sudo dnf install packit $ # OR in case you have packit already installed from the Fedora repositories: $ sudo dnf upgrade packit ``` -------------------------------- ### Multiple Copr Builds with Identifiers and Actions Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/examples.md Demonstrates configuring multiple Copr build jobs. One targets 'fedora-all' with an identifier 'fedora'. Another targets 'epel-8' and includes custom actions for creating an archive using sdist and selecting the latest tarball. ```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 ``` -------------------------------- ### Packit CLI Commands for Configuration Source: https://github.com/packit/packit.dev/blob/main/docs/fedora-releases-guide/dist-git-onboarding.md Common Packit CLI commands used for managing dist-git repository configurations, including initialization and validation. ```cli packit dist-git init # Initializes Packit dist-git configuration. ``` ```cli packit config validate # Validates the Packit configuration file. ``` -------------------------------- ### Install Packit from PyPI Source: https://github.com/packit/packit.dev/blob/main/docs/cli/index.md Installs the Packit CLI from the Python Package Index (PyPI) using pip. Note: The package name on PyPI is 'packitos'. ```shell $ pip install --user packitos ``` -------------------------------- ### Define mapping between build and test targets Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/examples.md This configuration illustrates how to map build targets (like EPEL 7 and 8) to specific test distributions (e.g., CentOS 7, Oracle Linux 7 for EPEL 7). This allows for granular control over testing environments. ```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] ``` -------------------------------- ### Install Packit on RHEL/CentOS Stream 9 Source: https://github.com/packit/packit.dev/blob/main/docs/cli/index.md Installs the Packit CLI on RHEL or CentOS Stream 9 by first enabling the EPEL repository and then using DNF. ```shell $ sudo dnf install epel-release $ sudo dnf install packit ``` -------------------------------- ### Download Specfile from Dist-Git Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/examples.md Downloads a .spec file from a dist-git repository using wget. This action is useful for obtaining the spec file before making modifications or building. ```yaml post-upstream-clone: - "wget https://src.fedoraproject.org/rpms/my-package/raw/main/f/my-package.spec -O my-package.spec" ``` -------------------------------- ### Dashboard: Copr Build Installation Instructions Source: https://github.com/packit/packit.dev/blob/main/weekly/2021.md Updates Copr build installation instructions on the dashboard to include detailed information about built packages. This allows users to precisely select and install specific builds from pull requests. ```dashboard // Example of enhanced installation instructions: // Previously: // sudo dnf install packit-package // // Now: // sudo dnf install packit-package-1.2.3-1.fc35.aarch64 (from build ID: abc123xyz) ``` -------------------------------- ### Python Sandcastle Integration for Packit Source: https://github.com/packit/packit.dev/blob/main/docs/reproduce-locally.md Example Python code showing how to use the `sandcastle` library to run commands within a Kubernetes pod, mimicking Packit's deployment. It includes setting up a mapped directory, running commands, and cleaning up the pod. ```python from sandcastle import Sandcastle from sandcastle.mapped_dir import MappedDir # this should be the path to your local clone of the upstream project git_repo_path: str = "fill-me" # kubernetes namespace to use k8s_namespace: str = "myproject" command = ["your", "command", "of", "choice"] # This is how your code gets copied (via rsync) into the openshift pod m_dir = MappedDir(git_repo_path, "/sandcastle", with_interim_pvc=True) o = Sandcastle( image_reference="docker.io/usercont/sandcastle:prod", k8s_namespace_name=k8s_namespace, mapped_dir=m_dir ) o.run() try: output = o.exec(command=command) print(output) finally: o.delete_pod() ``` -------------------------------- ### Install Packit with DNF Source: https://github.com/packit/packit.dev/blob/main/weekly/2019.md Installs the Packit tool using the DNF package manager, enabling the updates-testing repository. ```shell $ dnf install --enablerepo=updates-testing packit ``` -------------------------------- ### Skip Artifact Installation Source: https://github.com/packit/packit.dev/blob/main/docs/configuration/upstream/tests.md Configures the prepare step to skip the installation of artifacts by providing an exclude pattern, useful for specific testing scenarios. ```yaml prepare: - how: install exclude: - ".*" ``` -------------------------------- ### Packit Configuration File Source: https://github.com/packit/packit.dev/blob/main/docs/guide.md Example of a basic Packit configuration file written in YAML. This file specifies essential project details like the path to the specfile, which Packit uses to understand and manage builds. ```yaml # See the documentation for more information: # https://packit.dev/docs/configuration/ specfile_path: package.spec ``` -------------------------------- ### Install Packit from Master Branch Source: https://github.com/packit/packit.dev/blob/main/weekly/2019.md Installs the Packit tool directly from its master branch on GitHub for the latest development version. ```shell $ pip3 install --user git+https://github.com/packit-service/packit ``` -------------------------------- ### Copr Chroot Configuration Example Source: https://github.com/packit/packit.dev/blob/main/weekly/2023.md Example of how to specify additional_modules for Copr chroot configuration in Packit. This allows defining specific module streams for builds. ```APIDOC additional_modules: "httpd:2.4,python:4" ``` -------------------------------- ### Tutorial: Submit Build to OBS Source: https://github.com/packit/packit.dev/blob/main/docs/cli/build/in-obs.md This tutorial demonstrates the basic steps to submit a build to OBS using `packit build in-obs`. It involves navigating to the project directory and executing the command with an optional project name. ```shell cd my/ustream/project/ packit build in-obs --project ``` -------------------------------- ### Packit GitLab CI Pipeline Example Source: https://github.com/packit/packit.dev/blob/main/docs/guide.md Example configuration for using the Packit CLI within a GitLab CI pipeline. It specifies the Packit Docker image and a script to build an SRPM. ```yaml image: quay.io/packit/packit srpm_build: stage: build script: - packit srpm artifacts: paths: - "*.src.rpm" expire_in: 1 week ```