common: Rework package-publish-safety-catches.sh to use the CI checks

**Summary**

Run the CI checks in the safety catches instead of using a separate implementation.
This commit is contained in:
Silke Hofstra 2024-03-31 18:25:15 +02:00
parent 7a0ff7d715
commit afce3a9b52
2 changed files with 13 additions and 45 deletions

View file

@ -40,7 +40,6 @@ jobs:
check_together: 'yes'
ignore_paths: >-
common/Legacy/**
common/Scripts/package-publish-safety-catches.sh
common/Scripts/helpers.zsh
common/Scripts/sync_licenses.sh
common/Scripts/new-package.sh

View file

@ -1,51 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail
# Safety catches when publishing packages. Not foolproof and there are edge cases where we don't want it which allows for force-pushing.
# Currently:
# - Checks that the release has been bumped.
# - Warns if there are additions to abi_used_libs for system.{base,devel} packages.
check_script="$(dirname "$0")/../CI/package_checks.py"
check_args=(--base=origin/main --fail-on-warnings --results-only)
# FIXME: Check for rundeps changes as well for system.{base,devel} packages.
# FIXME: For the initial inclusion check that the release == 1
LAST_COMMIT=$(git rev-list -1 HEAD .)
LAST_COMMIT_DIFF=$(git log -u -1 ${LAST_COMMIT})
PKG_BUMP=$(git log -u -1 ${LAST_COMMIT} package.yml | grep -w +release)
# Check the release has been bumped
if [[ $PKG_BUMP == "" ]]; then
echo "Warning: Cannot determine that the release has been bumped"
read -p "Press y to force-through. If unsure press any other key to abort." prompt
if [[ $prompt = "y" ]]; then
if python3 "${check_script}" "${check_args[@]}"
then
exit 0
else
exit 1
fi
fi
# Checks for additions to abi_used_libs for system.{base,devel} packages.
echo "Package checks failed. Press 'y' to continue, or any other key to abort."
read -rp "Continue anyway? [yN] " prompt
if [[ `git grep -E 'system.base|system.devel' pspec_x86_64.xml` ]]; then
SYSTEM_BASE_DEVEL_PKG=1
fi
if [[ `grep -E abi_used_libs <<< $LAST_COMMIT_DIFF` ]]; then
# Only if the change is an addition
ABI_ADDITION=`git log -u -1 ${LAST_COMMIT} -U0 --word-diff abi_used_libs | grep {+`
if [[ $ABI_ADDITION != "" ]]; then
CHANGED_ABI_USED_LIBS=1
fi
fi
if [[ ! -z "${SYSTEM_BASE_DEVEL_PKG}" && ! -z "${CHANGED_ABI_USED_LIBS}" ]]; then
echo "Found a system.base/system.devel pkg where" $ABI_ADDITION "has been added to abi_used_libs."
echo "Please ensure that the package containing" $ABI_ADDITION "is in system.base/system.devel BEFORE continuing."
read -p "Press y to continue. If unsure press any other key to abort." prompt
if [[ $prompt = "y" ]]; then
if [[ $prompt = "y" ]]
then
exit 0
else
else
exit 1
fi
fi