#!/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, 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 . # Original author: Maciej Barć (xgqt@protonmail.com) # 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 eclass files licenses metadata profiles scripts 3rd_party ) # 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" # 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 echo echo "Ignoring ${commit_dir}" continue 2 fi done if cd "${commit_dir}" then echo echo "Checking ${commit_dir}" echo "Running repoman -Idix" repoman -Idix || test_success="false" cd - >/dev/null || return fi done if [ "${test_success}" = "false" ] then echo ">>> Exiting with failure due to previous errors" exit 1 else echo ">>> Exiting successfully" exit 0 fi