2020-04-12 01:28:10 +02:00
|
|
|
#!/usr/bin/env bash
|
2020-03-20 18:26:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
# CI Ebuild commit tester
|
|
|
|
# Run this in a overlay directory.
|
|
|
|
# This script uses pkgcheck and repoman
|
|
|
|
# to check the latest commit for QA issues.
|
|
|
|
|
|
|
|
|
|
|
|
# Check if we are in a git repo
|
|
|
|
if ! git status >/dev/null; then
|
|
|
|
echo Stop
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-03-20 19:07:38 +01:00
|
|
|
|
|
|
|
# Variables needed for tools
|
|
|
|
[ -z "${ARCH}" ] && export ARCH=x86_64
|
|
|
|
[ -z "${ACCEPT_KEYWORDS}" ] && export ACCEPT_KEYWORDS='**'
|
|
|
|
|
|
|
|
|
2020-04-12 14:14:13 +02:00
|
|
|
# First test for a whole repo
|
|
|
|
# This will likely exit firh error, because repoman
|
2020-04-12 14:26:58 +02:00
|
|
|
# has to download some files (metadata.xsd)
|
2020-04-12 14:14:13 +02:00
|
|
|
# We do that so we can truthfully test the actual latest commit
|
2020-04-12 14:26:58 +02:00
|
|
|
echo ">>> Starting full test"
|
2020-04-12 14:14:13 +02:00
|
|
|
repoman -Idix
|
2020-04-12 14:26:58 +02:00
|
|
|
pkgcheck scan
|
2020-04-12 14:14:13 +02:00
|
|
|
|
|
|
|
|
2020-04-12 14:26:58 +02:00
|
|
|
echo ">>> Starting latest commit test"
|
2020-04-12 01:28:10 +02:00
|
|
|
|
2020-04-12 14:26:58 +02:00
|
|
|
test_success=true
|
2020-04-12 01:28:10 +02:00
|
|
|
|
2020-03-20 18:26:37 +01:00
|
|
|
# Use pkgchek
|
2020-04-12 01:28:10 +02:00
|
|
|
pkgcheck scan --commits || test_success=false
|
|
|
|
|
2020-03-20 18:26:37 +01:00
|
|
|
# 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
|
2020-04-12 01:28:10 +02:00
|
|
|
commit_dir="$(dirname "${file}")"
|
|
|
|
[[ "${commit_dir}" = *eclass ]] && continue
|
2020-04-12 20:55:01 +02:00
|
|
|
[[ "${commit_dir}" = *files ]] && continue
|
|
|
|
[[ "${commit_dir}" = *licenses* ]] && continue
|
|
|
|
[[ "${commit_dir}" = *metadata* ]] && continue
|
|
|
|
[[ "${commit_dir}" = *profiles ]] && continue
|
2020-04-12 01:28:10 +02:00
|
|
|
if cd "${commit_dir}"; then
|
2020-03-20 18:26:37 +01:00
|
|
|
echo
|
|
|
|
echo "Directory $(pwd):"
|
2020-04-12 01:28:10 +02:00
|
|
|
repoman -Idix || test_success=false
|
2020-03-24 01:52:01 +01:00
|
|
|
cd - >/dev/null || return
|
2020-03-20 18:26:37 +01:00
|
|
|
fi
|
|
|
|
done
|
2020-04-12 01:28:10 +02:00
|
|
|
|
|
|
|
# If any of the QA tools fail the test will fail
|
2020-04-12 14:26:58 +02:00
|
|
|
if [ ${test_success} = false ]
|
|
|
|
then
|
|
|
|
echo ">>> Exiting with failure due to previous errors..."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
exit 0
|
|
|
|
fi
|