Skip to content

Commit

Permalink
Merge pull request #29 from jpopelka/jirka
Browse files Browse the repository at this point in the history
Bunch of various updates
  • Loading branch information
jpopelka authored Dec 4, 2023
2 parents edd2d32 + ca787bb commit 2c9b222
Show file tree
Hide file tree
Showing 28 changed files with 632 additions and 506 deletions.
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

version: 2
updates:
- package-ecosystem: github-actions
Expand Down
19 changes: 19 additions & 0 deletions .packit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
jobs:
- job: copr_build
trigger: pull_request
targets:
- fedora-all
- epel-7
- epel-8
- epel-9
# - job: copr_build
# trigger: commit
# branch: main
# targets:
# - fedora-all
# - epel-7
# - epel-8
# - epel-9
# owner: "@osci"
# project: mini-tps
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# HOWTO: https://pre-commit.com/#usage
# dnf install pre-commit
# pre-commit install -t pre-commit -t pre-push

repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff-format
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.6
hooks:
- id: shellcheck
args: [--severity=error]
# unused ?
exclude: (ver_cmp.sh|mtps*-xunit|mtps-tag|mtps-run-mtests|mtps-module-test)

ci:
autoupdate_schedule: quarterly
10 changes: 5 additions & 5 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and
modification follow.

GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

Expand Down Expand Up @@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
Expand Down Expand Up @@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
Expand Down Expand Up @@ -225,7 +225,7 @@ impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
Expand Down Expand Up @@ -278,7 +278,7 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
This is a lightweight version of the TPS.

Installability test checks that given RPMs can be:
* installed
* removed
* updated
* downgraded

- installed
- removed
- updated
- downgraded

mini-tps has no external dependencies. The original TPS runs on Red Hat products, mini-tps
was designed to be triggered early in the development process. It runs on Koji/Brew builds.
Expand Down Expand Up @@ -46,4 +47,4 @@ See `mtps-prepare-system --list` for the list of available profiles.
```

5. If you wish to test another package, remove `/etc/yum.repos.d/brew-${TASK_ID}.repo`
and the files in `/var/lib/brew-repo` and repeat from the step 3.
and the files in `/var/lib/brew-repo` and repeat from the step 3.
6 changes: 3 additions & 3 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ rpmbuild --define="_sourcedir $PWD" --define="%_srcrpmdir $PWD" -bs mini-tps.spe
```
xmllint --xpath 'string(//member[name="build_id"]/value/int/text())' list.xml
curl -k --data @xml-list-rpms "${BREWHUB}" > listg
brewbuild echo 'ls //member[value/string="src"]/../member[name="nvr"]/value/string/text()' | xmllint --shell list.xml
echo 'ls //member[value/string="noarch"]/../member[name="nvr"]/value/string/text()' | xmllint --shell listg | sed -n -e 's/^.*[[:space:]]//p'
brewbuild echo 'ls //member[value/string="src"]/../member[name="nvr"]/value/string/text()' | xmllint --shell list.xml
echo 'ls //member[value/string="noarch"]/../member[name="nvr"]/value/string/text()' | xmllint --shell listg | sed -n -e 's/^.*[[:space:]]//p'
curl -k --data @xmldownloadTaskOutput.xml "${BREWHUB}"
brew -d --debug-xmlrpc taskinfo 18326749
brew -d --debug-xmlrpc taskinfo 18326749
koji list-api
git archive --format=tar.gz --prefix mini-tps/ -o mini-tps.tar.gz -v master
rpmdev-bumpspec --comment='Build with the latest merged PRs.' --userstring='Andrei Stepanov <[email protected]>' mini-tps.spec
Expand Down
53 changes: 29 additions & 24 deletions mini-tps.spec
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
Name: mini-tps
Version: 0.1
Release: 161%{?dist}
Release: 162%{?dist}
Summary: Mini TPS - Test Package Sanity

License: GPLv2
URL: https://gitlab.cee.redhat.com/osci/mini-tps
URL: https://github.com/fedora-ci/mini-tps
Source0: %{name}.tar.gz
Requires: yum-utils
# List of packages for wich do not run 'remove' test.
Requires: openssh-server yum
# mtps-mutils
Requires: libmodulemd
BuildArch: noarch

%if 0%{?rhel} > 7
Expand All @@ -18,51 +20,54 @@ Requires: dnf-plugins-core
Requires: libselinux-utils
%endif

# mtps-mutils
%if 0%{?rhel} == 7
Requires: python2-gobject-base
%else
Requires: python3-gobject-base
%endif

%description
Light version of TPS

%prep
%setup -n %{name}
%autosetup -n %{name}

%build

%install
mkdir -p %{buildroot}%{_prefix}/local/bin/
cp -rfp mtps* %{buildroot}%{_prefix}/local/bin/
mkdir -p %{buildroot}%{_sysconfdir}/dnf/protected.d
cp -pf mini-tps.conf %{buildroot}%{_sysconfdir}/dnf/protected.d/

mkdir -p %{buildroot}%{_sbindir} # epel7
install -pD -m 0755 --target-directory=%{buildroot}%{_sbindir} mtps-*
install -pD -m 0644 mini-tps.conf %{buildroot}%{_sysconfdir}/dnf/protected.d/mini-tps.conf
# viewer
mkdir -p %{buildroot}%{_datarootdir}/mini-tps/viewer/
cp -pf viewer/viewer.html %{buildroot}%{_datarootdir}/mini-tps/viewer/
mkdir -p %{buildroot}%{_libexecdir}/mini-tps/viewer/
cp -pf viewer/generate-result-json %{buildroot}%{_libexecdir}/mini-tps/viewer/
install -pD -m 0755 viewer/generate-result-json %{buildroot}%{_libexecdir}/mini-tps/viewer/generate-result-json
install -pD -m 0644 viewer/viewer.html %{buildroot}%{_datarootdir}/mini-tps/viewer/viewer.html

# profiles
mkdir -p %{buildroot}%{_datarootdir}/mini-tps/profiles/{rhel,centos-stream,fedora}/
# rhel
cp -rfp profiles/rhel/{repos,optrepos}/ %{buildroot}%{_datarootdir}/mini-tps/profiles/rhel/
# centos-stream
cp -rfp profiles/centos-stream/{repos,optrepos}/ %{buildroot}%{_datarootdir}/mini-tps/profiles/centos-stream/
# fedora
cp -rfp profiles/fedora/repos/ %{buildroot}%{_datarootdir}/mini-tps/profiles/fedora/

# prepare scripts
mkdir -p %{buildroot}%{_libexecdir}/mini-tps/{rhel,centos-stream,fedora}/
# rhel
cp -pf profiles/rhel/prepare-system %{buildroot}%{_libexecdir}/mini-tps/rhel/
# centos-stream
cp -pf profiles/centos-stream/prepare-system %{buildroot}%{_libexecdir}/mini-tps/centos-stream/
# fedora
cp -pf profiles/fedora/prepare-system %{buildroot}%{_libexecdir}/mini-tps/fedora/
install -pD -m 0755 profiles/rhel/prepare-system %{buildroot}%{_libexecdir}/mini-tps/rhel/prepare-system
install -pD -m 0755 profiles/centos-stream/prepare-system %{buildroot}%{_libexecdir}/mini-tps/centos-stream/prepare-system
install -pD -m 0755 profiles/fedora/prepare-system %{buildroot}%{_libexecdir}/mini-tps/fedora/prepare-system

%files
%{_prefix}/local/bin/mtps*
%{_sysconfdir}/dnf/protected.d/mini-tps.conf
%{_sbindir}/mtps-*
%config %{_sysconfdir}/dnf/protected.d/mini-tps.conf
%{_datarootdir}/mini-tps/*
%{_libexecdir}/mini-tps/*


%changelog
* Fri Nov 24 2023 Jiri Popelka <[email protected]> - 0.1-162
- URL update
- move mtps-* executables from /usr/local/bin/ to /usr/sbin/
- use install instead of mkdir & cp
- mtps-mutils Requires: python-gobject-base

* Mon Jul 31 2023 Andrei Stepanov <[email protected]> - 0.1-161
- new build

Expand Down
20 changes: 9 additions & 11 deletions mtps-enable-mod-reqs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -efu
#!/usr/bin/bash -efu

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -15,7 +15,7 @@
# Author: Andrei Stepanov <[email protected]>


PROG="${PROG:-${0##*/}}"
: "${PROG:=${0##*/}}"

# Source `mtps-setup' from $PATH
if command -v "mtps-setup" >/dev/null; then source "mtps-setup"; fi
Expand Down Expand Up @@ -48,7 +48,6 @@ box_out() {
echo -e "| ${b//?/ } |\n-${b//?/-}-"
}

# http://wiki.bash-hackers.org/howto/getopts_tutorial
opt_str="$@"
opt=$(getopt -n "$0" --options "hvt:s:m:" --longoptions "help,verbose,mmd:,test:,selinux:" -- "$@")
eval set -- "$opt"
Expand Down Expand Up @@ -78,12 +77,9 @@ done

# Entry

DEBUG="${DEBUG:-}"
MMD="${MMD:-}"
# Put logs by default at CDIR/mtps-logs
LOGS_DIR="${LOGS_DIR:-mtps-logs}"
: "${DEBUG:=}"

debug "MMD: $MMD"
debug "MMD: ${MMD:=}"
debug "Use ${YUMDNFCMD}"

# Test correct invocation
Expand All @@ -107,7 +103,9 @@ box_out "# DEPENDENCY" "" "Modules to be enabled:" "" "${requires_list[@]:-}"

# Prefix all files with common suffix
TESTRUN_ID="$(date +%H%M%S)"
mkdir -p "$LOGS_DIR"

# Put logs by default at CWD/mtps-logs
mkdir -p "${LOGS_DIR:=mtps-logs}"

for require in "${requires[@]}"; do
ret=1
Expand All @@ -127,7 +125,7 @@ for require in "${requires[@]}"; do
"" \
" Name: $name" \
" Stream: $stream"
logfname="${LOGS_DIR%%/}/$TESTRUN_ID-enable-$name-$stream.log"
logfname="${LOGS_DIR%%/}/${TESTRUN_ID}-enable-${name}-${stream}.log"
echo "Reset module: $name" | tee -a "$logfname"
"${YUMDNFCMD}" -y module reset "$name" 2>&1 | tee -a "$logfname"
test_status="${PIPESTATUS[0]}"
Expand All @@ -150,7 +148,7 @@ for require in "${requires[@]}"; do
fi
done
if [ "$ret" -ne "0" ]; then
echo "Fail to meet module dependecy. No one can be enabled from: ${require// / or }"
echo "Fail to meet module dependency. No one can be enabled from: ${require// / or }"
exit 1
fi
done
Expand Down
2 changes: 1 addition & 1 deletion mtps-gen-xunit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -efu
#!/usr/bin/bash -efu

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
13 changes: 6 additions & 7 deletions mtps-get-builds
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -efu
#!/usr/bin/bash -efu

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -205,7 +205,6 @@ GB_CREATEREPO="${GB_CREATEREPO:-}"
GB_CREATEREPO_BIN="${GB_CREATEREPO_BIN:-}"
GB_ONLYINREPO="${GB_ONLYINREPO:-}"
GB_INSTALLREPOFILE="${GB_INSTALLREPOFILE:-}"
LOGS_DIR="${LOGS_DIR:-mtps-logs}"

# http://wiki.bash-hackers.org/howto/getopts_tutorial
opt_str="$@"
Expand Down Expand Up @@ -261,14 +260,14 @@ if [ -z "$GB_BUILD" ]; then
exit
fi

mkdir -p "$LOGS_DIR"
mkdir -p "${LOGS_DIR:=mtps-logs}"
LOGS_DIR="$(realpath "$LOGS_DIR")"
while true; do
TESTRUN_ID="$(date +%H%M%S)"
logfname="${LOGS_DIR%%/}/${TESTRUN_ID}-${GB_BUILD}-mtps-get-builds.log"
logfname_pass="$(dirname "$logfname")/PASS-$(basename "$logfname")"
logfname_fail="$(dirname "$logfname")/FAIL-$(basename "$logfname")"
if [ -e "$logfname" -o -e "$logfname_pass" -o -e "$logfname_fail" ]; then
if [[ -e "$logfname" || -e "$logfname_pass" || -e "$logfname_fail" ]]; then
sleep 1
continue
fi
Expand All @@ -281,7 +280,7 @@ do_clean_exit() {
rc=$?
trap - SIGINT SIGTERM SIGABRT EXIT # clear the trap
new_logfname="$logfname_fail"
if [ "$rc" = "0" -o "$rc" = "111" ]; then
if [[ "$rc" -eq 0 || "$rc" -eq 111 ]]; then
new_logfname="$logfname_pass"
fi
# Close tee pipes
Expand Down Expand Up @@ -355,7 +354,7 @@ for pkg in $rpms_from_build_noarch; do
download_rpm "$url"
done

if [ -z "$GB_CREATEREPO" -o ! -d "$GB_REPODIR" ]; then
if [[ -z "$GB_CREATEREPO" || ! -d "$GB_REPODIR" ]]; then
exit 0
fi

Expand All @@ -373,7 +372,7 @@ echo "Repo file:"
echo "$repo_file_text"
id="$(id -u)"

if [ -n "$GB_INSTALLREPOFILE" -a "$id" = "0" ]; then
if [[ -n "$GB_INSTALLREPOFILE" && "$id" -eq 0 ]]; then
repofile="/etc/yum.repos.d/brew-${brew_build_id}.repo"
echo "Create repo file: $repofile"
echo "$repo_file_text" > "$repofile"
Expand Down
Loading

0 comments on commit 2c9b222

Please sign in to comment.