2 #set -x # uncomment for bash script debugging
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
9 ### http://www.apache.org/licenses/LICENSE-2.0
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=====================================================
22 ### Thomas Kulik, Deutsche Telekom AG, 2020 - 2021
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.
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)
45 ### SOME HELPING COMMANDS TO PROCESS LOG FILES:
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:'.*::"
49 ### remove branchname from the line:
50 ### cat frankfurt_repoclone.log | sed 's:frankfurt|::'
52 ### list only image names
53 ### cat master_dockerimagesfull.log | grep image | sed -r 's:image\:::' | sed -r 's:^ +::' | sed '/^[[:space:]]*$/d'
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'
61 script_version="1.10 (2021-06-10)"
63 # save command for the restart with logging enabled
66 fullcommand="${command} ${arguments}"
75 echo " checkdocs.sh Version ${script_version}"
78 echo " ./checkdocs.sh <arguments> "
81 echo " -u|--user username "
82 echo " linux foundation username used to clone ONAP repositories"
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! "
89 echo " development-mode - limits number of repos to be cloned "
95 echo "*******************************************************************************"
98 # remove lockfile in case script is interrupted
99 trap InterruptedScript SIGINT SIGTERM SIGHUP SIGKILL SIGSTOP
100 function InterruptedScript {
102 echo "Script was interrupted."
103 if [ -f $lockfile ] ; then
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
114 function getwikilifecyclestate {
121 return_from_getwikilifecyclestate=""
123 for wikiline in "${wikiplsarray[@]}"
126 wikirepo=$(echo $wikiline | awk -F ";" '{print $1}');
127 wikistate=$(echo $wikiline | awk -F ";" '{print $2}');
129 #echo "DBUG: getwikilifecyclestate wikiline = \"${wikiline}\"";
130 #echo "DBUG: getwikilifecyclestate wikirepo = \"${wikirepo}\""
131 #echo "DBUG: getwikilifecyclestate wikistate = \"${wikistate}\""
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}\"";
143 #echo "DBUG: getwikilifecyclestate requested \"${requested}\" NOT FOUND in list"
144 return_from_getwikilifecyclestate=""
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
162 local current_branch_starting_letter=""
163 return_from_getrpinfo=""
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 "-"}');
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}"
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}\"";
186 if [[ ${rpproject} = ${requested} ]] && [[ "${rpdetails}" == *"${current_branch_starting_letter}"* ]]; then
187 return_from_getrpinfo="project partizipated"
188 #echo "DBUG: getrpinfo return = \"${return_from_getrpinfo}\"";
192 #echo "DBUG: getrpinfo requested \"${requested}\" NOT FOUND in list"
193 return_from_getrpinfo=""
198 ### arguments handling
210 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
214 echo "Error: Argument for $1 is missing" >&2
220 if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
224 echo "Error: Argument for $1 is missing" >&2
229 -*|--*=) # unsupported flags
230 echo "Error: Unsupported argument $1" >&2
234 *) # preserve positional arguments
241 # set positional arguments in their proper place
242 eval set -- "$PARAMS"
244 # old: declare -a branches=("master" "frankfurt" "guilin")
245 if [[ $branches_csv == "" || $lfusername == "" ]]; then
250 # master branch is automatically added and must not part of the user arguments
251 if [[ $branches_csv == *"master"* ]]; then
255 # clone master first, then the other branches
256 branches_csv="master,${branches_csv}"
258 # create the branches array by readinging in the values from the variable
259 IFS=',' read -r -a branches <<< "${branches_csv}"
261 #echo "DBUG: devmode = \"${devmode}\""
262 #echo "DBUG: branches_csv = \"${branches_csv}\""
263 #echo "DBUG: lfusername = \"${lfusername}\""
264 #echo "DBUG: branches = \"${branches[@]}\""
266 # restart script with logging enabled
267 lockfile="checkdocs-runtime-lockfile"
268 if [ ! -f $lockfile ] ; then
270 echo "Restarting script with logging enabled."
271 ${fullcommand} 2>&1 | tee checkdocs.log
277 echo "checkdocs.sh Version ${script_version}"
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>
286 wikiplsfile=$(ls | sed -nr '/wiki_lifecycle_state_[0-9]{6}.txt/Ip' | tail -1);
287 if [[ $wikiplsfile == "" ]]; then
288 echo "ERROR: wiki_lifecycle_state_yymmdd.txt missing"
291 echo "Using \"${wikiplsfile}\" as the source for wiki (project) lifecycle state information."
292 readarray -t wikiplsarray < ./${wikiplsfile};
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)
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"
308 echo "Using \"${rpfile}\" as the source for release partizipation information."
309 readarray -t rparray < ./${rpfile};
311 rparray=("${rparray[@]:1}")
312 # printf '%s\n' "${rparray[@]}"
315 # curl must be installed
318 if ! command -v curl &> /dev/null
320 echo "ERROR: curl command could not be found"
324 today=$(date '+%Y-%m-%d');
325 repolist="gerrit-repos-master-"$today".txt";
328 echo "Retrieving a full list of ONAP repositories (master) from gerrit.onap.org."
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)
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
338 # process the created repolist and try to clone the projects from the mirror
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 ..."
344 for branch in "${branches[@]}"
353 branch_upper=$(echo "${branch}" | tr '[:lower:]' '[:upper:]')
365 if [[ $devmode == "TRUE" ]]; then
366 devcounter=$((devcounter+1))
369 if [[ $devcounter -lt "50" ]]; then
371 if [[ $devmode == "TRUE" ]]; then
372 echo "INFO: devmode! counter=${devcounter}"
376 reponame=$(echo $line | awk -F "|" '{print $1}');
377 repostate=$(echo $line | awk -F "|" '{print $2}');
381 if [[ $repostate == "ACTIVE" ]] || [[ $repostate == "READ_ONLY" ]]; then
382 echo "Cloning \"${branch}\" branch of \"${repostate}\" project ${reponame}..."
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}
389 if [[ ! ${gitexitcode} == "0" ]]; then
390 errormsg=$(tail -1 ../checkdocs.log)
395 # repoclone.log format: $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg
396 echo "${gitexitcode}|${reponame}|${repostate}|${errormsg}" | tee -a ${branch}_repoclone.log
398 #elif [[ $repostate == "READ_ONLY" ]]; then
399 #echo "-|${reponame}|${repostate}|ignored" | tee -a ${branch}_repoclone.log
401 echo "-|${reponame}|unknown repo state \"${repostate}\"|-" | tee -a ${branch}_repoclone.log
405 if [[ ${gitexitcode} == "0" ]]; then
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
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
413 printf "\nrelease notes rst:\n"
414 find ./$reponame -type f | grep '.*release.*note.*.rst' | sed -r 's:./::' | sed -r s:${reponame}:[${reponame}]: | tee -a ${branch}_releasenotes.log
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
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
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
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
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
433 # end defcounter loop
440 # get (first) title for a rst file
442 python3 ../getrsttitle.py ${branch}_rstfiles.log | tee ${branch}_rstfiles_titles.log
444 python3 ../getrsttitle.py ${branch}_indexrst_docs_root.log | tee ${branch}_indexrst_docs_root_titles.log
448 find . -type f -name values.yaml -print -exec grep "image:" {} \; | sed -r 's:^ +::' | tee ${branch}_dockerimagesfull.log
450 ls --format single-column -d */ | sed 's:/$::' | tee ${branch}_directories.log
452 cat ${branch}_dockerimagesfull.log | grep image | sed -r 's:image\:::' | sed -r 's:^ +::' | sed '/^[[:space:]]*$/d' >${branch}_dockerimages.log
454 ls --format single-column -d oom/kubernetes/*/ | tee ${branch}_oomkubernetes.log
458 readarray -t docs_array < ./${branch}_docs.log;
460 for line in "${docs_array[@]}"
463 echo $line | tee -a ${branch}_docsconfig.log
465 # remove [ and ] which are distinguish the project name in the output
466 line=$(echo $line | sed -r 's:\[:: ; s:\]::')
468 if [ -f ./${line}/conf.py ] ; then
469 echo " conf.py ..... found" | tee -a ${branch}_docsconfig.log
471 echo " conf.py ..... NOT FOUND" | tee -a ${branch}_docsconfig.log
474 if [ -f ./${line}/index.rst ] ; then
475 echo " index.rst ... found" | tee -a ${branch}_docsconfig.log
477 echo " index.rst ... NOT FOUND" | tee -a ${branch}_docsconfig.log
480 if [ -f ./${line}/tox.ini ] ; then
481 echo " tox.ini ..... found" | tee -a ${branch}_docsconfig.log
483 echo " tox.ini ..... NOT FOUND" | tee -a ${branch}_docsconfig.log
486 echo " " | tee -a ${branch}_docsconfig.log
494 ### build a csv table that combines results
498 # csv column #1: project name
501 readarray -t array < ./${repolist};
505 for line in "${array[@]}"
507 reponame=$(echo $line | awk -F "|" '{print $1}');
508 project=$(echo $reponame | sed 's:/.*$::')
509 #echo "DBUG: reponame=${reponame}"
510 #echo "DBUG: project=${project}"
521 # csv column #2: repo name
524 readarray -t array < ./${repolist};
526 csv[i]="${csv[i]},MASTER repo name"
528 for line in "${array[@]}"
530 reponame=$(echo $line | awk -F "|" '{print $1}');
531 csv[i]="${csv[i]},${reponame}"
539 # csv column #3: repo state
542 readarray -t array < ./${repolist};
544 csv[i]="${csv[i]},MASTER repo state"
546 for line in "${array[@]}"
548 repostate=$(echo $line | awk -F "|" '{print $2}');
549 csv[i]="${csv[i]},${repostate}"
557 # csv column #4: clone message
560 readarray -t array < ./${branch}_repoclone.log;
562 csv[i]="${csv[i]},${branch_upper} clone message"
564 for line in "${array[@]}"
566 # repoclone.log format: $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg
567 errormsg=$(echo $line | awk -F "|" '{print $4}');
568 csv[i]="${csv[i]},${errormsg}"
576 # csv column #5: latest branch
579 readarray -t array < ./${repolist};
581 csv[i]="${csv[i]},latest branch"
583 for line in "${array[@]}"
585 reponame=$(echo $line | awk -F "|" '{print $1}');
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}"
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
604 readarray -t array < ./${repolist};
606 csv[i]="${csv[i]},INFO.yaml LC state,WIKI LC state,LC state match"
608 for line in "${array[@]}"
610 reponame=$(echo $line | awk -F "|" '{print $1}');
611 project=$(echo $reponame | sed 's:/.*$::')
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
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
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})"
624 lifecyclestate="INFO.yaml not found"
627 getwikilifecyclestate ${project}
628 # returns value in ${return_from_getwikilifecyclestate}
630 #echo "DBUG: working dir is ...";pwd
631 #echo "DBUG: lifecycleproject=${lifecycleproject}"
632 #echo "DBUG: lifecyclestate=${lifecyclestate}"
633 #echo "DBUG: wikilifecyclestate=${return_from_getwikilifecyclestate}"
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"
642 csv[i]="${csv[i]},${lifecyclestate},${return_from_getwikilifecyclestate},${lcstatesmatch}"
649 unset lifecycleproject
654 # csv column #9: RELEASE component (yes|maybe|unknown)
655 # to be filled with values of the planned release config file maintained by
656 # the onap release manager
659 # repoclone.log format: $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg
660 readarray -t array < ./${branch}_repoclone.log;
662 csv[i]="${csv[i]},${branch_upper} component"
664 for line in "${array[@]}"
667 # repoclone.log format: $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg
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}');
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"
683 # releasecomponent="unknown"
686 # not functional yet!
689 csv[i]="${csv[i]},${releasecomponent}"
698 unset releasecomponent
701 # csv column #10: RELEASE partizipation
704 # repoclone.log format: $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg
705 readarray -t array < ./${branch}_repoclone.log;
707 csv[i]="${csv[i]},${branch_upper} partizipation"
709 echo "INFO: determine release partizipation for project ..."
710 for line in "${array[@]}"
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:/.*$::')
720 if [[ $branch == "master" ]]; then
721 return_from_getrpinfo="";
723 #echo "DBUG: calling getrpinfo for projectname ${projectname}"
724 getrpinfo ${projectname}
727 csv[i]="${csv[i]},${return_from_getrpinfo}"
739 unset return_from_getrpinfo
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
748 # columns are filled with values from requested branch.
749 # if data is not available values from master branch are used.
750 # to identify master branch values, data is put into round brackets "(...)"
753 readarray -t array < ./${repolist};
755 csv[$i]="${csv[i]},docs,conf.py,tox.ini,index.rst,first title in index.rst"
757 for line in "${array[@]}"
759 line=$(echo $line | sed 's:|.*$::')
760 #echo "DBUG: line=${line}"
764 if [ -d ./${line}/docs ] ; then
766 elif [ -d ../master/${line}/docs ] ; then
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)"
781 # tox.ini (check docs dir and also check project root dir)
782 if [ -f ./${line}/docs/tox.ini ] || [ -f ./${line}/tox.ini ]; then
783 docs="${docs},tox.ini"
784 # tox.ini @ branch/docs dir
785 if [ -f ./${line}/docs/tox.ini ] ; then
788 # tox.ini @ branch/project root dir
789 if [ -f ./${line}/tox.ini ] ; then
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
798 # tox.ini @ master/project root dir
799 if [ -f ../master/${line}/tox.ini ] ; then
802 # just add a round bracket at the end of the value
805 # no tox.ini found in docs or root dir
809 # index.rst, first title in index.rst
811 if [ -f ./${line}/docs/index.rst ] ; then
812 indexrsttitle=$(cat ${branch}_indexrst_docs_root_titles.log | grep -F '['${line}']/docs/index.rst,' | awk -F "," '{print $4}');
813 docs="${docs},index.rst,${indexrsttitle}"
814 elif [ -f ../master/${line}/docs/index.rst ] ; then
815 indexrsttitle=$(cat ../master/master_indexrst_docs_root_titles.log | grep -F '['${line}']/docs/index.rst,' | awk -F "," '{print $4}');
816 docs="${docs},(index.rst),(${indexrsttitle})"
821 #echo "DBUG: docs=${docs}"
822 line="${csv[i]},${docs}"
831 # csv column #16: index.html@RTD accessibility check
832 # csv column #17: index.html url
835 readarray -t array < ./${branch}_repoclone.log;
837 csv[i]="${csv[i]},index.html@RTD,index.html url"
839 for line in "${array[@]}"
841 # repoclone.log format: $1=gitexitcode|$2=reponame|$3=repostate|$4=errormsg
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}');
850 # this script works only with release "frankfurt" and later because
851 # earlier releases are using submodule structure for documentation files
852 if echo "$branch" | grep -q '^[abcde]'; then
853 curl_result="unsupported release"
857 # we are working on "frankfurt" branch or later ...
858 if [[ ${repostate} == "ACTIVE" ]] || [[ ${repostate} == "READ_ONLY" ]]; then
860 # OPTIONAL: USE ALSO GITEXITCODE AS A FILTER CRITERIA ???
863 # important! only doc project needs a different url base
864 if [[ ${reponame} == "doc" ]]; then
865 url_start="https://docs.onap.org"
867 url_start="https://docs.onap.org/projects/onap"
872 # "master" branch documentation is available as "latest" in RTD
873 if [[ ${url_branch} == "master" ]]; then
877 # replace all / characters in repo name with - charachter
878 url_repo=$(echo ${reponame} | sed -r 's/\//-/g')
879 url_file="index.html"
882 if [[ ${reponame} == "doc" ]]; then
883 # build the full url for the doc project
884 url="${url_start}/${url_lang}/${url_branch}/${url_file}"
886 # build the full url for the other projects
887 url="${url_start}-${url_repo}/${url_lang}/${url_branch}/${url_file}"
889 #echo "DBUG: url=$url"
891 # test accessibility of url
892 curl --head --silent --fail "${url}?${unique}" >/dev/null
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"
901 curl_result="ERROR:${curl_result}"
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
910 # build the full (master/latest) url
911 url="${url_start}-${url_repo}/${url_lang}/latest/${url_file}"
912 #echo "DBUG: url=$url"
914 # test accessibility of url in "master branch" (latest)
915 curl --head --silent --fail "${url}?${unique}" >/dev/null
917 # denote result as a value from "master" branch (latest)
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)"
926 curl_result="(ERROR:${curl_result})"
931 # repostate IS NOT ACTIVE OR READ_ONLY - no curl test required
937 echo "$url ... $curl_result"
938 csv[i]="${csv[i]},${curl_result},${url}"
939 #echo "DBUG: csv line=${csv[i]}"
945 # csv column #18: release notes
948 readarray -t array < ../${repolist};
950 csv[i]="${csv[i]},release notes"
952 for line in "${array[@]}"
954 line=$(echo $line | sed 's:|.*$::')
955 #echo "DBUG: line=\"${line}\""
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}\""
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
967 relnote=$(find "./${line}" -type f | grep '.*release.*note.*.rst' | wc -l);
968 #echo "DBUG: relnote=${relnote}"
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);
974 #echo "DBUG: relnote=${relnote}"
975 # put results in round brackets to show that this is MASTER data
976 relnote=$(echo ${relnote} | sed -r s:${relnote}:\(${relnote}\):)
980 #echo "DBUG: relnote=${relnote}"
982 line="${csv[i]},${relnote}"
993 # build the table.csv file
998 echo "$i" | tee -a ./${branch}_table.csv
1002 # create data package for this branch and zip it
1005 datadir=${branch}_data
1007 cp $repolist $datadir
1008 cp ../$wikiplsfile $datadir
1009 cp ../$rpfile $datadir
1010 cp ${branch}_table.csv $datadir
1011 cp ${branch}_*.log $datadir
1012 zip -r ${datadir}.zip $datadir
1014 # return from the branch directory
1017 # return and work on the next requested branch ... or exit