scripts/src/repomanci

98 lines
2.4 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
# This file is part of scripts.
# scripts is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# scripts is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with scripts. If not, see <https://www.gnu.org/licenses/>.
# Original author: Maciej Barć (xgqt@protonmail.com)
# Copyright (c) 2020, src_prepare group
# Licensed under the GNU GPL v3 License
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