Skip to content

Commit

Permalink
scripts: Download coverage data directly from Testing Farm
Browse files Browse the repository at this point in the history
Instead of using an intermediary files storage service, download the
file directly from the Testing Farm artifacts storage.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
  • Loading branch information
ansasaki committed Jan 17, 2025
1 parent a77290d commit d7089c9
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions scripts/download_packit_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ PROJECT="keylime/keylime"
# uploads coverage XML files to a web drive
# currently we are doing that in a job running tests on Fedora-41
TF_JOB_DESC="testing-farm:fedora-41-x86_64"
TF_TEST_OUTPUT="/setup/generate_coverage_report.*/output.txt"
TF_ARTIFACTS_URL_PREFIX="https://artifacts.dev.testing-farm.io"
TF_COVERAGE_DATA_DIR="/setup/generate_coverage_report.*/data"

GITHUB_API_PREFIX_URL="https://api.github.com/repos/${PROJECT}"

Expand Down Expand Up @@ -135,21 +135,29 @@ fi
# now we have TF_ARTIFACTS_URL so we can proceed with the download
echo "TF_ARTIFACTS_URL=${TF_ARTIFACTS_URL}"

TF_TESTLOG=$( curl --retry 5 ${TF_ARTIFACTS_URL}/results.xml | grep -E -o "${TF_ARTIFACTS_URL}.*${TF_TEST_OUTPUT}" )
echo "TF_TESTLOG=${TF_TESTLOG}"
COVERAGE_DIR=$( curl --retry 5 ${TF_ARTIFACTS_URL}/results.xml | grep -E -o "${TF_ARTIFACTS_URL}.*${TF_COVERAGE_DATA_DIR}" )
echo "COVERAGE_DIR=${COVERAGE_DIR}"

# parse the URL of coverage XML file and download it
curl --retry 5 -s "${TF_TESTLOG}" &> ${TMPFILE}
for REPORT in coverage.packit.xml coverage.testsuite.xml coverage.unittests.xml; do
COVERAGE_URL=$( grep "$REPORT report is available at" ${TMPFILE} | grep -E -o "https?://[^[:space:]]*" )
echo "COVERAGE_URL=${COVERAGE_URL}"
COVERAGE_FILE="coverage.tar.gz"

if [ -z "${COVERAGE_URL}" ]; then
echo "Could not parse $REPORT URL from test log ${TF_TESTLOG}"
exit 5
fi
COVERAGE_URL=${COVERAGE_DIR}/${COVERAGE_FILE}
echo "Trying to download \"${COVERAGE_URL}\""

# download the file
curl -L -o "${REPORT}" "${COVERAGE_URL}"
# download the file
if curl --fail-with-body --retry 5 -L -o "${COVERAGE_FILE}" "${COVERAGE_URL}"; then
echo "Successfully downloaded \"${COVERAGE_URL}\""
DOWNLOADED="True"
tar -xvf ${COVERAGE_FILE}
else
echo "Failed to download \"${COVERAGE_URL}\""
rm -f ${COVERAGE_FILE}
exit 5
fi

for REPORT in coverage.packit.xml coverage.testsuite.xml coverage.unittests.xml; do
if [[ -f coverage/${REPORT} ]]; then
mv coverage/${REPORT} .
else
echo "${REPORT} file is missing in downloaded coverage archive"
fi
done
rm ${TMPFILE}

0 comments on commit d7089c9

Please sign in to comment.