-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVisualizationReports.sh
More file actions
executable file
·64 lines (51 loc) · 3.5 KB
/
VisualizationReports.sh
File metadata and controls
executable file
·64 lines (51 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
# Runs all Visualization reports.
# It only consideres scripts in the "reports" directory (overridable with REPORTS_SCRIPT_DIR) one directory above this one.
# These require node.js.
# Therefore these reports will take longer and require more resources than just plain database queries/procedures.
# Requires reports/*.sh
# Needs to run after reports/TopologySortCsv.sh that provides the property "topologicalSortIndex" to be queried.
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
set -o errexit -o pipefail
# Overrideable Constants (defaults also defined in sub scripts)
LOG_GROUP_START=${LOG_GROUP_START:-"::group::"} # Prefix to start a log group. Defaults to GitHub Actions log group start command.
LOG_GROUP_END=${LOG_GROUP_END:-"::endgroup::"} # Prefix to end a log group. Defaults to GitHub Actions log group end command.
# Local constants
SCRIPT_NAME=$(basename "${0}")
## Get this "scripts/reports/compilations" directory if not already set.
# Even if $BASH_SOURCE is made for Bourne-like shells it is also supported by others and therefore here the preferred solution.
# CDPATH reduces the scope of the cd command to potentially prevent unintended directory changes.
# This way non-standard tools like readlink aren't needed.
REPORT_COMPILATIONS_SCRIPT_DIR=${REPORT_COMPILATIONS_SCRIPT_DIR:-$( CDPATH=. cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P )}
REPORTS_SCRIPT_DIR=${REPORTS_SCRIPT_DIR:-$(dirname -- "${REPORT_COMPILATIONS_SCRIPT_DIR}")}
DOMAINS_DIRECTORY=${DOMAINS_DIRECTORY:-"${REPORTS_SCRIPT_DIR}/../../domains"}
echo "${LOG_GROUP_START}$(date +'%Y-%m-%dT%H:%M:%S') Initialize Visualization Reports";
echo "${SCRIPT_NAME}: REPORT_COMPILATIONS_SCRIPT_DIR=${REPORT_COMPILATIONS_SCRIPT_DIR}"
echo "${SCRIPT_NAME}: REPORTS_SCRIPT_DIR=${REPORTS_SCRIPT_DIR}"
echo "${SCRIPT_NAME}: DOMAINS_DIRECTORY=${DOMAINS_DIRECTORY}"
echo "${SCRIPT_NAME}: ANALYSIS_DOMAIN=${ANALYSIS_DOMAIN}"
echo "${LOG_GROUP_END}";
# Run all visualization scripts (filename ending with Visualization.sh) in the REPORTS_SCRIPT_DIR and DOMAINS_DIRECTORY directories.
# When a specific analysis domain is selected, only run reports for that domain's directory.
# Otherwise, run reports from both the general reports directory and all domains.
if [ -n "${ANALYSIS_DOMAIN}" ]; then
analysisReportScriptDirectories=( "${DOMAINS_DIRECTORY}/${ANALYSIS_DOMAIN}" )
else
analysisReportScriptDirectories=( "${REPORTS_SCRIPT_DIR}" "${DOMAINS_DIRECTORY}" )
fi
for directory in "${analysisReportScriptDirectories[@]}"; do
if [ ! -d "${directory}" ]; then
echo "${SCRIPT_NAME}: Error: Directory ${directory} does not exist. Please check your REPORTS_SCRIPT_DIR and DOMAINS_DIRECTORY settings."
exit 1
fi
# Run all visualization scripts in the selected directory.
find "${directory}" -type f -name "*Visualization.sh" | sort | while read -r visualization_script_file; do
visualization_script_filename=$(basename -- "${visualization_script_file}")
visualization_script_filename="${visualization_script_filename%.*}" # Remove file extension
echo "${LOG_GROUP_START}$(date +'%Y-%m-%dT%H:%M:%S') Create Visualization Report ${visualization_script_filename}";
echo "${SCRIPT_NAME}: $(date +'%Y-%m-%dT%H:%M:%S') Starting ${visualization_script_filename}...";
source "${visualization_script_file}"
echo "${SCRIPT_NAME}: $(date +'%Y-%m-%dT%H:%M:%S') Finished ${visualization_script_filename}";
echo "${LOG_GROUP_END}";
done
done