2020-06-16 15:33:23 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								#!/bin/bash
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# abort if we get any error  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								set  -eo pipefail 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								pretty_print_result_of_report( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # $1 = result of current report 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  echo  -e "\n\n" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  echo  -e "-----------------------------------------------------\n" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  echo  -e " $1 \n " 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-14 20:35:55 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  echo  "-----------------------------------------------------" 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-16 15:33:23 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-14 20:35:55 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								BUILD_MODE = " ${ 1 -local } "  
						 
					
						
							
								
									
										
										
										
											2020-06-16 15:33:23 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								REPORT_PATH = " $( realpath " $( dirname " $0 " ) /../reports/docs/ " ) "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								BUILD_SCRIPT_PATH = " $( realpath " $( dirname " $0 " ) /ci-reference-docs-build.sh " ) "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if  [  ! -d " $REPORT_PATH "  ] ;  then  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # this script needs to be run after the packages have been built and the api-extractor has completed. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # shellcheck source=/scripts/ci-reference-docs-build.sh 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-14 20:35:55 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  if  ! . " $BUILD_SCRIPT_PATH "  " $BUILD_MODE " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      echo  "Failed to build packages and extract docs"  >& 2 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      exit  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      echo  "Successfully built packages and extracted docs" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-16 15:33:23 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								fi  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-19 12:38:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								WARNINGS_COUNT = " $( find " $REPORT_PATH "  -type f -name \* .log -print0 |  xargs -0 grep -o "Warning:.*(ae-\|Warning:.*(tsdoc-"  |  wc -l |  xargs) "  
						 
					
						
							
								
									
										
										
										
											2021-10-18 15:16:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								WARNINGS_COUNT_LIMIT = 1212  
						 
					
						
							
								
									
										
										
										
											2020-06-16 15:33:23 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if  [  " $WARNINGS_COUNT "  -gt $WARNINGS_COUNT_LIMIT  ] ;  then  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  echo  -e " API Extractor warnings/errors  $WARNINGS_COUNT  exceeded  $WARNINGS_COUNT_LIMIT  so failing build.\n " 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-06 22:29:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  echo  "Please go to: https://github.com/grafana/grafana/blob/main/contribute/style-guides/code-comments.md for more information on how to add code comments." 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-16 15:33:23 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								fi  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if  [  " $WARNINGS_COUNT "  -lt $WARNINGS_COUNT_LIMIT  ] ;  then  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  pretty_print_result_of_report " Wohoo! Fewer warnings compared to last build 🎉🎈🍾✨\n\nYou can lower the threshold from  $WARNINGS_COUNT_LIMIT  to  $WARNINGS_COUNT  in the:\nscripts/ci-reference-docs-metrics.sh " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								fi  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								pretty_print_result_of_report " API Extractor total warnings:  $WARNINGS_COUNT "