forked from rpm-software-management/mock
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: Enable tests with Packit + Fedora Testing Farm
- Behave tests now remove dnf5 by default first as the dnf5 packgae is installed by default with `dnf install mock` (brings in weak dependencies). - Build with Packit also into the stable Fedora, so we can later test on stable fedora. - When run with TMT (not only in Testing Farm), we don't generate the Mock package with Tito anymore, but we download it pre-built from Copr. - Packit config uses 'merge_pr_in_ci: false' because we don't want to have "git sha" mismatch like in packit/packit-service#2329 - Packit: move the `actions:` configuration top-level. - Apply work-around for test failure rpm-software-management#1300. - Packit: start building also for pushes. Relates: https://gitlab.com/testing-farm/tests/-/issues/2 Fixes: rpm-software-management#1258
- Loading branch information
1 parent
f6d087c
commit 2651255
Showing
15 changed files
with
313 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
mock/integration-tests/setup-playbook/files/install-copr-packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#! /bin/bash | ||
|
||
# Install RPM packages (and dependencies) identified by the (a) package names, | ||
# (b) upstream commmit and (c) Copr directory. The short variant of the | ||
# upstream commit must be part of the packages' Release in NVR. | ||
# | ||
# ARG1: coprowner/projectname:dir | ||
# ARG2: upstream-commit | ||
# ARGN: packagename1 packagename2 ... | ||
|
||
# TODO: DNF5/YUM compat? | ||
DNF=/usr/bin/dnf-3 | ||
REPOQUERY=( "$DNF" repoquery ) | ||
DOWNLOAD=( "$DNF" download ) | ||
|
||
copr_dir=$1 ; shift | ||
commit=$1 ; shift | ||
copr_uri=https://download.copr.fedorainfracloud.org/results | ||
|
||
copr_chroot() ( | ||
# mimic: https://github.com/rpm-software-management/dnf5/blob/c6edcd75260accf7070f261e5b406fcf1f5db328/dnf5-plugins/copr_plugin/copr_config.cpp#L71-L80 | ||
. /etc/os-release | ||
name=$ID | ||
version=$VERSION_ID | ||
arch=$(rpm --eval %_arch) | ||
if test "$name" = fedora; then | ||
if test "$REDHAT_SUPPORT_PRODUCT_VERSION" = rawhide; then | ||
version=rawhide | ||
fi | ||
fi | ||
echo "$name-$version-$arch" | ||
) | ||
|
||
repo=$copr_uri/$copr_dir/$(copr_chroot) | ||
|
||
echo >&2 "using repo: $repo" | ||
|
||
repoid=xyztest | ||
|
||
export clean_cache=true | ||
|
||
|
||
repos=( "--repofrompath=$repoid,$repo" ) | ||
|
||
_repoquery() { | ||
local opts=( "${repos[@]}" --disablerepo='*' --enablerepo "$repoid" ) | ||
if ${clean_cache-true}; then | ||
opts+=( "--setopt=$repoid.metadata_expire=1" ) | ||
fi | ||
local cmd=( "${REPOQUERY[@]}" "${opts[@]}" "$@" ) | ||
info "Executing: ${cmd[*]}" | ||
"${cmd[@]}" 2>/dev/null | ||
} | ||
|
||
info() { echo >&2 "INFO: $*" ; } | ||
error() { echo >&2 "ERROR: $*" ; false; } | ||
die() { echo >&2 "FATAL: $*" ; exit 1 ; } | ||
|
||
find_nvr() { | ||
# ARGS: $1=pkg $2=commit | ||
# RETURN: $find_nvr_result | ||
# STATUS: true if found | ||
local _pkgname=$1 _commit=${2:0:7} _found=false | ||
while read -r name version release; do | ||
test -z "$name" && continue | ||
test "$name" = "$_pkgname" || continue | ||
case $release in | ||
*$_commit*) | ||
find_nvr_result=$name-$version-$release | ||
$_found && error "second occurence of $name-$version-$release" | ||
_found=true | ||
;; | ||
*) | ||
continue | ||
;; | ||
esac | ||
done < <( _repoquery --qf='%{NAME} %{VERSION} %{RELEASE}\n' ) | ||
$_found || error "$_pkgname with $commit in release not found" | ||
} | ||
|
||
nvrs=() | ||
SECONDS=0 | ||
TIMEOUT=${TIMEOUT-1200} # 20 minutes by default | ||
for pkg; do | ||
while true; do | ||
if find_nvr "$pkg" "$commit"; then | ||
nvrs+=( "$find_nvr_result" ) | ||
clean_cache=false | ||
break | ||
fi | ||
test "$SECONDS" -gt "$TIMEOUT" && die "The timeout ${TIMEOUT}s left" | ||
clean_cache=true | ||
sleep 5 | ||
done | ||
done | ||
|
||
if test -n "$SRPM_DOWNLOAD_DIR"; then | ||
mkdir -p "$SRPM_DOWNLOAD_DIR" | ||
cmd=( "${DOWNLOAD[@]}" "${repos[@]}" '--disablerepo=*' --enablerepo xyztest | ||
"${nvrs[@]}" --source --downloaddir "$SRPM_DOWNLOAD_DIR" ) | ||
else | ||
cmd=( "$DNF" -y install "${nvrs[@]}" "${repos[@]}" --nogpgcheck ) | ||
fi | ||
|
||
info "Running: ${cmd[*]}" | ||
"${cmd[@]}" |
23 changes: 23 additions & 0 deletions
23
mock/integration-tests/setup-playbook/files/install-mock-packages-built-by-packit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#! /bin/bash -x | ||
|
||
# Install specific Mock RPM packages (and dependencies) from a Copr repository | ||
# created by Packit PR or PUSH workflow. Pick the precise package version built | ||
# from the latest commit. | ||
|
||
_d=$(dirname "$(readlink -f "$0")") | ||
|
||
if test -n "$PACKIT_PR_ID"; then | ||
PROJECT=packit/rpm-software-management-mock-$PACKIT_PR_ID | ||
COMMIT=$PACKIT_COMMIT_SHA | ||
elif test -n "$PACKIT_COPR_PROJECT"; then | ||
PROJECT=$PACKIT_COPR_PROJECT | ||
COMMIT=$PACKIT_COMMIT_SHA | ||
elif test -n "$TEST_GIT_MAIN"; then | ||
PROJECT=@mock/mock | ||
COMMIT=$(curl -H "Accept: application/vnd.github.VERSION.sha" https://api.github.com/repos/rpm-software-management/mock/commits/main) | ||
else | ||
echo >&2 "Can't decide where to install packages from" | ||
exit 1 | ||
fi | ||
|
||
"$_d/install-copr-packages" "$PROJECT" "$COMMIT" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
- name: Prepare the testing machine for running Mock tests | ||
hosts: all | ||
user: "root" | ||
vars: | ||
mock_test_username: mockbuild | ||
mock_test_workdir: /home/mock/mock-testing | ||
mock_gpg_dir: "/home/mockbuild/gpg" | ||
mock_gpg_wrapper: "/home/mockbuild/gpg-mock" | ||
mock_test_rpmmacros: /home/mockbuild/.rpmmacros | ||
mock_lvm_volume: /test-lvm-disk | ||
mock_clone: /home/mockbuild/mock | ||
no_subscription_management: true | ||
|
||
tasks: | ||
- include_tasks: tasks/main.yml | ||
|
||
- name: upload the "install copr package" script | ||
copy: | ||
src: "{{ item }}" | ||
dest: "/usr/bin/{{ item }}" | ||
mode: '0755' | ||
loop: | ||
- install-copr-packages | ||
- install-mock-packages-built-by-packit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
summary: run the behave tests in Fedora Testing Farm | ||
discover: | ||
- how: fmf | ||
filter: "tag: behave" | ||
|
||
prepare: | ||
- how: ansible | ||
playbook: mock/integration-tests/setup-playbook/play-tf.yml | ||
|
||
execute: | ||
- how: tmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
summary: run the old testsuite in Fedora Testing Farm | ||
discover: | ||
- how: fmf | ||
filter: "tag: old_testsuite" | ||
|
||
prepare: | ||
- how: ansible | ||
playbook: mock/integration-tests/setup-playbook/play-tf.yml | ||
|
||
execute: | ||
- how: tmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
summary: Execute the behave test | ||
test: ./test.sh | ||
tag: behave | ||
duration: 2h | ||
|
||
require: | ||
- type: file | ||
pattern: /behave |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh -eux | ||
|
||
cd ../../../behave | ||
install-mock-packages-built-by-packit mock-core-configs mock | ||
behave |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
summary: Execute the old `make check` test-suite | ||
test: ./test.sh | ||
tag: old_testsuite | ||
duration: 3h | ||
|
||
require: | ||
- type: file | ||
# copy-paste the whole directory | ||
pattern: / |
Oops, something went wrong.