From 16a4290c3c927c4adf1b6416fcad00fe1d029122 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Mon, 17 Jun 2024 14:14:45 +0200 Subject: [PATCH] ci(tmt): run the tests on Testing Farm Signed-off-by: Matej Focko --- .fmf/version | 1 + .packit.yaml | 34 +++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 4 ++++ plans/README.md | 15 +++++++++++++++ plans/full.fmf | 8 ++++++++ plans/git_reference.py | 17 +++++++++++++++++ plans/main.fmf | 5 +++++ tests/full.fmf | 42 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 126 insertions(+) create mode 100644 .fmf/version create mode 100644 .packit.yaml create mode 100644 plans/README.md create mode 100644 plans/full.fmf create mode 100644 plans/git_reference.py create mode 100644 plans/main.fmf create mode 100644 tests/full.fmf diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.packit.yaml b/.packit.yaml new file mode 100644 index 000000000..a4131b5ef --- /dev/null +++ b/.packit.yaml @@ -0,0 +1,34 @@ +--- +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: + - os: + # to run the container specified in the tests + compose: "" + packages: + - packit-service diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e81f18fc7..7171f9af1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/plans/README.md b/plans/README.md new file mode 100644 index 000000000..22c63d965 --- /dev/null +++ b/plans/README.md @@ -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) diff --git a/plans/full.fmf b/plans/full.fmf new file mode 100644 index 000000000..12fa58283 --- /dev/null +++ b/plans/full.fmf @@ -0,0 +1,8 @@ +summary: Unit, integration & functional tests. + +discover+: + filter: tag:full + +provision: + how: container + image: quay.io/packit/packit-service-tests:stg diff --git a/plans/git_reference.py b/plans/git_reference.py new file mode 100644 index 000000000..b4300c600 --- /dev/null +++ b/plans/git_reference.py @@ -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() + ) diff --git a/plans/main.fmf b/plans/main.fmf new file mode 100644 index 000000000..3dde10392 --- /dev/null +++ b/plans/main.fmf @@ -0,0 +1,5 @@ +discover: + how: fmf + +execute: + how: tmt diff --git a/tests/full.fmf b/tests/full.fmf new file mode 100644 index 000000000..da9e6826d --- /dev/null +++ b/tests/full.fmf @@ -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/