Skip to content

Commit

Permalink
[skip-ci] Packit/TMT: Run unit, validate and integration tests
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
lsm5 committed Sep 24, 2024
1 parent e39efb1 commit 8790b41
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 9 deletions.
1 change: 1 addition & 0 deletions .fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
35 changes: 31 additions & 4 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -56,10 +56,10 @@ jobs:
enable_net: true

- job: copr_build
trigger: pull_request
trigger: ignore
packages: [skopeo-centos]
notifications: *copr_build_failure_notification
targets:
targets: &centos_copr_targets
- centos-stream-9-x86_64
- centos-stream-9-aarch64
- centos-stream-10-x86_64
Expand Down Expand Up @@ -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: ignore
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
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions hack/test-integration.sh
Original file line number Diff line number Diff line change
@@ -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"}
go test $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"}
13 changes: 13 additions & 0 deletions hack/tmt/main.fmf
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions integration/tmt/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require:
- golang
- make
- podman
- skopeo

duration: 30m

tag: [ upstream, downstream ]
summary: Run integration tests
test: make -C ../.. test-integration
20 changes: 20 additions & 0 deletions plans/main.fmf
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion rpm/skopeo.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8790b41

Please sign in to comment.