add a ci check for repoman only

This commit is contained in:
Maciej Barć 2020-07-24 04:47:52 +02:00
parent bf122d472a
commit bde4236df9
No known key found for this signature in database
GPG Key ID: 031C9FE65BED714A

60
src/repomanci Executable file
View File

@ -0,0 +1,60 @@
#!/usr/bin/env bash
# CI Ebuild commit tester
# Run this in a overlay directory.
# This script uses repoman
# to check the latest commit for QA issues.
# 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"
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}")"
# skip these directories
[[ "${commit_dir}" = *eclass ]] && continue
[[ "${commit_dir}" = *files ]] && continue
[[ "${commit_dir}" = *licenses* ]] && continue
[[ "${commit_dir}" = *metadata* ]] && continue
[[ "${commit_dir}" = *profiles ]] && continue
if cd "${commit_dir}"
then
echo
echo "Directory $(pwd):"
echo "Running repoman -Idix"
repoman -Idix || test_success=false
cd - >/dev/null || return
fi
done
# If any of the QA tools fail the test will fail
if [ ${test_success} = false ]
then
echo ">>> Exiting with failure due to previous errors..."
exit 1
else
exit 0
fi