scripts/src/repomanci

83 lines
1.7 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
# Original author: XGQT
# Licensed under the ISC License
# Copyright (c) 2020, src_prepare group
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
2020-12-19 13:01:14 +01:00
ignored_dirs=(
.
.git
eclass
files
licenses
metadata
profiles
scripts
3rd_party
)
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-12-19 13:01:14 +01:00
for i_dir in "${ignored_dirs[@]}"
2020-09-07 16:33:15 +02:00
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"
2020-12-19 13:01:14 +01:00
repoman -Idix || test_success="false"
2020-07-24 04:47:52 +02:00
cd - >/dev/null || return
fi
done
2020-12-19 13:01:14 +01:00
if [ "${test_success}" = "false" ]
2020-07-24 04:47:52 +02:00
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