From d433884a1dcef19e795b36aafba7c65e7d3bf94c Mon Sep 17 00:00:00 2001 From: Kyle Morgan Date: Wed, 3 Apr 2019 13:09:44 -0400 Subject: [PATCH] Add git submodule regression check * Add submodule_check.sh, which checks to see if the HEAD of any submodules on a pull-requested branch are older than they were previously. * Add the corresponding buildkite pipeline to run submodule_check.sh. --- .buildkite/pipeline.yml | 8 ++++++++ scripts/submodule_check.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 scripts/submodule_check.sh diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index f83249df044..c1500cd77ee 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -614,3 +614,11 @@ steps: - "build/packages/eosio_highsierra.rb" - "build/packages/eosio.rb" timeout: 60 + + - command: | + echo "+++ :microscope: Running git submodule regression check" && \ + ./scripts/submodule_check.sh + label: "Git submodule regression check" + agents: + queue: "automation-large-builder-fleet" + timeout: 240 diff --git a/scripts/submodule_check.sh b/scripts/submodule_check.sh new file mode 100755 index 00000000000..16aace418bf --- /dev/null +++ b/scripts/submodule_check.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +REPO_DIR=`mktemp -d` +git clone "$BUILDKITE_REPO" "$REPO_DIR" +git submodule update --init --recursive +cd "$REPO_DIR" + +declare -A PR_MAP +declare -A BASE_MAP + +echo "getting submodule info for $BUILDKITE_BRANCH" +git checkout "$BUILDKITE_BRANCH" &> /dev/null +git submodule update --init &> /dev/null +while read -r a b; do + PR_MAP[$a]=$b +done < <(git submodule --quiet foreach --recursive 'echo $path `git log -1 --format=%ct`') + +echo "getting submodule info for $BUILDKITE_PULL_REQUEST_BASE_BRANCH" +git checkout "$BUILDKITE_PULL_REQUEST_BASE_BRANCH" &> /dev/null +git submodule update --init &> /dev/null +while read -r a b; do + BASE_MAP[$a]=$b +done < <(git submodule --quiet foreach --recursive 'echo $path `git log -1 --format=%ct`') + +for k in "${!BASE_MAP[@]}"; do + base_ts=${BASE_MAP[$k]} + pr_ts=${PR_MAP[$k]} + echo "submodule $k" + echo " timestamp on $BUILDKITE_BRANCH: $pr_ts" + echo " timestamp on $BUILDKITE_PULL_REQUEST_BASE_BRANCH: $base_ts" + if (( $pr_ts < $base_ts)); then + echo "ERROR: $k is older on $BUILDKITE_BRANCH than $BUILDKITE_PULL_REQUEST_BASE_BRANCH" + exit 1 + fi +done