Skip to content

Commit 2751ae0

Browse files
committed
Generate analysis results references documentation
1 parent 4da7f9e commit 2751ae0

File tree

9 files changed

+329
-0
lines changed

9 files changed

+329
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Generate report reference documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "analysis-results/**" # Only run on changed analysis results
9+
- "!analysis-results/*.md" # Ignore report reference documentation changes (endless loop prevention)
10+
- ".github/workflows/internal-report-reference-documentation.yml" # Also run when this file was changed
11+
pull_request:
12+
branches:
13+
- main
14+
paths:
15+
- "analysis-results/**" # Only run on changed analysis results
16+
- "!analysis-results/*.md" # Ignore report reference documentation changes (endless loop prevention)
17+
- ".github/workflows/internal-report-reference-documentation.yml" # Also run when this file was changed
18+
19+
jobs:
20+
generate-report-reference-documentation:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
generated_documents_changed: ${{ steps.set-generated_documents_changed.outputs.generated_documents_changed }}
24+
documentation-upload-name: ${{ steps.set-documentation-upload-name.outputs.documentation-upload-name }}
25+
26+
steps:
27+
- name: Checkout git repository
28+
uses: actions/checkout@v4
29+
30+
- name: Generate report reference document
31+
working-directory: analysis-results
32+
run: |
33+
./../documentation/analysis-reports-reference/generateReportReferences.sh
34+
35+
- name: Use git to detect changes in the regenerated documentation and set generated_documents_changed
36+
working-directory: analysis-results
37+
id: set-generated_documents_changed
38+
run: |
39+
git add -N *.md # Add all new files to the index so that git diff also works for newly generated files
40+
git diff --quiet || echo "generated_documents_changed=true" >> "$GITHUB_OUTPUT"
41+
git --no-pager diff --name-only
42+
43+
- name: Display generated_documents_changed
44+
run: echo "generated_documents_changed=${{ steps.set-generated_documents_changed.outputs.generated_documents_changed }}"
45+
46+
- name: Generate ARTIFACT_UPLOAD_ID
47+
if: steps.set-generated_documents_changed.outputs.generated_documents_changed == 'true'
48+
run: echo "ARTIFACT_UPLOAD_ID=$(LC_ALL=C tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 10)" >> $GITHUB_ENV
49+
50+
- name: Set documentation-upload-name
51+
if: steps.set-generated_documents_changed.outputs.generated_documents_changed == 'true'
52+
id: set-documentation-upload-name
53+
run: echo "documentation-upload-name=report-reference-documentation-${{ env.ARTIFACT_UPLOAD_ID }}" >> "$GITHUB_OUTPUT"
54+
55+
- name: Archive generated report references documents
56+
if: steps.set-generated_documents_changed.outputs.generated_documents_changed == 'true'
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: ${{ steps.set-documentation-upload-name.outputs.documentation-upload-name }}
60+
path: ./analysis-results/*.md
61+
if-no-files-found: error
62+
retention-days: 5
63+
64+
65+
commit-analysis-results:
66+
name: Commit Analysis Results
67+
needs: [generate-report-reference-documentation]
68+
uses: ./.github/workflows/internal-commit-results.yml
69+
if: needs.generate-report-reference-documentation.outputs.generated_documents_changed == 'true'
70+
with:
71+
commit-author-name: "${{ github.event.repository.name }} Continuous Integration"
72+
commit-author-email: "7671054+JohT@users.noreply.github.com"
73+
commit-message: "Automated code structure analysis results (CI)"
74+
commit-directory: "./analysis-results/*.md"
75+
uploaded-artifact-name: ${{ needs.generate-report-reference-documentation.outputs.documentation-upload-name }}
76+
secrets:
77+
repository-commit-token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
# Ignore changes in documentation, general configuration and analysis-results for push events
88
paths-ignore:
99
- 'analysis-results/**'
10+
- 'documentation/**'
1011
- '**/*.md'
1112
- '**/*.txt'
1213
- '**/*.css'
@@ -24,6 +25,7 @@ on:
2425
# Ignore changes in documentation, general configuration and analysis-results for pull request events
2526
paths-ignore:
2627
- 'analysis-results/**'
28+
- 'documentation/**'
2729
- '**/*.md'
2830
- '**/*.txt'
2931
- '**/*.css'

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
# Ignore changes in documentation, general configuration and analysis-results for push events
88
paths-ignore:
99
- 'analysis-results/**'
10+
- 'documentation/**'
1011
- '**/*.md'
1112
- '**/*.txt'
1213
- '**/*.css'
@@ -24,6 +25,7 @@ on:
2425
# Ignore changes in documentation, general configuration and analysis-results for pull request events
2526
paths-ignore:
2627
- 'analysis-results/**'
28+
- 'documentation/**'
2729
- '**/*.md'
2830
- '**/*.txt'
2931
- '**/*.css'

COMMANDS.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Code Graph Analysis Pipeline - Commands
2+
3+
<!-- TOC -->
4+
5+
- [Generate Markdown References](#generate-markdown-references)
6+
- [Generate CSV Cypher Query Results Report Reference](#generate-csv-cypher-query-results-report-reference)
7+
- [Generate Jupyter Notebook Report Reference](#generate-jupyter-notebook-report-reference)
8+
- [Generate Image Reference](#generate-image-reference)
9+
10+
<!-- /TOC -->
11+
12+
## Generate Markdown References
13+
14+
### Generate CSV Cypher Query Results Report Reference
15+
16+
Change into the [analysis-results](./analysis-results/) directory e.g. with `cd analysis-results` and then execute the script [generateCsvReportReference.sh](./documentation/analysis-reports-reference/generateCsvReportReference.sh) with the following command:
17+
18+
👉**Note:** This script is automatically triggered in the pipeline [internal-report-reference-documentation.yml](.github/workflows/internal-report-reference-documentation.yml) and doesn't need to be executed manually normally.
19+
20+
```script
21+
./../documentation/analysis-reports-reference/generateCsvReportReference.sh
22+
```
23+
24+
### Generate Jupyter Notebook Report Reference
25+
26+
Change into the [analysis-results](./analysis-results/) directory e.g. with `cd analysis-results` and then execute the script [generateJupyterReportReference.sh](./documentation/analysis-reports-reference/generateJupyterReportReference.sh) with the following command:
27+
28+
👉**Note:** This script is automatically triggered in the pipeline [internal-report-reference-documentation.yml](.github/workflows/internal-report-reference-documentation.yml) and doesn't need to be executed manually normally.
29+
30+
```script
31+
./../documentation/analysis-reports-reference/generateJupyterReportReference.sh
32+
```
33+
34+
### Generate Image Reference
35+
36+
Change into the [analysis-results](./analysis-results/) directory e.g. with `cd analysis-results` and then execute the script [generateImageReference.sh](./documentation/analysis-reports-reference/generateImageReference.sh) with the following command:
37+
38+
👉**Note:** This script is automatically triggered in the pipeline [internal-report-reference-documentation.yml](.github/workflows/internal-report-reference-documentation.yml) and doesn't need to be executed manually normally.
39+
40+
```script
41+
./../documentation/analysis-reports-reference/generateImageReference.sh
42+
```

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ Here are ten examples from over a hundred reports generated by the analysis. The
8383
8484
<img src="./analysis-results/AxonFramework/AxonFramework-4.10.3/wordcloud/Wordcloud_files/Wordcloud_17_0.png" width="600" alt="Word cloud of git authors">
8585
86+
## :page_with_curl: CSV Cypher Query Report Reference
87+
88+
[CSV_REPORTS.md](./analysis-results/CSV_REPORTS.md) lists all CSV Cypher query result reports inside the [results](./results) directory. It can be generated as described in [Generate CSV Report Reference](./COMMANDS.md#generate-csv-cypher-query-report-reference).
89+
90+
## :page_with_curl: Jupyter Notebook Report Reference
91+
92+
[JUPYTER_REPORTS.md](./analysis-results/JUPYTER_REPORTS.md) lists all Jupyter Notebook reports inside the [results](./results) directory. It can be generated as described in [Generate Jupyter Notebook Report Reference](./COMMANDS.md#generate-jupyter-notebook-report-reference).
93+
94+
## :camera: Image Reference
95+
96+
[IMAGES.md](./analysis-results/IMAGES.md) lists all PNG images inside the [results](./results) directory. It can be generated as described in [Generate Image Reference](./COMMANDS.md#generate-image-reference).
97+
8698
## Keeping the Analysis Workflow Updated with Renovate
8799
88100
This repository uses [Renovate](https://docs.renovatebot.com) to automatically update the analysis workflow to the latest version. To enable this, add the following extension to your Renovate configuration:
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
3+
# Generates "CSV_REPORTS.md" containing a reference to all CSV cypher query reports in this directory and its subdirectories.
4+
5+
# Note: This script was generated by Chat-GPT after some messages back and forth:
6+
# https://chat.openai.com/share/0bd3cde7-32d0-460d-830c-79b7d00a2492
7+
8+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
9+
set -o errexit -o pipefail
10+
11+
# Output Markdown file name
12+
markdown_file="CSV_REPORTS.md"
13+
14+
# Function to count rows in a CSV file
15+
count_rows() {
16+
wc -l < "$1"
17+
}
18+
19+
# Function to extract the source query name from CSV header
20+
get_source_query() {
21+
header=$(head -n 1 "$1")
22+
source_query=$(echo "$header" | sed -n 's/.*Source Cypher File: \(.*\)"/\1/p')
23+
echo "$source_query"
24+
}
25+
26+
echo "generateCsvReportReference: Generating ${markdown_file}..."
27+
28+
# Create the Markdown header
29+
{
30+
echo "# CSV Cypher Query Result Reports Reference"
31+
echo ""
32+
echo "This document lists all CSV Cypher query result reports found in the current directory and its subdirectories."
33+
echo "Each entry in the table below includes the file name, the analysis type, the number of rows in the CSV, and the source Cypher query."
34+
echo "This file was automatically generated using the [generateCsvReportReference](./../documentation/analysis-reports-reference/generateCsvReportReference.sh) script."
35+
echo ""
36+
# Create the Markdown table header
37+
echo "| CSV File | Analysis | Number of Rows | Source Query |"
38+
echo "| -------- | -------- | -------------- | ------------ |"
39+
} > "$markdown_file"
40+
41+
# Find and process CSV files
42+
find . -type f -name "*.csv" | sort | while IFS= read -r csv_file; do
43+
num_rows=$(count_rows "$csv_file")
44+
source_query=$(get_source_query "$csv_file")
45+
46+
# Get the main directory name
47+
main_dir=$(dirname "$csv_file" | cut -d '/' -f 3)
48+
49+
# Get the base name of the file
50+
base_name=$(basename "$csv_file")
51+
52+
# Escape special characters for Markdown
53+
csv_link=$(echo "$csv_file" | sed 's/\[/\\[/g; s/\]/\\]/g')
54+
55+
# Create a link to the source query
56+
source_query_link="./../cypher/$source_query"
57+
58+
# Append a new row to the Markdown table
59+
echo "| [$base_name]($csv_link) | $main_dir | $num_rows | [$source_query]($source_query_link) |" >> "$markdown_file"
60+
done
61+
62+
echo "generateCsvReportReference: Successfully generated ${markdown_file}."
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
3+
# Generates "IMAGES.md" containing a reference to all images (PNG) in this directory and its subdirectories.
4+
5+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
6+
set -o errexit -o pipefail
7+
8+
# Markdown file name
9+
markdown_file="IMAGES.md"
10+
11+
echo "generateImageReference: Generating ${markdown_file}..."
12+
13+
{
14+
echo "# Image Reference"
15+
echo ""
16+
echo "This document serves as a reference for all images (PNG) in the current directory and its subdirectories."
17+
echo "It provides a table listing each file and the analysis it belongs to."
18+
echo "This file was generated with the script [generateImageReference.sh](./../documentation/analysis-reports-reference/generateImageReference.sh)."
19+
echo ""
20+
echo "Image | Analysis |"
21+
echo "-------|----------|"
22+
} > ${markdown_file}
23+
24+
# Loop through all Markdown files in the current directory
25+
find . -type f -name "*.png" | sort | while read -r image_file; do
26+
# Trim leading and trailing whitespace
27+
description=$(echo "${description}" | awk '{$1=$1;print}')
28+
29+
# Extract the script file name without the path
30+
filename=$(basename "$image_file")
31+
32+
if [ "$filename" = "${markdown_file}" ]; then
33+
continue
34+
fi
35+
36+
# Extract the script file path without the name
37+
pathname=$(dirname "$image_file")
38+
39+
# Extract the second part of the path after ./ that contains the analysis directory name
40+
analysisname=$(echo "${pathname}" | cut -d/ -f 3)
41+
42+
# Create a link to the script file in the table
43+
link="[${filename}](${image_file})"
44+
45+
# Add the script file and its description to the Markdown table
46+
echo "| ${link} | ${analysisname%%.} |" >> ${markdown_file}
47+
done
48+
49+
echo "generateImageReference: Successfully generated ${markdown_file}."
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
3+
# Generates "JUPYTER_REPORTS.md" containing a reference to all Jupyter Notebook Markdown reports in this directory and its subdirectories.
4+
# This script was generated by Chat-GPT after some messages back and forth and then tuned manually.
5+
6+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
7+
set -o errexit -o pipefail
8+
9+
# Markdown file name
10+
markdown_file="JUPYTER_REPORTS.md"
11+
12+
echo "generateJupyterReportReference: Generating ${markdown_file}..."
13+
14+
{
15+
echo "# Jupyter Notebook Reports Reference"
16+
echo ""
17+
echo "This document serves as a reference for all Jupyter Notebook reports in the current directory and its subdirectories."
18+
echo "It provides a table listing each file and its corresponding description found in the first header line."
19+
echo "This file was generated with the script [generateJupyterReportReference.sh](./../documentation/analysis-reports-reference/generateJupyterReportReference.sh)."
20+
echo ""
21+
echo "Report | Analysis | Description"
22+
echo "-------|----------|------------"
23+
} > ${markdown_file}
24+
25+
# Loop through all Markdown files in the current directory
26+
find . -type f -name "*.md" | sort | while read -r report_file; do
27+
# Extract the first non-empty line that starts with '#'
28+
report_file_header_line=$(grep -m 1 -e '^#\+.*' "${report_file}")
29+
30+
# Remove leading '#' characters and trim leading/trailing spaces
31+
description=$(echo "${report_file_header_line}" | sed -E 's/^#+\s*//')
32+
33+
# Trim leading and trailing whitespace
34+
description=$(echo "${description}" | awk '{$1=$1;print}')
35+
36+
# Extract the script file name without the path
37+
filename=$(basename "$report_file")
38+
39+
if [ "$filename" = "${markdown_file}" ]; then
40+
continue
41+
fi
42+
43+
# Extract the script file path without the name
44+
pathname=$(dirname "$report_file")
45+
46+
# Extract the second part of the path after ./ that contains the analysis directory name
47+
analysisname=$(echo "${pathname}" | cut -d/ -f 3)
48+
49+
# Create a link to the script file in the table
50+
link="[${filename}](${report_file})"
51+
52+
# Add the script file and its description to the Markdown table
53+
echo "| ${link} | ${analysisname%%.} | ${description} |" >> ${markdown_file}
54+
done
55+
56+
echo "generateJupyterReportReference: Successfully generated ${markdown_file}."
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
# Triggers the regeneration of all reference documentations for the reports inside the "results" directory.
4+
# The generation to the reference documentations is delegated to the dedicated scripts.
5+
6+
# Notice that this scripts needs to be executed within the "results" directory.
7+
8+
# Requires generateJupyterReportReference.sh, generateCsvReportReference.sh, generateImageReference.sh
9+
10+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
11+
set -o errexit -o pipefail
12+
13+
## Get this "scripts" directory if not already set
14+
# Even if $BASH_SOURCE is made for Bourne-like shells it is also supported by others and therefore here the preferred solution.
15+
# CDPATH reduces the scope of the cd command to potentially prevent unintended directory changes.
16+
# This way non-standard tools like readlink aren't needed.
17+
DOCUMENTATION_SCRIPT_DIR=${DOCUMENTATION_SCRIPT_DIR:-$( CDPATH=. cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P )} # Repository directory containing the shell scripts
18+
echo "generateReportReferences: SCRIPTS_DIR=${DOCUMENTATION_SCRIPT_DIR}"
19+
20+
# Generate JUPYTER_REPORTS.md containing a reference to all Jupyter Notebook Markdown reports in the "results" directory and its subdirectories.
21+
source "${DOCUMENTATION_SCRIPT_DIR}/generateJupyterReportReference.sh"
22+
23+
# Generate CSV_REPORTS.md containing a reference to all CSV cypher query reports in the "results" directory and its subdirectories.
24+
source "${DOCUMENTATION_SCRIPT_DIR}/generateCsvReportReference.sh"
25+
26+
# Generate IMAGES.md containing a reference to all PNG images in the "results" directory and its subdirectories.
27+
source "${DOCUMENTATION_SCRIPT_DIR}/generateImageReference.sh"

0 commit comments

Comments
 (0)