Skip to content

Commit

Permalink
ci(tmt): run the tests on Testing Farm
Browse files Browse the repository at this point in the history
Signed-off-by: Matej Focko <[email protected]>
  • Loading branch information
mfocko committed Jun 17, 2024
1 parent 3531669 commit d8c059a
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 0 deletions.
1 change: 1 addition & 0 deletions .fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
33 changes: 33 additions & 0 deletions .packit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
packit_instances: ["prod", "stg"]

packages:
packit-service:
downstream_package_name: packit-service
upstream_package_name: packit-service
upstream_project_url: https://github.com/packit/packit-service
paths:
- ./
specfile_path: none.spec

issue_repository: https://github.com/packit/packit-service

actions:
pre-sync:
# FMF has to be installed on system where you are calling this tool.
- python3 plans/git_reference.py

srpm_build_deps: []

jobs:
- job: tests
trigger: pull_request
targets:
- epel-9
skip_build: true
tf_extra_params:
environments:
# to run the container specified in the tests
- os: {}
packages:
- packit-service
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@ repos:
- LICENSE_HEADER.txt
- --comment-style
- "#"
- repo: https://github.com/teemtee/tmt.git
rev: 1.29.0
hooks:
- id: tmt-lint
15 changes: 15 additions & 0 deletions plans/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Run tests locally:

$ tmt -v run -a provision -h local

Run tests in a container using podman:

$ sudo dnf install tmt-provision-container
$ tmt -v run -a provision -h container

For more info see:

- https://packit.dev/docs/testing-farm/
- [tmt @ DevConf 2021 slides](https://static.sched.com/hosted_files/devconfcz2021/37/tmt-slides.pdf)
- [fmf docs](https://fmf.readthedocs.io)
- [tmt docs](https://tmt.readthedocs.io)
8 changes: 8 additions & 0 deletions plans/full.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
summary: Unit, integration & functional tests.

discover+:
filter: tag:full

provision:
how: container
image: quay.io/packit/packit-service-tests:stg
17 changes: 17 additions & 0 deletions plans/git_reference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/python

# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

import subprocess
from pathlib import Path

import fmf

tree_root = Path.cwd().absolute()
node = fmf.Tree(tree_root).find("/plans")
with node as data:
data["discover"]["url"] = "https://github.com/packit/packit-service.git"
data["discover"]["ref"] = (
subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip()
)
5 changes: 5 additions & 0 deletions plans/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
discover:
how: fmf

execute:
how: tmt
42 changes: 42 additions & 0 deletions tests/full.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
summary:
Full test suite of the Packit Service

component:
- packit-service
tier: 1
tag:
- full

adjust+:
- when: initiator == packit
environment+:
COLOR: "no"
CONTAINER_RUN_INTERACTIVE: ""

path: /
test: 'make check "TEST_TARGET=$TEST_TARGET"'
duration: 30m

/custom-target:
summary: Custom tests
description: |
Custom tests that are useful for debugging as it is much easier to override
the ‹TEST_TARGET› environment variable, disabled in CI as it is split into
the separate test suites.
tag: manual
adjust:
- when: initiator != human
enabled: false
because: "This test suite is for manually specifying the target and to be run locally"

/unit:
summary: Unit tests
order: 1
environment+:
TEST_TARGET: tests/unit/

/integration:
summary: Integration tests
order: 2
environment+:
TEST_TARGET: tests/integration/

0 comments on commit d8c059a

Please sign in to comment.