From 28d6f00a40a98b571b40455f1e29578f4b9c3dcc Mon Sep 17 00:00:00 2001 From: Aric Gardner Date: Thu, 23 Jan 2020 15:23:33 -0500 Subject: [PATCH] Branch discovery and build polling If a Branch has not been seen by rtd we trigger a build and poll till that build is complete. we can then enable the branch and trigger a build on it, again polling all builds untill they are complete ISSUE-ID: RELENG-2682 Signed-off-by: Aric Gardner Change-Id: Id59d4200dd5a883fc1fdc2f898c589bd58658312 --- .../notes/lf-rtdv3-jobs-5fda8e30d8f3e5ed.yaml | 10 +++++ shell/rtdv3.sh | 48 +++++++++++++++++++--- 2 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/lf-rtdv3-jobs-5fda8e30d8f3e5ed.yaml diff --git a/releasenotes/notes/lf-rtdv3-jobs-5fda8e30d8f3e5ed.yaml b/releasenotes/notes/lf-rtdv3-jobs-5fda8e30d8f3e5ed.yaml new file mode 100644 index 00000000..c52053d0 --- /dev/null +++ b/releasenotes/notes/lf-rtdv3-jobs-5fda8e30d8f3e5ed.yaml @@ -0,0 +1,10 @@ +--- +fixes: + - | + Branch discovery and build polling implemented. + If a Branch has not been seen by rtd + we trigger a build with rtd and poll till that build + is complete. + we can then enable the branch and trigger a build + against it, again polling all builds untill they are + complete. diff --git a/shell/rtdv3.sh b/shell/rtdv3.sh index 29808afa..7b4fef8b 100644 --- a/shell/rtdv3.sh +++ b/shell/rtdv3.sh @@ -11,6 +11,25 @@ echo "---> rtdv3.sh" set -euo pipefail +watchbuild(){ + echo "INFO: Running build against branch $1" + local buildid + local result + buildid=$(lftools rtd project-build-trigger "$rtdproject" "$1" | jq '.build.id') + + result=null + while [ $result == null ]; do + sleep 10 + result=$(lftools rtd project-build-details "$rtdproject" "$buildid" | jq '.success') + echo "INFO Current result of running build $result" + if [[ $result == failed ]]; then + echo "INFO: read the docs build completed with status: $result" + exit 1 + fi + done + echo "INFO: read the docs build completed with status: $result" +} + project_dashed="${PROJECT////-}" umbrella=$(echo "$GERRIT_URL" | awk -F'.' '{print $2}') if [[ "$SILO" == "sandbox" ]]; then @@ -102,12 +121,31 @@ echo "INFO: Performing merge action" lftools rtd project-update "$rtdproject" default_version="$default_version" fi - lftools rtd project-build-trigger "$rtdproject" "$GERRIT_BRANCH" if [[ $GERRIT_BRANCH == "master" ]]; then - echo "INFO: triggering latest" - lftools rtd project-build-trigger "$rtdproject" latest + echo "INFO: triggering $rtdproject latest" + watchbuild latest else - echo "INFO: triggering stable" - lftools rtd project-build-trigger "$rtdproject" stable + + #read the docs only understands lower case branch names + branch=$(echo "$GERRIT_BRANCH" | tr '[:upper:]' '[:lower:]') + echo "INFO: Checking if read the docs has seen branch $branch" + + #if this is 404. then run discover branch + if ! lftools rtd project-version-details "$rtdproject" "$branch" | jq '.active'; then + echo "INFO: read the docs has not seen branch $branch for project $rtdproject" + echo "INFO: triggering $rtdproject latest to instantiate new branch discovery" + watchbuild latest + fi + + echo "INFO: triggering $rtdproject $branch" + watchbuild "$branch" + + #Make newly discovered branches visible in the u/i + isactive=$(lftools rtd project-version-details "$rtdproject" "$branch" | jq '.active') + if [[ "$isactive" == false ]]; then + echo "INFO: Marking $branch as active for project $rtdproject" + lftools rtd project-version-update "$rtdproject" "$branch" true + fi + fi fi -- 2.16.6