From 59438486d5bda2b5eafde14423196d793025c96d Mon Sep 17 00:00:00 2001 From: Nicola Sella Date: Thu, 5 Dec 2024 16:36:18 +0100 Subject: [PATCH] Onboard TMT Signed-off-by: Nicola Sella --- .fmf/version | 1 + .packit.yaml | 33 ++++++++++++++++++++++++++++ .pre-commit-config.yaml | 4 ++++ plans/main.fmf | 48 +++++++++++++++++++++++++++++++++++++++++ tests/integration.sh | 3 +++ tests/lint.sh | 3 +++ tests/main.fmf | 13 +++++++++++ 7 files changed, 105 insertions(+) create mode 100644 .fmf/version create mode 100644 plans/main.fmf create mode 100644 tests/integration.sh create mode 100644 tests/lint.sh create mode 100644 tests/main.fmf diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.packit.yaml b/.packit.yaml index a7a14509..62bcb951 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -77,3 +77,36 @@ jobs: packages: [python-podman-fedora] dist_git_branches: - fedora-branched # rawhide updates are created automatically + + # Test linting on the codebase + # This test might break based on the OS and lint used, so we follow fedora-latest as a reference + - job: tests + trigger: pull_request + tmt_plan: /upstream/lint + packages: [python-podman-fedora] + targets: + - fedora-latest-stable + skip_build: true + + # Test integration on all the targets + - job: tests + trigger: pull_request + tmt_plan: /upstream + packages: [python-podman-fedora] + targets: + - fedora-all + + - job: tests + trigger: pull_request + tmt_plan: /upstream + packages: [python-podman-centos] + targets: + - centos-stream-9 + - centos-stream-10 + + - job: tests + packages: [python-podman-rhel] + tmt_plan: /upstream + trigger: pull_request + targets: + - epel-9 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 67fc4d6c..80fce52a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,3 +14,7 @@ repos: args: [ --fix ] # Run the formatter. - id: ruff-format +- repo: https://github.com/teemtee/tmt.git + rev: 1.39.0 + hooks: + - id: tmt-lint diff --git a/plans/main.fmf b/plans/main.fmf new file mode 100644 index 00000000..764dd8e7 --- /dev/null +++ b/plans/main.fmf @@ -0,0 +1,48 @@ +summary: Run Python Podman Tests + +discover: + how: fmf +execute: + how: tmt +prepare: + - name: pkg dependencies + how: install + package: + - make + - python3-pip + + - name: pip dependencies + how: shell + script: + - make + + - name: ssh configuration + how: shell + script: + - ssh-keygen -t ecdsa -b 521 -f /root/.ssh/id_ecdsa -P "" + - cp /root/.ssh/authorized_keys /root/.ssh/authorized_keys% + - cat /root/.ssh/id_ecdsa.pub >>/root/.ssh/authorized_keys + +/upstream: + /lint: + summary: Run Python Podman Tests on upstream PRs + discover+: + test: /tests/lint + + /integration_tests: + summary: Run Python Podman Tests on upstream PRs + discover+: + test: /tests/integration_tests + + adjust+: + enabled: false + when: initiator is not defined or initiator != packit + +/downstream: + summary: Run Python Podman Tests on bodhi / errata and dist-git PRs + discover+: + test: /tests/integration_tests + + adjust+: + enabled: false + when: initiator == packit diff --git a/tests/integration.sh b/tests/integration.sh new file mode 100644 index 00000000..9d13cd77 --- /dev/null +++ b/tests/integration.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +PYTHON ?= $(shell command -v python3 2>/dev/null || command -v python || which python3) +tox -e coverage,py39,py310,py311,py312,py313 diff --git a/tests/lint.sh b/tests/lint.sh new file mode 100644 index 00000000..2fbb69b9 --- /dev/null +++ b/tests/lint.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +PYTHON ?= $(shell command -v python3 2>/dev/null || command -v python || which python3) +python3 -m tox -e format,lint diff --git a/tests/main.fmf b/tests/main.fmf new file mode 100644 index 00000000..4ac23bbf --- /dev/null +++ b/tests/main.fmf @@ -0,0 +1,13 @@ +require: + - make + - python3-pip + +/lint: + tag: [ upstream ] + summary: Run Linting on the whole codebase + test: lint.sh + +/integration_tests: + tag: [ upstream, downstream ] + summary: Run integration tests + test: integration.sh