scripts/src/repomanci

78 lines
1.6 KiB
Plaintext
Raw Normal View History

2020-09-07 16:37:17 +02:00
#!/usr/bin/env bash
2020-07-24 04:47:52 +02:00
# CI Ebuild commit tester
# Run this in a overlay directory.
# This script uses repoman
# to check the latest commit for QA issues.
2020-09-07 16:33:15 +02:00
# skip these directories
ignored_dirs="
.
.git
eclass
files
licenses
metadata
profiles
2020-10-21 04:48:54 +02:00
scripts
2020-09-07 16:33:15 +02:00
"
2020-07-24 04:47:52 +02:00
# Variables needed for tools
[ -z "${ARCH}" ] && export ARCH=x86_64
[ -z "${ACCEPT_KEYWORDS}" ] && export ACCEPT_KEYWORDS='**'
# First test for a whole repo
# This will likely exit firh error, because repoman
# has to download some files (metadata.xsd)
# We do that so we can truthfully test the actual latest commit
echo ">>> Starting full test"
echo "Running repoman -Idix"
repoman -Idix
echo ">>> Starting latest commit test"
2020-09-07 16:33:15 +02:00
# If any of the QA checks fail the test will fail
2020-07-24 04:47:52 +02:00
test_success=true
# Iterate through changed files in last commit
# For each of these use dirname to change directory
# to the one where the changed file resides
# and run repoman in there
for file in $(git diff --name-only HEAD HEAD~1)
do
commit_dir="$(dirname "${file}")"
2020-09-07 16:33:15 +02:00
for i_dir in ${ignored_dirs}
do
if [[ "${commit_dir}" = *"${i_dir}"* ]]
then
echo
echo "Ignoring ${commit_dir}"
continue 2
fi
done
2020-07-24 04:47:52 +02:00
if cd "${commit_dir}"
then
echo
2020-09-07 16:33:15 +02:00
echo "Checking ${commit_dir}"
2020-07-24 04:47:52 +02:00
echo "Running repoman -Idix"
repoman -Idix || test_success=false
cd - >/dev/null || return
fi
done
if [ ${test_success} = false ]
then
2020-09-07 16:33:15 +02:00
echo ">>> Exiting with failure due to previous errors"
2020-07-24 04:47:52 +02:00
exit 1
else
2020-09-07 16:33:15 +02:00
echo ">>> Exiting successfully"
2020-07-24 04:47:52 +02:00
exit 0
fi