Skip to content

Commit 0643846

Browse files
committed
Improve error handling using a fail-fast approach
1 parent 6486d10 commit 0643846

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+226
-66
lines changed

.github/workflows/code-structure-analysis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,9 @@ jobs:
134134
if: failure()
135135
uses: actions/upload-artifact@v3
136136
with:
137-
name: code-analysis-logs-java-${{ matrix.java }}-python-${{ matrix.python }}-mambaforge-${{ matrix.mambaforge }}
137+
name: code-analysis-error-logs-java-${{ matrix.java }}-python-${{ matrix.python }}-mambaforge-${{ matrix.mambaforge }}
138138
path: |
139-
./temp/**/runtime/*
140-
./results
139+
temp/AxonFramework-${{ env.AXON_FRAMEWORK_VERSION }}/**/*.log
141140
retention-days: 5
142141

143142
# Upload successful results in case they are needed for troubleshooting

scripts/analysis/analyze.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131
# Requires setupNeo4j.sh,setupJQAssistant.sh,startNeo4j.sh,resetAndScanChanged.sh,prepareAnalysis.sh,stopNeo4j.sh,comilations/*.sh,profiles/*.sh
3232

33+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
34+
set -eo pipefail
35+
3336
# Overrideable variables with directory names
3437
REPORTS_SCRIPTS_DIRECTORY=${REPORTS_SCRIPTS_DIRECTORY:-"reports"} # Working directory containing the generated reports
3538
REPORT_COMPILATIONS_SCRIPTS_DIRECTORY=${REPORT_COMPILATIONS_SCRIPTS_DIRECTORY:-"compilations"} # Repository directory that contains scripts that execute selected report generation scripts
@@ -116,18 +119,18 @@ fi
116119

117120
# Execute the settings profile script that sets all the neccessary settings variables (overrideable by environment variables).
118121
echo "analyze: Using analysis settings profile script ${SETTINGS_PROFILE_SCRIPT}"
119-
source "${SETTINGS_PROFILE_SCRIPT}" || exit 2
122+
source "${SETTINGS_PROFILE_SCRIPT}"
120123

121124
# Setup Tools
122-
source "${SCRIPTS_DIR}/setupNeo4j.sh" || exit 3
123-
source "${SCRIPTS_DIR}/setupJQAssistant.sh" || exit 3
124-
source "${SCRIPTS_DIR}/startNeo4j.sh" || exit 3
125+
source "${SCRIPTS_DIR}/setupNeo4j.sh"
126+
source "${SCRIPTS_DIR}/setupJQAssistant.sh"
127+
source "${SCRIPTS_DIR}/startNeo4j.sh"
125128

126129
# Scan and analyze artifacts when they were changed
127-
source "${SCRIPTS_DIR}/resetAndScanChanged.sh" || exit 4
130+
source "${SCRIPTS_DIR}/resetAndScanChanged.sh"
128131

129132
# Prepare and validate graph database before analyzing and creating reports
130-
source "${SCRIPTS_DIR}/prepareAnalysis.sh" || exit 5
133+
source "${SCRIPTS_DIR}/prepareAnalysis.sh"
131134

132135
if ${exploreMode}; then
133136
echo "analyze: Explore mode activated. Report generation will be skipped. Neo4j keeps running."
@@ -138,7 +141,7 @@ fi
138141
# Create Reports
139142
#########################
140143
echo "analyze: Creating Reports with ${REPORT_COMPILATION_SCRIPT} ..."
141-
source "${REPORT_COMPILATION_SCRIPT}" || exit 6
144+
source "${REPORT_COMPILATION_SCRIPT}"
142145

143146
# Stop Neo4j at the end
144147
source "${SCRIPTS_DIR}/stopNeo4j.sh"

scripts/copyReportsIntoResults.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
# Requires generateJupyterReportReference.sh
1010

11+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
12+
set -eo pipefail
13+
1114
## Get this "scripts" directory if not already set
1215
# Even if $BASH_SOURCE is made for Bourne-like shells it is also supported by others and therefore here the preferred solution.
1316
# CDPATH reduces the scope of the cd command to potentially prevent unintended directory changes.

scripts/detectChangedArtifacts.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# The hash value is generated based on all files (their names and properties) within the artifacts directory.
55
# A change is detected when the current hash and the stored one differ.
66

7+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
8+
set -eo pipefail
9+
710
ARTIFACTS_DIRECTORY=${ARTIFACTS_DIRECTORY:-"artifacts"}
811
ARTIFACTS_CHANGE_DETECTION_HASH_FILE=${ARTIFACTS_CHANGE_DETECTION_HASH_FILE:-"artifactsChangeDetectionHash.txt"} # Name of the file that contains the hash code of the file list for change detection
912
ARTIFACTS_CHANGE_DETECTION_HASH_FILE_PATH="./${ARTIFACTS_DIRECTORY}/$ARTIFACTS_CHANGE_DETECTION_HASH_FILE"
@@ -16,7 +19,9 @@ fi
1619

1720
# Use find to list all files in the directory with their properties,
1821
# sort the output, and pipe it to md5 to create a hash
19-
CURRENT_ARTIFACTS_HASH="$( find "./$ARTIFACTS_DIRECTORY" -type f -not -name "${ARTIFACTS_CHANGE_DETECTION_HASH_FILE}" -exec stat -f "%N %p %z" {} + | sort | md5 -r )"
22+
# Use openssl md5 that is at least available on Mac and Linux.
23+
# See: https://github.com/TRON-US/go-btfs/issues/90#issuecomment-517409369
24+
CURRENT_ARTIFACTS_HASH="$( find "./$ARTIFACTS_DIRECTORY" -type f -not -name "${ARTIFACTS_CHANGE_DETECTION_HASH_FILE}" -exec openssl md5 -binary {} + | openssl md5 | awk '{print $2}' )"
2025

2126
# Assume that the files where changed if the file containing the hash of the file list does not exist yet.
2227
if [ ! -f "${ARTIFACTS_CHANGE_DETECTION_HASH_FILE_PATH}" ] ; then

scripts/documentation/appendEnvironmentVariables.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# Note: If called with "clear" instead of a filename then the generated markdown reference documentation file is deleted.
66
# This is helpful to start over with the generation of a new document.
77

8+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
9+
set -eo pipefail
10+
811
# Markdown file name
912
markdownFile="ENVIRONMENT_VARIABLES.md"
1013

scripts/documentation/generateCsvReportReference.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# Note: This script was generated by Chat-GPT after some messages back and forth:
66
# https://chat.openai.com/share/0bd3cde7-32d0-460d-830c-79b7d00a2492
77

8+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
9+
set -eo pipefail
10+
811
# Output Markdown file name
912
output_file="CSV_REPORTS.md"
1013

scripts/documentation/generateCypherReference.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# Generates "CYPHER.md" containing a reference to all Cypher files in this directory and its subdirectories.
44
# This script was generated by Chat-GPT after some messages back and forth and then tuned manually.
55

6+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
7+
set -eo pipefail
8+
69
# Markdown file name
710
markdown_file="CYPHER.md"
811

scripts/documentation/generateEnvironmentVariableReference.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
# Requires appendEnvironmentVariable.sh
66

7+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
8+
set -eo pipefail
9+
710
## Get this "scripts" directory if not already set
811
# Even if $BASH_SOURCE is made for Bourne-like shells it is also supported by others and therefore here the preferred solution.
912
# CDPATH reduces the scope of the cd command to potentially prevent unintended directory changes.

scripts/documentation/generateImageReference.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
# Generates "IMAGES.md" containing a reference to all images (PNG) in this directory and its subdirectories.
44

5+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
6+
set -eo pipefail
7+
58
# Markdown file name
69
markdown_file="IMAGES.md"
710

scripts/documentation/generateJupyterReportReference.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# Generates "JUPYTER_REPORTS.md" containing a reference to all Jupyter Notebook Markdown reports in this directory and its subdirectories.
44
# This script was generated by Chat-GPT after some messages back and forth and then tuned manually.
55

6+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
7+
set -eo pipefail
8+
69
# Markdown file name
710
markdown_file="JUPYTER_REPORTS.md"
811

0 commit comments

Comments
 (0)