Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | #set -x # uncomment for bash script debugging |
| 3 | |
| 4 | ### ============================================================================ |
| 5 | ### Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ### you may not use this file except in compliance with the License. |
| 7 | ### You may obtain a copy of the License at |
| 8 | ### |
| 9 | ### http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ### |
| 11 | ### Unless required by applicable law or agreed to in writing, software |
| 12 | ### distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ### WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ### See the License for the specific language governing permissions and |
| 15 | ### limitations under the License. |
| 16 | ### ============LICENSE_END===================================================== |
| 17 | |
| 18 | ### |
| 19 | ### checkdocs.sh |
| 20 | ### |
| 21 | ### AUTHOR(S): |
Thomas Kulik | 56180a5 | 2021-03-31 14:53:19 +0200 | [diff] [blame] | 22 | ### Thomas Kulik, Deutsche Telekom AG, 2020 - 2021 |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 23 | ### |
| 24 | ### DESCRIPTION: |
| 25 | ### Retrieves a full list of ONAP repos from gerrit inluding their state. |
| 26 | ### Clones all active repos of the ONAP master branch plus other requested ONAP |
| 27 | ### branches. Then the script does some docs related analyses depending on the |
| 28 | ### clone results. It creates logfiles containing filtered results. In addition |
| 29 | ### a table.csv is created which can be used to import it in a spreadsheed. |
| 30 | ### Also a zip-file is created which contains all the results. |
| 31 | ### |
| 32 | ### IMPORTANT: |
| 33 | ### - in the output, repo names are shown in square brackets for readability |
| 34 | ### e.g [aai/aai-common]/docs/release-notes.rst |
| 35 | ### - in the table.csv file you see data for the requested branch if available. |
| 36 | ### if not available, data is retrieved from the master branch. it will be |
| 37 | ### denoted in round brackets, e.g. (3) (tox.ini) |
| 38 | ### |
| 39 | ### REQUIREMENTS: |
| 40 | ### curl |
| 41 | ### jq |
| 42 | ### |
| 43 | |
| 44 | ### |
| 45 | ### SOME HELPING COMMANDS TO PROCESS LOG FILES: |
| 46 | ### create repo list |
| 47 | ### curl -s https://git.onap.org/ | grep "^<tr><td class='toplevel-repo'><a title='" | sed -r "s:^<tr><td class='toplevel-repo'><a title='::" | sed -r "s:'.*::" |
| 48 | ### |
Thomas Kulik | 56180a5 | 2021-03-31 14:53:19 +0200 | [diff] [blame] | 49 | ### remove branchname from the line: |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 50 | ### cat frankfurt_repoclone.log | sed 's:frankfurt|::' |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 51 | ### |
| 52 | ### list only image names |
| 53 | ### cat master_dockerimagesfull.log | grep image | sed -r 's:image\:::' | sed -r 's:^ +::' | sed '/^[[:space:]]*$/d' |
| 54 | ### |
| 55 | ### more interesting stuff ... |
| 56 | ### curl https://gerrit.onap.org/r/projects/?d |
| 57 | ### LONG: curl -s 'https://gerrit.onap.org/r/projects/?d' | awk '{if(NR>1)print}' | jq -c '.[] | {id, state}' | sed -r 's:%2F:/:g' | sed -r 's:["{}]::g' | sed -r 's:id\:::' | sed -r 's:,state\::|:' | sed '/All-Projects/d' | sed '/All-Users/d' |
| 58 | ### SHORT: curl -s 'https://gerrit.onap.org/r/projects/?d' | awk '{if(NR>1)print}' | jq -c '.[] | {id, state}' | sed -r 's:%2F:/:g; s:["{}]::g; s:id\:::; s:,state\::|:; /All-Projects/d; /All-Users/d' |
| 59 | ### |
| 60 | |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 61 | script_version="1.10 (2021-06-10)" |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 62 | |
| 63 | # save command for the restart with logging enabled |
| 64 | command=$0 |
| 65 | arguments=$@ |
| 66 | fullcommand="${command} ${arguments}" |
| 67 | |
| 68 | ### |
| 69 | ### functions |
| 70 | ### |
| 71 | |
| 72 | # print usage |
| 73 | function usage() { |
| 74 | echo " " |
Thomas Kulik | ed7d4f6 | 2020-11-18 15:07:29 +0100 | [diff] [blame] | 75 | echo " checkdocs.sh Version ${script_version}" |
| 76 | echo " " |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 77 | echo " USAGE: " |
Thomas Kulik | ed7d4f6 | 2020-11-18 15:07:29 +0100 | [diff] [blame] | 78 | echo " ./checkdocs.sh <arguments> " |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 79 | echo " " |
| 80 | echo " ARGUMENTS: " |
| 81 | echo " -u|--user username " |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 82 | echo " linux foundation username used to clone ONAP repositories" |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 83 | echo " " |
| 84 | echo " -b|--branches branch1,branch2,branch3 " |
| 85 | echo " list of branches to be cloned. master is automatically " |
| 86 | echo " added to the list. do not add manually! " |
| 87 | echo " " |
| 88 | echo " -d|--dev " |
| 89 | echo " development-mode - limits number of repos to be cloned " |
| 90 | echo " " |
| 91 | } |
| 92 | |
| 93 | # draw a simple line |
| 94 | function drawline { |
| 95 | echo "*******************************************************************************" |
| 96 | } |
| 97 | |
| 98 | # remove lockfile in case script is interrupted |
| 99 | trap InterruptedScript SIGINT SIGTERM SIGHUP SIGKILL SIGSTOP |
| 100 | function InterruptedScript { |
| 101 | echo " " |
| 102 | echo "Script was interrupted." |
| 103 | if [ -f $lockfile ] ; then |
| 104 | rm $lockfile |
| 105 | fi |
| 106 | exit 0 |
| 107 | } |
| 108 | |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 109 | # function to parse wiki (project) lifecycle state information |
| 110 | # call: getwikilifecyclestate "projectname" |
| 111 | # result: $return_from_getwikilifecyclestate |
| 112 | # because bash supports only returning numeric values a variable $return_from_getwikilifecyclestate is used |
| 113 | |
| 114 | function getwikilifecyclestate { |
| 115 | |
| 116 | local requested=$1 |
| 117 | local wikiline="" |
| 118 | local wikirepo="" |
| 119 | local wikistate="" |
| 120 | |
| 121 | return_from_getwikilifecyclestate="" |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 122 | |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 123 | for wikiline in "${wikiplsarray[@]}" |
| 124 | do |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 125 | |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 126 | wikirepo=$(echo $wikiline | awk -F ";" '{print $1}'); |
| 127 | wikistate=$(echo $wikiline | awk -F ";" '{print $2}'); |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 128 | |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 129 | #echo "DBUG: getwikilifecyclestate wikiline = \"${wikiline}\""; |
| 130 | #echo "DBUG: getwikilifecyclestate wikirepo = \"${wikirepo}\"" |
| 131 | #echo "DBUG: getwikilifecyclestate wikistate = \"${wikistate}\"" |
| 132 | |
| 133 | if [[ ${wikirepo} == ${requested} ]]; then |
| 134 | return_from_getwikilifecyclestate=${wikistate} |
| 135 | #echo "DBUG: getwikilifecyclestate wikirepo = \"${wikirepo}\"" |
| 136 | #echo "DBUG: getwikilifecyclestate requested = \"${requested}\"" |
| 137 | #echo "DBUG: return_from_getwikilifecyclestate = \"${return_from_getwikilifecyclestate}\""; |
| 138 | return 0; |
| 139 | fi |
| 140 | |
| 141 | done |
| 142 | |
| 143 | #echo "DBUG: getwikilifecyclestate requested \"${requested}\" NOT FOUND in list" |
| 144 | return_from_getwikilifecyclestate="" |
| 145 | |
| 146 | } |
| 147 | |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 148 | # function to parse release partizipation information |
| 149 | # call: getrpinfo "projectname" |
| 150 | # result: $return_from_getrpinfo |
| 151 | # because bash supports only returning numeric values a variable $return_from_getrpinfo is used |
| 152 | |
| 153 | function getrpinfo { |
| 154 | |
| 155 | local requested=$1 |
| 156 | |
| 157 | # clean up first |
| 158 | local rpdetails="" |
| 159 | local rpline="" |
| 160 | local rprepo="" |
| 161 | local rpproject="" |
| 162 | local current_branch_starting_letter="" |
| 163 | return_from_getrpinfo="" |
| 164 | |
| 165 | # finds first matching line in the array using grep (currently every line shows the same partizipation for the project (NOT repository!) ) |
| 166 | # this is much faster then looping line by line |
| 167 | rpline=$(IFS=$'\n'; echo "${rparray[*]}" | grep -m 1 ";${requested};"); |
| 168 | rpline=$(echo ${rpline} | tr -d '^M') |
| 169 | rprepo=$(echo ${rpline} | awk -F ";" '{print $1}'); |
| 170 | rpproject=$(echo ${rpline} | awk -F ";" '{print $2}'); |
| 171 | # concatenate details to do an easy grep later on to find out if or if not the project/repo has partizipated to a release |
| 172 | rpdetails=$(echo ${rpline} | awk -F ";" '{print "-" $3 "-" $4 "-" $5 "-" $6 "-" $7 "-" $8 "-" $9 "-" $10 "-" $11 "-" $12 "-"}'); |
| 173 | |
| 174 | # result will be e.g. "-g" and this avoids false positives with the "m" release |
| 175 | # (because "m" is also used to indicate the maintenance release, e.g. "gm") |
| 176 | current_branch_starting_letter="-${branch:0:1}" |
| 177 | |
| 178 | #echo "DBUG: getrpinfo ****************************"; |
| 179 | #echo "DBUG: getrpinfo requested = \"${requested}\""; |
| 180 | #echo "DBUG: getrpinfo rpproject = \"${rpproject}\""; |
| 181 | #echo "DBUG: getrpinfo rpdetails = \"${rpdetails}\""; |
| 182 | #echo "DBUG: current branch = \"${branch}\""; |
| 183 | #echo "DBUG: starting_letter = \"${current_branch_starting_letter}\""; |
| 184 | |
| 185 | # check |
| 186 | if [[ ${rpproject} = ${requested} ]] && [[ "${rpdetails}" == *"${current_branch_starting_letter}"* ]]; then |
| 187 | return_from_getrpinfo="project partizipated" |
| 188 | #echo "DBUG: getrpinfo return = \"${return_from_getrpinfo}\""; |
| 189 | return 0; |
| 190 | fi |
| 191 | |
| 192 | #echo "DBUG: getrpinfo requested \"${requested}\" NOT FOUND in list" |
| 193 | return_from_getrpinfo="" |
| 194 | |
| 195 | } |
| 196 | |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 197 | ### |
| 198 | ### arguments handling |
| 199 | ### |
| 200 | |
| 201 | PARAMS="" |
| 202 | |
| 203 | while (( "$#" )); do |
| 204 | case "$1" in |
| 205 | -d|--dev) |
| 206 | devmode="TRUE" |
| 207 | shift |
| 208 | ;; |
| 209 | -b|--branches) |
| 210 | if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then |
| 211 | branches_csv=$2 |
| 212 | shift 2 |
| 213 | else |
| 214 | echo "Error: Argument for $1 is missing" >&2 |
| 215 | usage |
| 216 | exit 1 |
| 217 | fi |
| 218 | ;; |
| 219 | -u|--user) |
| 220 | if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then |
| 221 | lfusername=$2 |
| 222 | shift 2 |
| 223 | else |
| 224 | echo "Error: Argument for $1 is missing" >&2 |
| 225 | usage |
| 226 | exit 1 |
| 227 | fi |
| 228 | ;; |
| 229 | -*|--*=) # unsupported flags |
| 230 | echo "Error: Unsupported argument $1" >&2 |
| 231 | usage |
| 232 | exit 1 |
| 233 | ;; |
| 234 | *) # preserve positional arguments |
| 235 | PARAMS="$PARAMS $1" |
| 236 | shift |
| 237 | ;; |
| 238 | esac |
| 239 | done |
| 240 | |
| 241 | # set positional arguments in their proper place |
| 242 | eval set -- "$PARAMS" |
| 243 | |
| 244 | # old: declare -a branches=("master" "frankfurt" "guilin") |
| 245 | if [[ $branches_csv == "" || $lfusername == "" ]]; then |
| 246 | usage |
| 247 | exit -1 |
| 248 | fi |
| 249 | |
| 250 | # master branch is automatically added and must not part of the user arguments |
| 251 | if [[ $branches_csv == *"master"* ]]; then |
| 252 | usage |
| 253 | exit -1 |
| 254 | fi |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 255 | # clone master first, then the other branches |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 256 | branches_csv="master,${branches_csv}" |
| 257 | |
| 258 | # create the branches array by readinging in the values from the variable |
| 259 | IFS=',' read -r -a branches <<< "${branches_csv}" |
| 260 | |
| 261 | #echo "DBUG: devmode = \"${devmode}\"" |
| 262 | #echo "DBUG: branches_csv = \"${branches_csv}\"" |
| 263 | #echo "DBUG: lfusername = \"${lfusername}\"" |
| 264 | #echo "DBUG: branches = \"${branches[@]}\"" |
| 265 | |
| 266 | # restart script with logging enabled |
| 267 | lockfile="checkdocs-runtime-lockfile" |
| 268 | if [ ! -f $lockfile ] ; then |
| 269 | touch $lockfile |
| 270 | echo "Restarting script with logging enabled." |
| 271 | ${fullcommand} 2>&1 | tee checkdocs.log |
| 272 | rm $lockfile |
| 273 | exit |
| 274 | fi |
| 275 | |
| 276 | echo " " |
| 277 | echo "checkdocs.sh Version ${script_version}" |
| 278 | echo " " |
| 279 | |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 280 | # |
| 281 | # read in wiki (project) lifecycle state |
| 282 | # always use the lastest available file (derived from date in filename e.g. wiki_lifecycle_state_210409.txt) |
| 283 | # format is <reponame abbrev>;<state>;<reponame full> |
| 284 | # |
| 285 | |
| 286 | wikiplsfile=$(ls | sed -nr '/wiki_lifecycle_state_[0-9]{6}.txt/Ip' | tail -1); |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 287 | if [[ $wikiplsfile == "" ]]; then |
| 288 | echo "ERROR: wiki_lifecycle_state_yymmdd.txt missing" |
| 289 | exit -1 |
| 290 | fi |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 291 | echo "Using \"${wikiplsfile}\" as the source for wiki (project) lifecycle state information." |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 292 | readarray -t wikiplsarray < ./${wikiplsfile}; |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 293 | |
| 294 | # |
| 295 | # read in release_partizipation_YYMMDD.csv file |
| 296 | # always use the latest available file (derived from date in filename e.g. release_partizipation_210409.csv) |
| 297 | # format is: $1=repository;$2=project;$3=g;$4=gm;$5=h;$6=hm;$7=i;$8=im;$9=j;$10=jm;$11=k;$12=km;;;; |
| 298 | # example: "g" = project partizipated to the (g)uilin release |
| 299 | # "gm" = project partizipated to the (g)uilin (m)aintenance release |
| 300 | # file may contain windows control charaters at end of line (^M) |
| 301 | # |
| 302 | |
| 303 | rpfile=$(ls | sed -nr '/release_partizipation_[0-9]{6}.csv/Ip' | tail -1); |
| 304 | if [[ $rpfile == "" ]]; then |
| 305 | echo "ERROR: release_partizipation_yymmdd.csv missing" |
| 306 | exit -1 |
| 307 | fi |
| 308 | echo "Using \"${rpfile}\" as the source for release partizipation information." |
| 309 | readarray -t rparray < ./${rpfile}; |
| 310 | # remove first line |
| 311 | rparray=("${rparray[@]:1}") |
| 312 | # printf '%s\n' "${rparray[@]}" |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 313 | |
| 314 | # |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 315 | # curl must be installed |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 316 | # |
| 317 | |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 318 | if ! command -v curl &> /dev/null |
| 319 | then |
| 320 | echo "ERROR: curl command could not be found" |
| 321 | exit -1 |
| 322 | fi |
| 323 | |
| 324 | today=$(date '+%Y-%m-%d'); |
| 325 | repolist="gerrit-repos-master-"$today".txt"; |
Thomas Kulik | 33cf98f | 2020-11-17 15:09:48 +0100 | [diff] [blame] | 326 | unique=$(date +%s) |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 327 | |
| 328 | echo "Retrieving a full list of ONAP repositories (master) from gerrit.onap.org." |
| 329 | |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 330 | # |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 331 | # retrieve the full repolist from gerrit |
| 332 | # workaround because of the (wrong?) response of gerrit.onap.org which makes jq command fail |
| 333 | # "| awk '{if(NR>1)print}'" filters the first line of the response so that jq will work again (thx marek) |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 334 | # |
| 335 | |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 336 | curl -s 'https://gerrit.onap.org/r/projects/?d' | awk '{if(NR>1)print}' | jq -c '.[] | {id, state}' | sed -r 's:%2F:/:g; s:["{}]::g; s:id\:::; s:,state\::|:; /All-Projects/d; /All-Users/d' >./$repolist |
| 337 | |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 338 | # process the created repolist and try to clone the projects from the mirror |
| 339 | |
| 340 | source="git://cloud.onap.org/mirror" |
| 341 | echo "Using \"${source}\" as the source and username \"${lfusername}\" for cloning the repositories." |
| 342 | echo "Start cloning of repositories ..." |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 343 | |
| 344 | for branch in "${branches[@]}" |
| 345 | do |
| 346 | |
| 347 | echo " " |
| 348 | echo "###" |
| 349 | echo "### ${branch}" |
| 350 | echo "###" |
| 351 | echo " " |
| 352 | |
| 353 | branch_upper=$(echo "${branch}" | tr '[:lower:]' '[:upper:]') |
| 354 | |
| 355 | mkdir $branch |
| 356 | cp $repolist $branch |
| 357 | cd $branch |
| 358 | |
| 359 | devcounter=0 |
| 360 | |
| 361 | # process repolist |
| 362 | while read line |
| 363 | do |
| 364 | |
| 365 | if [[ $devmode == "TRUE" ]]; then |
| 366 | devcounter=$((devcounter+1)) |
| 367 | fi |
| 368 | |
Thomas Kulik | 3920fd2 | 2021-03-29 12:56:54 +0200 | [diff] [blame] | 369 | if [[ $devcounter -lt "50" ]]; then |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 370 | |
| 371 | if [[ $devmode == "TRUE" ]]; then |
| 372 | echo "INFO: devmode! counter=${devcounter}" |
| 373 | fi |
| 374 | |
| 375 | drawline |
| 376 | reponame=$(echo $line | awk -F "|" '{print $1}'); |
| 377 | repostate=$(echo $line | awk -F "|" '{print $2}'); |
| 378 | echo $reponame |
| 379 | echo $repostate |
| 380 | |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 381 | if [[ $repostate == "ACTIVE" ]] || [[ $repostate == "READ_ONLY" ]]; then |
| 382 | echo "Cloning \"${branch}\" branch of \"${repostate}\" project ${reponame}..." |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 383 | |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 384 | # previously used: git clone --branch ${branch} --recurse-submodules ssh://${lfusername}@gerrit.onap.org:29418/$reponame ./$reponame |
| 385 | # clone script Jess: git clone "git://cloud.onap.org/mirror/${i}" "${LOCALNAME}" |
| 386 | git clone --branch ${branch} --recurse-submodules ${source}/${reponame} ./${reponame} |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 387 | gitexitcode=$? |
| 388 | |
| 389 | if [[ ! ${gitexitcode} == "0" ]]; then |
| 390 | errormsg=$(tail -1 ../checkdocs.log) |
| 391 | else |
| 392 | errormsg="cloned" |
| 393 | fi |
| 394 | |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 395 | # repoclone.log format: $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg |
| 396 | echo "${gitexitcode}|${reponame}|${repostate}|${errormsg}" | tee -a ${branch}_repoclone.log |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 397 | |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 398 | #elif [[ $repostate == "READ_ONLY" ]]; then |
| 399 | #echo "-|${reponame}|${repostate}|ignored" | tee -a ${branch}_repoclone.log |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 400 | else |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 401 | echo "-|${reponame}|unknown repo state \"${repostate}\"|-" | tee -a ${branch}_repoclone.log |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 402 | fi |
| 403 | |
| 404 | # examine repo |
| 405 | if [[ ${gitexitcode} == "0" ]]; then |
| 406 | |
| 407 | printf "\ndocs directories:\n" |
| 408 | find ./$reponame -type d -name docs | sed -r 's:./::' | sed -r s:${reponame}:[${reponame}]: | tee -a ${branch}_docs.log |
| 409 | |
| 410 | printf "\nrst files:\n" |
| 411 | find ./$reponame -type f -name *.rst | sed -r 's:./::' | sed -r s:${reponame}:[${reponame}]: | tee -a ${branch}_rstfiles.log |
| 412 | |
| 413 | printf "\nrelease notes rst:\n" |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 414 | find ./$reponame -type f | grep '.*release.*note.*.rst' | sed -r 's:./::' | sed -r s:${reponame}:[${reponame}]: | tee -a ${branch}_releasenotes.log |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 415 | |
| 416 | printf "\ntox.ini files:\n" |
| 417 | find ./$reponame -type f -name tox.ini | sed -r 's:./::' | sed -r s:${reponame}:[${reponame}]: | tee -a ${branch}_toxini.log |
| 418 | |
| 419 | printf "\nconf.py files:\n" |
| 420 | find ./$reponame -type f -name conf.py | sed -r 's:./::' | sed -r s:${reponame}:[${reponame}]: | tee -a ${branch}_confpy.log |
| 421 | |
thmsdt | 3353c6e | 2021-06-01 04:42:34 -0700 | [diff] [blame] | 422 | printf "\nindex.rst files (all):\n" |
| 423 | find ./$reponame -type f -name index.rst | sed -r 's:./::' | sed -r s:${reponame}:[${reponame}]: | tee -a ${branch}_indexrst_all.log |
| 424 | |
| 425 | printf "\nindex.rst files (docs root directory):\n" |
| 426 | find ./$reponame -type f -name index.rst | sed -r 's:./::' | sed -r s:${reponame}:[${reponame}]: | grep ']/docs/index.rst' | tee -a ${branch}_indexrst_docs_root.log |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 427 | |
Thomas Kulik | 3920fd2 | 2021-03-29 12:56:54 +0200 | [diff] [blame] | 428 | printf "\nINFO.yaml files:\n" |
| 429 | find ./$reponame -type f -name INFO.yaml | sed -r 's:./::' | sed -r s:${reponame}:[${reponame}]: | tee -a ${branch}_infoyaml.log |
| 430 | |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 431 | fi |
| 432 | |
| 433 | # end defcounter loop |
| 434 | fi |
| 435 | |
| 436 | gitexitcode="" |
| 437 | |
| 438 | done <${repolist} |
| 439 | |
thmsdt | 3353c6e | 2021-06-01 04:42:34 -0700 | [diff] [blame] | 440 | # get (first) title for a rst file |
| 441 | drawline |
| 442 | python3 ../getrsttitle.py ${branch}_rstfiles.log | tee ${branch}_rstfiles_titles.log |
| 443 | drawline |
| 444 | python3 ../getrsttitle.py ${branch}_indexrst_docs_root.log | tee ${branch}_indexrst_docs_root_titles.log |
| 445 | |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 446 | # examine repos |
| 447 | drawline |
| 448 | find . -type f -name values.yaml -print -exec grep "image:" {} \; | sed -r 's:^ +::' | tee ${branch}_dockerimagesfull.log |
| 449 | drawline |
| 450 | ls --format single-column -d */ | sed 's:/$::' | tee ${branch}_directories.log |
| 451 | drawline |
| 452 | cat ${branch}_dockerimagesfull.log | grep image | sed -r 's:image\:::' | sed -r 's:^ +::' | sed '/^[[:space:]]*$/d' >${branch}_dockerimages.log |
| 453 | drawline |
| 454 | ls --format single-column -d oom/kubernetes/*/ | tee ${branch}_oomkubernetes.log |
| 455 | drawline |
| 456 | |
| 457 | # examine docs |
| 458 | readarray -t docs_array < ./${branch}_docs.log; |
| 459 | |
| 460 | for line in "${docs_array[@]}" |
| 461 | do |
| 462 | |
| 463 | echo $line | tee -a ${branch}_docsconfig.log |
| 464 | |
| 465 | # remove [ and ] which are distinguish the project name in the output |
| 466 | line=$(echo $line | sed -r 's:\[:: ; s:\]::') |
| 467 | |
| 468 | if [ -f ./${line}/conf.py ] ; then |
| 469 | echo " conf.py ..... found" | tee -a ${branch}_docsconfig.log |
| 470 | else |
| 471 | echo " conf.py ..... NOT FOUND" | tee -a ${branch}_docsconfig.log |
| 472 | fi |
| 473 | |
| 474 | if [ -f ./${line}/index.rst ] ; then |
| 475 | echo " index.rst ... found" | tee -a ${branch}_docsconfig.log |
| 476 | else |
| 477 | echo " index.rst ... NOT FOUND" | tee -a ${branch}_docsconfig.log |
| 478 | fi |
| 479 | |
| 480 | if [ -f ./${line}/tox.ini ] ; then |
| 481 | echo " tox.ini ..... found" | tee -a ${branch}_docsconfig.log |
| 482 | else |
| 483 | echo " tox.ini ..... NOT FOUND" | tee -a ${branch}_docsconfig.log |
| 484 | fi |
| 485 | |
| 486 | echo " " | tee -a ${branch}_docsconfig.log |
| 487 | |
| 488 | done |
| 489 | unset docs_array |
| 490 | |
| 491 | drawline |
| 492 | |
| 493 | ### |
| 494 | ### build a csv table that combines results |
| 495 | ### |
| 496 | |
| 497 | # |
| 498 | # csv column #1: project name |
| 499 | # |
| 500 | |
| 501 | readarray -t array < ./${repolist}; |
| 502 | i=0 |
| 503 | csv[i]="project" |
| 504 | ((i++)) |
| 505 | for line in "${array[@]}" |
| 506 | do |
| 507 | reponame=$(echo $line | awk -F "|" '{print $1}'); |
| 508 | project=$(echo $reponame | sed 's:/.*$::') |
| 509 | #echo "DBUG: reponame=${reponame}" |
| 510 | #echo "DBUG: project=${project}" |
| 511 | #echo "DBUG: i=${i}" |
| 512 | csv[i]=${project} |
| 513 | ((i++)) |
| 514 | done |
| 515 | unset array |
| 516 | unset i |
| 517 | unset reponame |
| 518 | unset project |
| 519 | |
| 520 | # |
| 521 | # csv column #2: repo name |
| 522 | # |
| 523 | |
| 524 | readarray -t array < ./${repolist}; |
| 525 | i=0 |
| 526 | csv[i]="${csv[i]},MASTER repo name" |
| 527 | ((i++)) |
| 528 | for line in "${array[@]}" |
| 529 | do |
| 530 | reponame=$(echo $line | awk -F "|" '{print $1}'); |
| 531 | csv[i]="${csv[i]},${reponame}" |
| 532 | ((i++)) |
| 533 | done |
| 534 | unset array |
| 535 | unset i |
| 536 | unset reponame |
| 537 | |
| 538 | # |
| 539 | # csv column #3: repo state |
| 540 | # |
| 541 | |
| 542 | readarray -t array < ./${repolist}; |
| 543 | i=0 |
| 544 | csv[i]="${csv[i]},MASTER repo state" |
| 545 | ((i++)) |
| 546 | for line in "${array[@]}" |
| 547 | do |
| 548 | repostate=$(echo $line | awk -F "|" '{print $2}'); |
| 549 | csv[i]="${csv[i]},${repostate}" |
| 550 | ((i++)) |
| 551 | done |
| 552 | unset array |
| 553 | unset i |
| 554 | unset repostate |
| 555 | |
| 556 | # |
| 557 | # csv column #4: clone message |
| 558 | # |
| 559 | |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 560 | readarray -t array < ./${branch}_repoclone.log; |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 561 | i=0 |
| 562 | csv[i]="${csv[i]},${branch_upper} clone message" |
| 563 | ((i++)) |
| 564 | for line in "${array[@]}" |
| 565 | do |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 566 | # repoclone.log format: $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 567 | errormsg=$(echo $line | awk -F "|" '{print $4}'); |
| 568 | csv[i]="${csv[i]},${errormsg}" |
| 569 | ((i++)) |
| 570 | done |
| 571 | unset array |
| 572 | unset i |
| 573 | unset errormsg |
| 574 | |
| 575 | # |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 576 | # csv column #5: latest branch |
Thomas Kulik | 3920fd2 | 2021-03-29 12:56:54 +0200 | [diff] [blame] | 577 | # |
| 578 | |
| 579 | readarray -t array < ./${repolist}; |
| 580 | i=0 |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 581 | csv[i]="${csv[i]},latest branch" |
Thomas Kulik | 3920fd2 | 2021-03-29 12:56:54 +0200 | [diff] [blame] | 582 | ((i++)) |
| 583 | for line in "${array[@]}" |
| 584 | do |
| 585 | reponame=$(echo $line | awk -F "|" '{print $1}'); |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 586 | latestbranch=$(git ls-remote -q --heads "${source}/${reponame}" | sed 's/^.*heads\///' | sed -nr '/^master$|^amsterdam$|^beijing$|^casablanca$|^dublin$|^elalto$|^frankfurt$|^guilin$|^honolulu$|^istanbul$/Ip' | tail -2 | head -1); |
| 587 | #echo "DBUG: reponame=${reponame}" |
| 588 | #echo "DBUG: latestbranch=${latestbranch}" |
| 589 | echo "latest available branch for repo \"${reponame}\" is \"${latestbranch}\"" |
| 590 | csv[i]="${csv[i]},${latestbranch}" |
| 591 | ((i++)) |
| 592 | done |
| 593 | unset array |
| 594 | unset i |
| 595 | unset reponame |
| 596 | unset latestbranch |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 597 | |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 598 | # |
| 599 | # csv column #6: INFO.yaml LC state (project lifecycle state based on INFO.yaml / per repo) |
| 600 | # csv column #7: WIKI LC state (project lifecycle state based on ONAP Dev Wiki / per project) |
| 601 | # csv column #8: LC state match shows a "match" if both LC states match |
| 602 | # |
| 603 | |
| 604 | readarray -t array < ./${repolist}; |
| 605 | i=0 |
| 606 | csv[i]="${csv[i]},INFO.yaml LC state,WIKI LC state,LC state match" |
| 607 | ((i++)) |
| 608 | for line in "${array[@]}" |
| 609 | do |
| 610 | reponame=$(echo $line | awk -F "|" '{print $1}'); |
| 611 | project=$(echo $reponame | sed 's:/.*$::') |
| 612 | |
Thomas Kulik | 3920fd2 | 2021-03-29 12:56:54 +0200 | [diff] [blame] | 613 | if [ -f ./${reponame}/INFO.yaml ] ; then |
| 614 | # check if repo/branch has a INFO.yaml |
| 615 | lifecycleproject=$(grep '^project: ' ./${reponame}/INFO.yaml | awk -F ":" '{print $2}' | sed 's:^ ::' | sed "s:'::g" | tr '[:upper:]' '[:lower:]' | sed 's/\r$//') |
| 616 | lifecyclestate=$(grep '^lifecycle_state: ' ./${reponame}/INFO.yaml | awk -F ":" '{print $2}' | sed 's:^ ::' | sed "s:'::g" | tr '[:upper:]' '[:lower:]' | sed 's/\r$//') |
| 617 | elif [ ${branch} != "master" ] && [ -f ../master/${reponame}/INFO.yaml ] ; then |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 618 | # IF current branch is not master AND if info.yaml not found in the current repo/branch THAN use INFO.yaml of repo/master if available |
Thomas Kulik | 3920fd2 | 2021-03-29 12:56:54 +0200 | [diff] [blame] | 619 | #echo "DBUG: branch=${branch} - checking master for INFO.yaml" |
| 620 | lifecycleproject=$(grep '^project: ' ../master/${reponame}/INFO.yaml | awk -F ":" '{print $2}' | sed 's:^ ::' | sed "s:'::g" | tr '[:upper:]' '[:lower:]' | sed 's/\r$//') |
| 621 | lifecyclestate=$(grep '^lifecycle_state: ' ../master/${reponame}/INFO.yaml | awk -F ":" '{print $2}' | sed 's:^ ::' | sed "s:'::g" | tr '[:upper:]' '[:lower:]' | sed 's/\r$//') |
| 622 | lifecyclestate="(${lifecyclestate})" |
| 623 | else |
| 624 | lifecyclestate="INFO.yaml not found" |
| 625 | fi |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 626 | |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 627 | getwikilifecyclestate ${project} |
| 628 | # returns value in ${return_from_getwikilifecyclestate} |
| 629 | |
Thomas Kulik | 3920fd2 | 2021-03-29 12:56:54 +0200 | [diff] [blame] | 630 | #echo "DBUG: working dir is ...";pwd |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 631 | #echo "DBUG: lifecycleproject=${lifecycleproject}" |
| 632 | #echo "DBUG: lifecyclestate=${lifecyclestate}" |
| 633 | #echo "DBUG: wikilifecyclestate=${return_from_getwikilifecyclestate}" |
| 634 | |
| 635 | #check if YAML.info LC state is not empty _AND_ if WIKI LC state is not empty _AND_ if YAML.info LC state contains WIKI LC state |
| 636 | if [[ ${lifecyclestate} != "" ]] && [[ ${return_from_getwikilifecyclestate} != "" ]] && [[ ${lifecyclestate} == *"${return_from_getwikilifecyclestate}"* ]]; then |
| 637 | lcstatesmatch="match" |
| 638 | else |
| 639 | lcstatesmatch="" |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 640 | fi |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 641 | |
| 642 | csv[i]="${csv[i]},${lifecyclestate},${return_from_getwikilifecyclestate},${lcstatesmatch}" |
Thomas Kulik | 3920fd2 | 2021-03-29 12:56:54 +0200 | [diff] [blame] | 643 | ((i++)) |
| 644 | done |
| 645 | unset array |
| 646 | unset i |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 647 | unset reponame |
| 648 | unset project |
Thomas Kulik | 3920fd2 | 2021-03-29 12:56:54 +0200 | [diff] [blame] | 649 | unset lifecycleproject |
| 650 | unset lifecyclestate |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 651 | unset lcstatesmatch |
Thomas Kulik | 3920fd2 | 2021-03-29 12:56:54 +0200 | [diff] [blame] | 652 | |
| 653 | # |
Thomas Kulik | cff2d01 | 2021-04-12 10:19:38 +0200 | [diff] [blame] | 654 | # csv column #9: RELEASE component (yes|maybe|unknown) |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 655 | # to be filled with values of the planned release config file maintained by |
| 656 | # the onap release manager |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 657 | # NOR FUNCTIONAL YET |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 658 | |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 659 | # repoclone.log format: $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg |
| 660 | readarray -t array < ./${branch}_repoclone.log; |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 661 | i=0 |
| 662 | csv[i]="${csv[i]},${branch_upper} component" |
| 663 | ((i++)) |
| 664 | for line in "${array[@]}" |
| 665 | do |
| 666 | |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 667 | # repoclone.log format: $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 668 | gitexitcode=$(echo $line | awk -F "|" '{print $1}'); |
| 669 | reponame=$(echo $line | awk -F "|" '{print $2}'); |
| 670 | repostate=$(echo $line | awk -F "|" '{print $3}'); |
| 671 | errormsg=$(echo $line | awk -F "|" '{print $4}'); |
| 672 | |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 673 | #if [[ ${repostate} == "ACTIVE" && ${gitexitcode} == "0" ]]; then |
| 674 | # releasecomponent="yes" |
| 675 | #elif [ ${repostate} == "ACTIVE" ]; then |
| 676 | ##elif [[ ${repostate} == "ACTIVE" && ${gitexitcode} == "128" ]]; then |
| 677 | # releasecomponent="maybe" |
| 678 | #elif [[ ${repostate} == "READ_ONLY" && ${gitexitcode} == "0" ]]; then |
| 679 | # releasecomponent="yes" |
| 680 | #elif [ ${repostate} == "READ_ONLY" ]; then |
| 681 | # releasecomponent="maybe" |
| 682 | #else |
| 683 | # releasecomponent="unknown" |
| 684 | #fi |
| 685 | |
| 686 | # not functional yet! |
| 687 | releasecomponent="" |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 688 | |
| 689 | csv[i]="${csv[i]},${releasecomponent}" |
| 690 | ((i++)) |
| 691 | done |
| 692 | unset array |
| 693 | unset i |
| 694 | unset gitexitcode |
| 695 | unset reponame |
| 696 | unset repostate |
| 697 | unset errormsg |
| 698 | unset releasecomponent |
| 699 | |
| 700 | # |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 701 | # csv column #10: RELEASE partizipation |
| 702 | # |
| 703 | |
| 704 | # repoclone.log format: $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg |
| 705 | readarray -t array < ./${branch}_repoclone.log; |
| 706 | i=0 |
| 707 | csv[i]="${csv[i]},${branch_upper} partizipation" |
| 708 | ((i++)) |
| 709 | echo "INFO: determine release partizipation for project ..." |
| 710 | for line in "${array[@]}" |
| 711 | do |
| 712 | |
| 713 | # repoclone.log format: $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg |
| 714 | gitexitcode=$(echo $line | awk -F "|" '{print $1}'); |
| 715 | reponame=$(echo $line | awk -F "|" '{print $2}'); |
| 716 | repostate=$(echo $line | awk -F "|" '{print $3}'); |
| 717 | errormsg=$(echo $line | awk -F "|" '{print $4}'); |
| 718 | projectname=$(echo $reponame | sed 's:/.*$::') |
| 719 | |
| 720 | if [[ $branch == "master" ]]; then |
| 721 | return_from_getrpinfo=""; |
| 722 | else |
| 723 | #echo "DBUG: calling getrpinfo for projectname ${projectname}" |
| 724 | getrpinfo ${projectname} |
| 725 | fi |
| 726 | |
| 727 | csv[i]="${csv[i]},${return_from_getrpinfo}" |
| 728 | ((i++)) |
| 729 | |
| 730 | done |
| 731 | |
| 732 | unset array |
| 733 | unset i |
| 734 | unset gitexitcode |
| 735 | unset reponame |
| 736 | unset repostate |
| 737 | unset errormsg |
| 738 | unset projectname |
| 739 | unset return_from_getrpinfo |
| 740 | |
| 741 | # |
| 742 | # csv column #11: docs (at repo root directory only; no recursive search!) |
| 743 | # csv column #12: conf.py |
| 744 | # csv column #13: tox.ini |
| 745 | # csv column #14: index.rst |
| 746 | # csv column #15: first title in index.rst |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 747 | # |
| 748 | # columns are filled with values from requested branch. |
| 749 | # if data is not available values from master branch are used. |
Thomas Kulik | 56180a5 | 2021-03-31 14:53:19 +0200 | [diff] [blame] | 750 | # to identify master branch values, data is put into round brackets "(...)" |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 751 | # |
| 752 | |
| 753 | readarray -t array < ./${repolist}; |
| 754 | i=0 |
thmsdt | 3353c6e | 2021-06-01 04:42:34 -0700 | [diff] [blame] | 755 | csv[$i]="${csv[i]},docs,conf.py,tox.ini,index.rst,first title in index.rst" |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 756 | ((i++)) |
| 757 | for line in "${array[@]}" |
| 758 | do |
| 759 | line=$(echo $line | sed 's:|.*$::') |
| 760 | #echo "DBUG: line=${line}" |
| 761 | #echo "DBUG: i=${i}" |
| 762 | |
| 763 | # docs |
| 764 | if [ -d ./${line}/docs ] ; then |
| 765 | docs="docs" |
| 766 | elif [ -d ../master/${line}/docs ] ; then |
| 767 | docs="(docs)" |
| 768 | else |
| 769 | docs="-" |
| 770 | fi |
| 771 | |
| 772 | # conf.py |
| 773 | if [ -f ./${line}/docs/conf.py ] ; then |
| 774 | docs="${docs},conf.py" |
| 775 | elif [ -f ../master/${line}/docs/conf.py ] ; then |
| 776 | docs="${docs},(conf.py)" |
| 777 | else |
| 778 | docs="${docs},-" |
| 779 | fi |
| 780 | |
Thomas Kulik | 56180a5 | 2021-03-31 14:53:19 +0200 | [diff] [blame] | 781 | # tox.ini (check docs dir and also check project root dir) |
| 782 | if [ -f ./${line}/docs/tox.ini ] || [ -f ./${line}/tox.ini ]; then |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 783 | docs="${docs},tox.ini" |
Thomas Kulik | 56180a5 | 2021-03-31 14:53:19 +0200 | [diff] [blame] | 784 | # tox.ini @ branch/docs dir |
| 785 | if [ -f ./${line}/docs/tox.ini ] ; then |
| 786 | docs="${docs} @docs" |
| 787 | fi |
| 788 | # tox.ini @ branch/project root dir |
| 789 | if [ -f ./${line}/tox.ini ] ; then |
| 790 | docs="${docs} @root" |
| 791 | fi |
| 792 | elif [ -f ../master/${line}/docs/tox.ini ] || [ -f ../master/${line}/tox.ini ]; then |
| 793 | docs="${docs},(tox.ini" |
| 794 | # tox.ini @ master/docs dir |
| 795 | if [ -f ../master/${line}/docs/tox.ini ] ; then |
| 796 | docs="${docs} @docs" |
| 797 | fi |
| 798 | # tox.ini @ master/project root dir |
| 799 | if [ -f ../master/${line}/tox.ini ] ; then |
| 800 | docs="${docs} @root" |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 801 | fi |
Thomas Kulik | 56180a5 | 2021-03-31 14:53:19 +0200 | [diff] [blame] | 802 | # just add a round bracket at the end of the value |
| 803 | docs="${docs})" |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 804 | else |
Thomas Kulik | 56180a5 | 2021-03-31 14:53:19 +0200 | [diff] [blame] | 805 | # no tox.ini found in docs or root dir |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 806 | docs="${docs},-" |
| 807 | fi |
| 808 | |
thmsdt | 3353c6e | 2021-06-01 04:42:34 -0700 | [diff] [blame] | 809 | # index.rst, first title in index.rst |
| 810 | indexrsttitle="" |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 811 | if [ -f ./${line}/docs/index.rst ] ; then |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 812 | indexrsttitle=$(cat ${branch}_indexrst_docs_root_titles.log | grep -F '['${line}']/docs/index.rst,' | awk -F "," '{print $4}'); |
thmsdt | 3353c6e | 2021-06-01 04:42:34 -0700 | [diff] [blame] | 813 | docs="${docs},index.rst,${indexrsttitle}" |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 814 | elif [ -f ../master/${line}/docs/index.rst ] ; then |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 815 | indexrsttitle=$(cat ../master/master_indexrst_docs_root_titles.log | grep -F '['${line}']/docs/index.rst,' | awk -F "," '{print $4}'); |
thmsdt | 3353c6e | 2021-06-01 04:42:34 -0700 | [diff] [blame] | 816 | docs="${docs},(index.rst),(${indexrsttitle})" |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 817 | else |
thmsdt | 3353c6e | 2021-06-01 04:42:34 -0700 | [diff] [blame] | 818 | docs="${docs},-,-" |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 819 | fi |
| 820 | |
| 821 | #echo "DBUG: docs=${docs}" |
| 822 | line="${csv[i]},${docs}" |
| 823 | csv[$i]=${line} |
| 824 | ((i++)) |
| 825 | done |
| 826 | unset array |
| 827 | unset i |
| 828 | unset docs |
| 829 | |
| 830 | # |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 831 | # csv column #16: index.html@RTD accessibility check |
| 832 | # csv column #17: index.html url |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 833 | # |
| 834 | |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 835 | readarray -t array < ./${branch}_repoclone.log; |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 836 | i=0 |
| 837 | csv[i]="${csv[i]},index.html@RTD,index.html url" |
| 838 | ((i++)) |
| 839 | for line in "${array[@]}" |
| 840 | do |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 841 | # repoclone.log format: $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 842 | gitexitcode=$(echo $line | awk -F "|" '{print $1}'); |
| 843 | reponame=$(echo $line | awk -F "|" '{print $2}'); |
| 844 | repostate=$(echo $line | awk -F "|" '{print $3}'); |
| 845 | errormsg=$(echo $line | awk -F "|" '{print $4}'); |
| 846 | |
| 847 | url="" |
| 848 | curl_result="" |
| 849 | |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 850 | # this script works only with release "frankfurt" and later because |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 851 | # earlier releases are using submodule structure for documentation files |
| 852 | if echo "$branch" | grep -q '^[abcde]'; then |
| 853 | curl_result="unsupported release" |
| 854 | url="-" |
| 855 | else |
| 856 | |
| 857 | # we are working on "frankfurt" branch or later ... |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 858 | if [[ ${repostate} == "ACTIVE" ]] || [[ ${repostate} == "READ_ONLY" ]]; then |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 859 | |
| 860 | # OPTIONAL: USE ALSO GITEXITCODE AS A FILTER CRITERIA ??? |
| 861 | |
| 862 | # url base |
Thomas Kulik | 33cf98f | 2020-11-17 15:09:48 +0100 | [diff] [blame] | 863 | # important! only doc project needs a different url base |
| 864 | if [[ ${reponame} == "doc" ]]; then |
| 865 | url_start="https://docs.onap.org" |
| 866 | else |
| 867 | url_start="https://docs.onap.org/projects/onap" |
| 868 | fi |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 869 | url_lang="en" |
| 870 | url_branch=${branch} |
| 871 | |
| 872 | # "master" branch documentation is available as "latest" in RTD |
| 873 | if [[ ${url_branch} == "master" ]]; then |
| 874 | url_branch="latest" |
| 875 | fi |
| 876 | |
| 877 | # replace all / characters in repo name with - charachter |
| 878 | url_repo=$(echo ${reponame} | sed -r 's/\//-/g') |
| 879 | url_file="index.html" |
| 880 | |
| 881 | # build the full url |
Thomas Kulik | 33cf98f | 2020-11-17 15:09:48 +0100 | [diff] [blame] | 882 | if [[ ${reponame} == "doc" ]]; then |
| 883 | # build the full url for the doc project |
| 884 | url="${url_start}/${url_lang}/${url_branch}/${url_file}" |
| 885 | else |
| 886 | # build the full url for the other projects |
| 887 | url="${url_start}-${url_repo}/${url_lang}/${url_branch}/${url_file}" |
| 888 | fi |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 889 | #echo "DBUG: url=$url" |
| 890 | |
| 891 | # test accessibility of url |
Thomas Kulik | 33cf98f | 2020-11-17 15:09:48 +0100 | [diff] [blame] | 892 | curl --head --silent --fail "${url}?${unique}" >/dev/null |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 893 | curl_result=$? |
| 894 | |
| 895 | # convert numeric results to text |
| 896 | if [ "${curl_result}" = "0" ]; then |
| 897 | curl_result="accessible" |
| 898 | elif [ "${curl_result}" = "22" ]; then |
| 899 | curl_result="does not exist" |
| 900 | else |
| 901 | curl_result="ERROR:${curl_result}" |
| 902 | fi |
| 903 | |
| 904 | # url does not exist for this branch. |
| 905 | # in case the requested url is not already for "master" branch, |
| 906 | # we try to access the url of the master branch and denote the |
| 907 | # result by using round brackets (result) |
| 908 | if [[ ${curl_result} == "does not exist" && ! $branch == "master" ]]; then |
| 909 | |
| 910 | # build the full (master/latest) url |
| 911 | url="${url_start}-${url_repo}/${url_lang}/latest/${url_file}" |
| 912 | #echo "DBUG: url=$url" |
| 913 | |
| 914 | # test accessibility of url in "master branch" (latest) |
Thomas Kulik | 33cf98f | 2020-11-17 15:09:48 +0100 | [diff] [blame] | 915 | curl --head --silent --fail "${url}?${unique}" >/dev/null |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 916 | curl_result=$? |
| 917 | # denote result as a value from "master" branch (latest) |
| 918 | url="(${url})" |
| 919 | |
| 920 | # convert numeric results to text |
| 921 | if [ "${curl_result}" = "0" ]; then |
| 922 | curl_result="(accessible)" |
| 923 | elif [ "${curl_result}" = "22" ]; then |
| 924 | curl_result="(does not exist)" |
| 925 | else |
| 926 | curl_result="(ERROR:${curl_result})" |
| 927 | fi |
| 928 | |
| 929 | fi |
| 930 | else |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 931 | # repostate IS NOT ACTIVE OR READ_ONLY - no curl test required |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 932 | curl_result="-" |
| 933 | url="-" |
| 934 | fi |
| 935 | fi |
| 936 | |
| 937 | echo "$url ... $curl_result" |
| 938 | csv[i]="${csv[i]},${curl_result},${url}" |
| 939 | #echo "DBUG: csv line=${csv[i]}" |
| 940 | |
| 941 | ((i++)) |
| 942 | done |
| 943 | |
| 944 | # |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 945 | # csv column #18: release notes |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 946 | # |
| 947 | |
| 948 | readarray -t array < ../${repolist}; |
| 949 | i=0 |
| 950 | csv[i]="${csv[i]},release notes" |
| 951 | ((i++)) |
| 952 | for line in "${array[@]}" |
| 953 | do |
| 954 | line=$(echo $line | sed 's:|.*$::') |
| 955 | #echo "DBUG: line=\"${line}\"" |
| 956 | #echo "DBUG: i=${i}" |
| 957 | relnote="" |
| 958 | |
| 959 | # put repo name in square brackets for increased grep hit rate |
| 960 | # escape minus and bracket characters to avoid problems with the grep command |
| 961 | #repo_grepable=$(echo ${line} | sed -r s:${line}:[${line}]: | sed -r 's/-/\\-/g' | sed -r 's/\[/\\[/g' | sed -r 's/\]/\\]/g') |
| 962 | #echo "DBUG: repo_grepable=\"${repo_grepable}\"" |
| 963 | |
| 964 | # check if repo dir exists in this branch |
| 965 | if [ -d ./${line} ] ; then |
| 966 | # if yes, check if repo name appears in the branch releasenotes.log |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 967 | relnote=$(find "./${line}" -type f | grep '.*release.*note.*.rst' | wc -l); |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 968 | #echo "DBUG: relnote=${relnote}" |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 969 | # repo dir DOES NOT exist in this branch - so check if repo dir exists in MASTER branch |
| 970 | elif [ -d ../master/${line} ] ; then |
| 971 | # if yes, check if repo name appears in the MASTER releasenotes.log |
| 972 | # count release notes files in MASTER branch (in repo root and its subdirectories) |
| 973 | relnote=$(find "../master/${line}" -type f | grep 'release.*note.*.rst' | wc -l); |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 974 | #echo "DBUG: relnote=${relnote}" |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 975 | # put results in round brackets to show that this is MASTER data |
| 976 | relnote=$(echo ${relnote} | sed -r s:${relnote}:\(${relnote}\):) |
| 977 | else |
| 978 | relnote="-" |
| 979 | fi |
Thomas Kulik | eb61bd8 | 2021-03-24 14:28:05 +0100 | [diff] [blame] | 980 | #echo "DBUG: relnote=${relnote}" |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 981 | |
| 982 | line="${csv[i]},${relnote}" |
| 983 | csv[i]=${line} |
| 984 | ((i++)) |
| 985 | |
| 986 | done |
| 987 | unset array |
| 988 | unset i |
| 989 | unset relnote |
| 990 | unset repo_grepable |
| 991 | |
| 992 | # |
| 993 | # build the table.csv file |
| 994 | # |
| 995 | |
| 996 | for i in "${csv[@]}" |
| 997 | do |
| 998 | echo "$i" | tee -a ./${branch}_table.csv |
| 999 | done |
| 1000 | |
| 1001 | # |
| 1002 | # create data package for this branch and zip it |
| 1003 | # |
| 1004 | |
| 1005 | datadir=${branch}_data |
| 1006 | mkdir $datadir |
| 1007 | cp $repolist $datadir |
thmsdt | c7adba6 | 2021-06-10 08:53:28 -0700 | [diff] [blame] | 1008 | cp ../$wikiplsfile $datadir |
| 1009 | cp ../$rpfile $datadir |
Thomas Kulik | baa0710 | 2020-11-16 10:43:15 +0100 | [diff] [blame] | 1010 | cp ${branch}_table.csv $datadir |
| 1011 | cp ${branch}_*.log $datadir |
| 1012 | zip -r ${datadir}.zip $datadir |
| 1013 | |
| 1014 | # return from the branch directory |
| 1015 | cd .. |
| 1016 | |
| 1017 | # return and work on the next requested branch ... or exit |
| 1018 | done |