[vlc-devel] [PATCH 1/2] CI: Add script to get contribs SHA for CI

Hugo Beauzée-Luyssen hugo at beauzee.fr
Tue Oct 22 14:57:00 CEST 2019


Hi,

On Tue, Oct 22, 2019, at 2:39 PM, Marvin Scholz wrote:
> ---
>  extras/ci/get-contrib-sha.sh | 41 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
>  create mode 100755 extras/ci/get-contrib-sha.sh
> 
> diff --git a/extras/ci/get-contrib-sha.sh b/extras/ci/get-contrib-sha.sh
> new file mode 100755
> index 0000000000..9191c59b96
> --- /dev/null
> +++ b/extras/ci/get-contrib-sha.sh
> @@ -0,0 +1,41 @@
> +#!/usr/bin/env bash
> +# Copyright (C) Marvin Scholz
> +#
> +# Get latest SHA that changed contribs (needed for CI)
> +
> +# Array of paths that trigger contrib rebuilds in Gitlab CI
> +VLC_CONTRIB_REBUILD_PATHS=("extras/tools" "contrib")
> +# Revision from which to start look for changes (backwards in time)
> +VLC_START_REVISION="HEAD"
> +# VLC source root directory
> +VLC_SRC_ROOT_DIR=$(git rev-parse --show-toplevel)
> +
> +# Print error message and terminate script with status 1
> +# Arguments:
> +#   Message to print
> +abort_err()
> +{

Any specific reason you're not using set -e instead? Looks like all errors are critical

> +    echo "ERROR: $1" >&2
> +    exit 1
> +}
> +
> +# Check if tool exists
> +# Arguments:
> +#   Tool name to check for
> +has_tool()
> +{
> +    command -v "$1" >/dev/null 2>&1 || return 1
> +}
> +
> +has_tool "git" || abort_err "Git was not found!"

Is this needed? You already used git to set VLC_SRC_ROOT_DIR variable above

> +[ -n "${VLC_SRC_ROOT_DIR}" ] || abort_err "This script must be run in 
> the VLC Git repo and git must be available"
> +[ -f "${VLC_SRC_ROOT_DIR}/src/libvlc.h" ] || abort_err "This script 
> must be run in the VLC Git repository"
> +
> +VLC_LAST_CONTRIB_SHA=$(
> +    cd "$VLC_SRC_ROOT_DIR" &&
> +    git rev-list -1 "${VLC_START_REVISION}" -- 
> "${VLC_CONTRIB_REBUILD_PATHS[@]}"
> +)
> +
> +[ -n "${VLC_LAST_CONTRIB_SHA}" ] || abort_err "Failed to determine 
> last contrib SHA using Git!"
> +
> +echo "${VLC_LAST_CONTRIB_SHA}"
> -- 
> 2.20.1 (Apple Git-117)
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel

-- 
  Hugo Beauzée-Luyssen
  hugo at beauzee.fr


More information about the vlc-devel mailing list