Skip to content

Commit 792f627

Browse files
committed
Move report reference document generation into a separate action
1 parent f6d4a1b commit 792f627

File tree

3 files changed

+92
-10
lines changed

3 files changed

+92
-10
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Generate report reference documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'results/**' # Only run results have been updates
9+
- '!results/*.md' # Ignore when report reference documentation itself changes
10+
- '.github/workflows/report-reference-documentation.yml' # or when this file was changed
11+
pull_request:
12+
branches:
13+
- main
14+
paths:
15+
- 'results/**' # Only run results have been updates
16+
- '!results/*.md' # Ignore when report reference documentation itself changes
17+
- '.github/workflows/report-reference-documentation.yml' # or when this file was changed
18+
19+
jobs:
20+
reports:
21+
runs-on: ubuntu-latest
22+
env:
23+
CI_COMMIT_MESSAGE: Automated report reference document generation (CI)
24+
CI_COMMIT_AUTHOR: ${{ github.event.repository.name }} Continuous Integration
25+
26+
steps:
27+
- name: Checkout git repository
28+
uses: actions/checkout@v4
29+
with:
30+
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
31+
32+
- name: Generate report reference document
33+
working-directory: results
34+
run: |
35+
./../scripts/documentation/generateReportReferences.sh
36+
37+
- name: Use git to detect changes in the regenerated documenta and set generated_document_changed
38+
run: git diff --quiet || echo "generated_document_changed=true" >> $GITHUB_ENV
39+
40+
- name: Display generated_document_changed
41+
run: echo "generated_document_changed=${{ env.generated_document_changed}}"
42+
43+
- name: Archive generated report reference document
44+
if: env.generated_document_changed
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: report-reference-document
48+
path: ./results/*.md
49+
if-no-files-found: error
50+
retention-days: 5
51+
52+
- name: Commit generated report reference document if there were changes
53+
# Only run when a pull request gets merged or a commit is pushed to the main branch.
54+
# And only run when the generated document changed to avoid an empty commit or an error while committing.
55+
if: github.event_name == 'push' && env.generated_document_changed
56+
run: |
57+
git config --global user.name '${{ env.CI_COMMIT_AUTHOR }}'
58+
git config --global user.email '[email protected]'
59+
set -o errexit -o pipefail -o xtrace
60+
git add ./results/*.md
61+
git status
62+
git commit -m "${{ env.CI_COMMIT_MESSAGE }}"
63+
git status
64+
git push --verbose

scripts/copyReportsIntoResults.sh

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,4 @@ for report_source_folder in **/"${REPORTS_DIRECTORY}"; do
4141

4242
rm -rf "${reportTargetDirectory}"
4343
cp -Rp "${report_source_folder}" "${reportTargetDirectory}"
44-
done
45-
46-
# Generate JUPYTER_REPORTS.md containing a reference to all Jupyter Notebook Markdown reports in the "results" directory and its subdirectories.
47-
(cd "./../${RESULTS_DIRECTORY}" && exec "${SCRIPTS_DIR}/documentation/generateJupyterReportReference.sh")
48-
49-
# Generate CSV_REPORTS.md containing a reference to all CSV cypher query reports in the "results" directory and its subdirectories.
50-
(cd "./../${RESULTS_DIRECTORY}" && exec "${SCRIPTS_DIR}/documentation/generateCsvReportReference.sh")
51-
52-
# Generate IMAGES.md containing a reference to all PNG images in the "results" directory and its subdirectories.
53-
(cd "./../${RESULTS_DIRECTORY}" && exec "${SCRIPTS_DIR}/documentation/generateImageReference.sh")
44+
done
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)