From 95fbd34cdccda0c4f7ec2d097e1189368d2fb3e3 Mon Sep 17 00:00:00 2001 From: Lokesh Mandvekar Date: Tue, 24 Sep 2024 17:35:53 +0530 Subject: [PATCH] [skip-ci] Packit/TMT: Run unit, validate and integration tests This commit adds enables unit, validate and integration testing via TMT. system and ostree tests will be added in followup PRs. Signed-off-by: Lokesh Mandvekar --- .fmf/version | 1 + .packit.yaml | 33 ++++++++++++++++++++++++++++++--- Makefile | 7 ++++++- hack/test-integration.sh | 8 +++++--- hack/tmt/main.fmf | 13 +++++++++++++ integration/tmt/main.fmf | 11 +++++++++++ plans/main.fmf | 20 ++++++++++++++++++++ rpm/skopeo.spec | 2 +- 8 files changed, 87 insertions(+), 8 deletions(-) create mode 100644 .fmf/version create mode 100644 hack/tmt/main.fmf create mode 100644 integration/tmt/main.fmf create mode 100644 plans/main.fmf diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.packit.yaml b/.packit.yaml index 59ebefa91f..30cac0dada 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -31,7 +31,7 @@ jobs: notifications: &copr_build_failure_notification failure_comment: message: "Ephemeral COPR build failed. @containers/packit-build please check." - targets: + targets: &fedora_copr_targets - fedora-development-x86_64 - fedora-development-aarch64 - fedora-latest-x86_64 @@ -43,7 +43,7 @@ jobs: enable_net: true - job: copr_build - trigger: pull_request + trigger: ignore packages: [skopeo-eln] notifications: *copr_build_failure_notification targets: @@ -59,7 +59,7 @@ jobs: trigger: pull_request packages: [skopeo-centos] notifications: *copr_build_failure_notification - targets: + targets: ¢os_copr_targets - centos-stream-9-x86_64 - centos-stream-9-aarch64 - centos-stream-10-x86_64 @@ -88,6 +88,33 @@ jobs: project: podman-next enable_net: true + # Tests on Fedora + - job: tests + trigger: pull_request + packages: [skopeo-fedora] + notifications: &test_failure_notification + failure_comment: + message: "Tests failed. @containers/packit-build please check." + tmt_plan: /plans/upstream + targets: *fedora_copr_targets + tf_extra_params: + environments: + - artifacts: + - type: repository-file + id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/fedora-$releasever/rhcontainerbot-podman-next-fedora-$releasever.repo + + # Tests on CentOS Stream + - job: tests + trigger: pull_request + packages: [skopeo-centos] + notifications: *test_failure_notification + targets: *centos_copr_targets + tf_extra_params: + environments: + - artifacts: + - type: repository-file + id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/centos-stream-$releasever/rhcontainerbot-podman-next-centos-stream-$releasever.repo + # Sync to Fedora - job: propose_downstream trigger: release diff --git a/Makefile b/Makefile index e25c4cfbef..1f373e5a69 100644 --- a/Makefile +++ b/Makefile @@ -202,7 +202,12 @@ test-integration: # Intended for CI, assumed to be running in quay.io/libpod/skopeo_cidev container. +ifdef SKOPEO_BINARY +$(info Skipping build as SKOPEO_BINARY is specified) +test-integration-local: +else test-integration-local: bin/skopeo +endif hack/warn-destructive-tests.sh hack/test-integration.sh @@ -228,7 +233,7 @@ test-unit: $(CONTAINER_RUN) $(MAKE) test-unit-local validate: - $(CONTAINER_RUN) $(MAKE) validate-local + $(CONTAINER_RUN) $(MAKE) tools validate-local # This target is only intended for development, e.g. executing it from an IDE. Use (make test) for CI or pre-release testing. test-all-local: validate-local validate-docs test-unit-local diff --git a/hack/test-integration.sh b/hack/test-integration.sh index 63dc2485a1..861c471ae5 100755 --- a/hack/test-integration.sh +++ b/hack/test-integration.sh @@ -1,8 +1,10 @@ #!/bin/bash -set -e +set -exo pipefail -make PREFIX=/usr install +if [[ ! -f /usr/bin/skopeo ]]; then + make PREFIX=/usr install +fi echo "cd ./integration;" go test $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"} cd ./integration -go test $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"} \ No newline at end of file +go test $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"} diff --git a/hack/tmt/main.fmf b/hack/tmt/main.fmf new file mode 100644 index 0000000000..59f88a547f --- /dev/null +++ b/hack/tmt/main.fmf @@ -0,0 +1,13 @@ +require: + - make + - podman-docker + +/unit: + tag: upstream + summary: Run unit test + test: make -C ../.. test-unit + +/validate: + tag: upstream + summary: Run validate test + test: make -C ../.. tools validate diff --git a/integration/tmt/main.fmf b/integration/tmt/main.fmf new file mode 100644 index 0000000000..baf53fd40e --- /dev/null +++ b/integration/tmt/main.fmf @@ -0,0 +1,11 @@ +require: + - golang + - make + - podman + - skopeo + +duration: 30m + +tag: [ upstream, downstream ] +summary: Run integration tests +test: make -C ../.. test-integration diff --git a/plans/main.fmf b/plans/main.fmf new file mode 100644 index 0000000000..4b754d2da5 --- /dev/null +++ b/plans/main.fmf @@ -0,0 +1,20 @@ +discover: + how: fmf +execute: + how: tmt + +/upstream: + summary: Run tests on upstream PRs + discover+: + filter: tag:upstream + adjust+: + enabled: false + when: initiator is not defined or initiator != packit + +/downstream: + summary: Run tests on bodhi / errata and dist-git PRs + discover+: + filter: tag:downstream + adjust+: + enabled: false + when: initiator == packit diff --git a/rpm/skopeo.spec b/rpm/skopeo.spec index 24f89899af..c9b3cc4838 100644 --- a/rpm/skopeo.spec +++ b/rpm/skopeo.spec @@ -71,7 +71,7 @@ BuildRequires: ostree-devel BuildRequires: glib2-devel BuildRequires: make BuildRequires: shadow-utils-subid-devel -Requires: containers-common >= 4:1-21 +Requires: containers-common %description Command line utility to inspect images and repositories directly on Docker