You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

99 lines
2.4 KiB

#!/usr/bin/env bash
# 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, version 3.
# 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@riseup.net>
# Copyright (c) 2020, src_prepare group
# Licensed under the GNU GPL v3 License
# CI Ebuild commit tester
# Run this in a overlay directory.
# This script uses repoman
# to check the latest commit for QA issues.
# skip these directories
ignored_dirs=(
.
.git
3rd_party
doc
eclass
files
licenses
metadata
profiles
public
scribblings
scripts
)
# 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
printf "%s\n" \
">>> Starting full test" \
"Running repoman -Idix"
repoman --verbose -Idix
printf "%s\n" ">>> Starting latest commit test"
# If any of the QA checks fail the test will fail
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}")"
for i_dir in "${ignored_dirs[@]}"
do
if [[ "${commit_dir}" = *"${i_dir}"* ]]
then
printf "\n%s\n" "Ignoring ${commit_dir}"
continue 2
fi
done
if cd "${commit_dir}"
then
printf "\n%s\n" \
"Checking ${commit_dir}" \
"Running repoman -Idix"
repoman --verbose -Idix || test_success="false"
cd - >/dev/null || return
fi
done
if [ "${test_success}" = "false" ]
then
printf "%s\n" ">>> Exiting with failure due to previous errors" >> /dev/stderr
exit 1
else
printf "%s\n" ">>> Exiting successfully"
exit 0
fi