view contrib/docker/pytype/recipe.sh @ 52293:77b38c86915d

ci: add a small script one can run to purge older pipeline We have over ten thousands old pipeline that take a huge space and that I suspect to be the source of some slowdown in merge request. However it seems that the only way to clear them is manually and through the API, so lets do it. The script was run today.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 12 Nov 2024 12:45:23 +0100
parents 87bfd1703597
children
line wrap: on
line source

#!/usr/bin/env bash

# find repo-root without calling hg as this might be run with sudo
THIS="$(readlink -m "$0")"
HERE="$(dirname "$THIS")"
HG_ROOT="$(readlink -m "$HERE"/../../..)"
echo source mercurial repository: "$HG_ROOT"

# find actual user as this might be run with sudo
if [ -n "$SUDO_UID" ]; then
    ACTUAL_UID="$SUDO_UID"
else
    ACTUAL_UID="$(id -u)"
fi
if [ -n "$SUDO_GID" ]; then
    ACTUAL_GID="$SUDO_GID"
else
    ACTUAL_GID="$(id -g)"
fi
echo using user "$ACTUAL_UID:$ACTUAL_GID"
if groups | egrep -q '\<(docker|root)\>' ; then
    env DOCKER_BUILDKIT=1 docker build --tag mercurial-pytype-checker "$HERE"
    docker run --rm -it --user "$ACTUAL_UID:$ACTUAL_GID" -v "$HG_ROOT:/tmp/mercurial-ci" mercurial-pytype-checker
else
    echo "user not in the docker group" >&2
    echo "(consider running this with \`sudo\`)" >&2
    exit 255
fi