33# Runs all Python report scripts (no Chromium required).
44# It only considers scripts in the "reports" and "domains" directories and their sub directories (overridable with REPORTS_SCRIPT_DIR and DOMAINS_DIRECTORY).
55
6- # Requires reports/*.sh
6+ # Requires activateCondaEnvironment.sh, activatePythonEnvironment.sh, reports/*.sh
77
88# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
99set -o errexit -o pipefail
@@ -12,22 +12,25 @@ set -o errexit -o pipefail
1212LOG_GROUP_START=${LOG_GROUP_START:- " ::group::" } # Prefix to start a log group. Defaults to GitHub Actions log group start command.
1313LOG_GROUP_END=${LOG_GROUP_END:- " ::endgroup::" } # Prefix to end a log group. Defaults to GitHub Actions log group end command.
1414
15+ # Local constants
16+ SCRIPT_NAME=$( basename " ${0} " )
17+
1518# # Get this "scripts/reports/compilations" directory if not already set.
1619# Even if $BASH_SOURCE is made for Bourne-like shells it is also supported by others and therefore here the preferred solution.
1720# CDPATH reduces the scope of the cd command to potentially prevent unintended directory changes.
1821# This way non-standard tools like readlink aren't needed.
1922REPORT_COMPILATIONS_SCRIPT_DIR=${REPORT_COMPILATIONS_SCRIPT_DIR:- $( CDPATH=. cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " && pwd -P )}
20- echo " PythonReports: REPORT_COMPILATIONS_SCRIPT_DIR=${REPORT_COMPILATIONS_SCRIPT_DIR} "
21-
2223REPORTS_SCRIPT_DIR=${REPORTS_SCRIPT_DIR:- $(dirname -- " ${REPORT_COMPILATIONS_SCRIPT_DIR} " )}
23- echo " PythonReports: REPORTS_SCRIPT_DIR=${REPORTS_SCRIPT_DIR} "
24-
2524SCRIPTS_DIR=${SCRIPTS_DIR:- $(dirname -- " ${REPORTS_SCRIPT_DIR} " )}
26- echo " PythonReports: SCRIPTS_DIR=${SCRIPTS_DIR} "
2725
2826# Get the "domains" directory that contains analysis and report scripts by functionality.
2927DOMAINS_DIRECTORY=${DOMAINS_DIRECTORY:- " ${REPORTS_SCRIPT_DIR} /../../domains" }
30- echo " PythonReports: DOMAINS_DIRECTORY=${DOMAINS_DIRECTORY} "
28+
29+ echo " ${LOG_GROUP_START} $( date +' %Y-%m-%dT%H:%M:%S' ) Initialize Python Reports" ;
30+ echo " ${SCRIPT_NAME} : REPORT_COMPILATIONS_SCRIPT_DIR=${REPORT_COMPILATIONS_SCRIPT_DIR} "
31+ echo " ${SCRIPT_NAME} : REPORTS_SCRIPT_DIR=${REPORTS_SCRIPT_DIR} "
32+ echo " ${SCRIPT_NAME} : SCRIPTS_DIR=${SCRIPTS_DIR} "
33+ echo " ${SCRIPT_NAME} : DOMAINS_DIRECTORY=${DOMAINS_DIRECTORY} "
3134
3235# Create and activate (if necessary) a virtual environment (Conda or venv).
3336# For Conda, the environment name is taken from the environment variable CODEGRAPH_CONDA_ENVIRONMENT (default "codegraph")
@@ -36,10 +39,12 @@ echo "PythonReports: DOMAINS_DIRECTORY=${DOMAINS_DIRECTORY}"
3639time source " ${SCRIPTS_DIR} /activateCondaEnvironment.sh"
3740time source " ${SCRIPTS_DIR} /activatePythonEnvironment.sh"
3841
42+ echo " ${LOG_GROUP_END} " ;
43+
3944# Run all Python report scripts (filename ending with Csv.sh) in the REPORTS_SCRIPT_DIR and DOMAINS_DIRECTORY directories.
4045for directory in " ${REPORTS_SCRIPT_DIR} " " ${DOMAINS_DIRECTORY} " ; do
4146 if [ ! -d " ${directory} " ]; then
42- echo " PythonReports : Error: Directory ${directory} does not exist. Please check your REPORTS_SCRIPT_DIR and DOMAIN_DIRECTORY settings."
47+ echo " ${SCRIPT_NAME} : Error: Directory ${directory} does not exist. Please check your REPORTS_SCRIPT_DIR and DOMAIN_DIRECTORY settings."
4348 exit 1
4449 fi
4550
@@ -48,12 +53,12 @@ for directory in "${REPORTS_SCRIPT_DIR}" "${DOMAINS_DIRECTORY}"; do
4853 report_script_filename=$( basename -- " ${report_script_file} " ) ;
4954 report_script_filename=" ${report_script_filename% .* } " # Remove file extension
5055
51- echo " ${LOG_GROUP_START} Create Python Report ${report_script_filename} " ;
52- echo " PythonReports : $( date +' %Y-%m-%dT%H:%M:%S%z ' ) Starting ${report_script_filename} ..." ;
56+ echo " ${LOG_GROUP_START} $( date + ' %Y-%m-%dT%H:%M:%S ' ) Create Python Report ${report_script_filename} " ;
57+ echo " ${SCRIPT_NAME} : $( date +' %Y-%m-%dT%H:%M:%S' ) Starting ${report_script_filename} ..." ;
5358
5459 source " ${report_script_file} "
5560
56- echo " PythonReports : $( date +' %Y-%m-%dT%H:%M:%S%z ' ) Finished ${report_script_filename} " ;
61+ echo " ${SCRIPT_NAME} : $( date +' %Y-%m-%dT%H:%M:%S' ) Finished ${report_script_filename} " ;
5762 echo " ${LOG_GROUP_END} " ;
5863 done
5964done
0 commit comments