Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avoid viewer.html if rpminspect failed #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 37 additions & 21 deletions tests/rpminspect/rpminspect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,19 @@ rlJournalStart
[[ -n "${RPMINSPECT_SUPPRESS}" ]] && rlRun "args=\"\$args --suppress=${RPMINSPECT_SUPPRESS}\"" 0 "Set args: Suppress threshold"
rlRun "args=\"\$args ./inspect_builds/$PACKIT_PACKAGE_NVR\" && echo \$args" 0 "Set args: Set downloaded source as after_build"
rlRun "/usr/bin/rpminspect $args" 0 "Run rpminspect"
# Get the number of BAD and VERIFY check results
# Note about jq syntax used:
# - .[][] : collapse the dict of list of objects into a series of objects
# - select(.result ...) : filter the series of objects by the `result` value
# - [ ... ] | length : create a list of the filtered object series and count the length
rlRun "bad_results=\$(jq '[.[][] | select(.result == \"BAD\")] | length' $TMT_TEST_DATA/result.json)" 0 "Count the BAD check results"
rlRun "verify_results=\$(jq '[.[][] | select(.result == \"VERIFY\")] | length' $TMT_TEST_DATA/result.json)" 0 "Count the VERIFY check results"
rlRun "info_results=\$(jq '[.[][] | select(.result == \"INFO\")] | length' $TMT_TEST_DATA/result.json)" 0 "Count the INFO check results"
rlRun "ok_results=\$(jq '[.[][] | select(.result == \"OK\")] | length' $TMT_TEST_DATA/result.json)" 0 "Count the OK check results"
rlRun "cp $TMT_PLAN_DATA/viewer.html $TMT_TEST_DATA/viewer.html"
# Calculate results only if result.json was produced
if [[ -f "$TMT_TEST_DATA/result.json" ]]; then
# Get the number of BAD and VERIFY check results
# Note about jq syntax used:
# - .[][] : collapse the dict of list of objects into a series of objects
# - select(.result ...) : filter the series of objects by the `result` value
# - [ ... ] | length : create a list of the filtered object series and count the length
rlRun "bad_results=\$(jq '[.[][] | select(.result == \"BAD\")] | length' $TMT_TEST_DATA/result.json)" 0 "Count the BAD check results"
rlRun "verify_results=\$(jq '[.[][] | select(.result == \"VERIFY\")] | length' $TMT_TEST_DATA/result.json)" 0 "Count the VERIFY check results"
rlRun "info_results=\$(jq '[.[][] | select(.result == \"INFO\")] | length' $TMT_TEST_DATA/result.json)" 0 "Count the INFO check results"
rlRun "ok_results=\$(jq '[.[][] | select(.result == \"OK\")] | length' $TMT_TEST_DATA/result.json)" 0 "Count the OK check results"
rlRun "cp $TMT_PLAN_DATA/viewer.html $TMT_TEST_DATA/viewer.html"
fi
rlPhaseEnd

rlPhaseStartCleanup
Expand Down Expand Up @@ -107,14 +110,27 @@ else
fi
fi
# Write the actual results.yaml
cat <<EOF >> "$TMT_TEST_DATA/results.yaml"
- name: /
result: ${result}
note: ${bad_results} BAD, ${verify_results} VERIFY, ${info_results} INFO, ${ok_results} OK
log:
- ../output.txt
- ../journal.txt
- ../journal.xml
- viewer.html
- result.json
EOF
if [[ -f "$TMT_TEST_DATA/results.json" ]]; then
# Add rpminspect results
cat <<-EOF >> "$TMT_TEST_DATA/results.yaml"
- name: /
result: ${result}
note: ${bad_results} BAD, ${verify_results} VERIFY, ${info_results} INFO, ${ok_results} OK
log:
- ../output.txt
- ../journal.txt
- ../journal.xml
- viewer.html
- result.json
EOF
else
# Add the beakerlib data only
cat <<-EOF >> "$TMT_TEST_DATA/results.yaml"
- name: /
result: ${result}
log:
- ../output.txt
- ../journal.txt
- ../journal.xml
EOF
fi