Improve RTD projects branches activation 96/99996/2
authorguillaume.lambert <guillaume.lambert@orange.com>
Thu, 3 Mar 2022 20:02:43 +0000 (21:02 +0100)
committerguillaume.lambert <guillaume.lambert@orange.com>
Mon, 7 Mar 2022 15:50:42 +0000 (16:50 +0100)
Some projects branches need to be manually activated by docs maintainers
with a script and a RTD personnal token.
This is especially true for MRI projects
Though, the current script only allows MSI projects activation.

- remove MRI projects from the old script mostly targeting MSI projects
- create a MRI projects versions list in TSV format
- copy/paste old script and adapt it quickly and dirtily
  to activate and build MRI projects branches

Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: Ia9fa2c61c012970398d204196d5be78925374c34

.pre-commit-config.yaml
MRI_projects_to_activate.list [new file with mode: 0644]
activate-mri-projects-rtd-branch.sh [new file with mode: 0755]
activate-projects-rtd-branch.sh

index 88987acea59c03d225d38e546acebb712fb8b767..3ec6a15cf08c217801f53173f1389172c3a94a22 100644 (file)
@@ -20,5 +20,6 @@ repos:
             (?x)^(
                 .git/COMMIT_EDITMSG|
                 docs/make.bat|
-                docs/Makefile
+                docs/Makefile|
+                MRI_projects_to_activate.list
             )$
diff --git a/MRI_projects_to_activate.list b/MRI_projects_to_activate.list
new file mode 100644 (file)
index 0000000..3adfd9a
--- /dev/null
@@ -0,0 +1,7 @@
+aaa    latest
+bgpcep latest
+controller     latest
+infrautils     latest
+mdsal  latest
+netconf        latest
+
diff --git a/activate-mri-projects-rtd-branch.sh b/activate-mri-projects-rtd-branch.sh
new file mode 100755 (executable)
index 0000000..17b49a3
--- /dev/null
@@ -0,0 +1,98 @@
+#!/bin/bash
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2019 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+
+#activate project docs versions for all supported
+#ODL autorelease projects. This script maintains a list in the project
+#and needs to be run manually by a docs maintainer.
+
+
+usage() {
+    echo "Usage: $0 <token>"
+    echo ""
+    echo "    token:  RTD API Token"
+    echo ""
+}
+
+# Activate project docs version in RTD
+activate_version() {
+    token=$1
+    project_name=$2
+    version_name=$3
+
+    echo "Activating $project_name $version_name"
+    curl -X PATCH "https://readthedocs.org/api/v3/projects/$project_name/versions/$version_name/" \
+        -H "Authorization: Token $token"  \
+        -H "Content-Type: application/json" \
+        --data "{\"active\": true, \"hidden\": false}"
+}
+
+# Build "latest" to force RTD to update available versions
+update_available_versions() {
+    token=$1
+    project_name=$2
+
+    echo "Forcing RTD to update available versions"
+    curl -X POST "https://readthedocs.org/api/v3/projects/$project_name/versions/latest/builds/" \
+        -H "Authorization: Token $token" \
+        -H "Content-Length: 0"
+}
+
+# Build  to force RTD to update available versions
+build_version() {
+    token=$1
+    project_name=$2
+    version_name=$3
+
+    echo "Forcing RTD to update available versions"
+    curl -X POST "https://readthedocs.org/api/v3/projects/$project_name/versions/$version_name/builds/" \
+        -H "Authorization: Token $token" \
+        -H "Content-Length: 0"
+}
+
+while getopts :h: opts; do
+    case "$opts" in
+        h)
+            usage
+            exit 0
+            ;;
+        [?])
+            usage
+            exit 1
+            ;;
+    esac
+done
+
+if [ -z $1 ]; then
+    usage
+    exit 1
+fi
+
+################
+# Start script #
+################
+
+token="$1"
+
+for project in $(cut -f1 < MRI_projects_to_activate.list); do
+    update_available_versions "$token" "odl-$project"
+done
+
+echo ""
+echo ""
+echo "Waiting 60 seconds for available versions to update"
+sleep 60  # Wait a minute for RTD to update available versions
+
+for project in $(cut -f1 < MRI_projects_to_activate.list); do
+    version_name=$(grep $project MRI_projects_to_activate.list | cut -f2)
+    activate_version "$token" "odl-$project" "$version_name"
+    build_version "$token" "odl-$project" "$version_name"
+done
index e8f1d9651dd04cd9e310d0650ce6fe767ee9fb7a..2e23aed4957bfb81b1d8e13a30faa7670b587991 100755 (executable)
@@ -9,6 +9,12 @@
 # http://www.eclipse.org/legal/epl-v10.html
 ##############################################################################
 
+
+#activate project docs versions for all supported
+#ODL autorelease projects. This script maintains a list in the project
+#and needs to be run manually by a docs maintainer.
+
+
 usage() {
     echo "Usage: $0 <token> <version_name>"
     echo ""
@@ -67,18 +73,14 @@ token="$1"
 version_name="$2"
 
 supported_projects=(
-    odl-aaa
-    odl-bgpcep
     odl-daexim
-    odl-genius
     opendaylight-distribution
     odl-jsonrpc
     odl-lispflowmapping
-    odl-netconf
     odl-openflowplugin
     opendaylight-ovsdb
-    opendaylight-serviceutils
-)
+    odl-transportpce
+    )
 
 for project in ${supported_projects[@]}; do
     update_available_versions "$token" "$project" "$version_name"