Skip to content

Commit 72250c9

Browse files
authored
Merge pull request #306 from JohT/feature/provide-public-reusable-analysis-workflow
Provide re-useable public workflow for code graph analysis
2 parents 47f9df1 + 68de2d8 commit 72250c9

14 files changed

+561
-382
lines changed

.github/workflows/check-links-in-documentation.yml renamed to .github/workflows/internal-check-links-in-documentation.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
- 'README.md'
1010
- 'COMMANDS.md'
1111
- 'GETTING_STARTED.md'
12+
- 'INTEGRATION.md'
1213
- '.github/workflows/check-links-in-documentation.yml' # also run when this file was changed
1314
schedule:
1415
- cron: "15 6 1 * *" # On the first day of each month at 6:15 o'clock
@@ -36,6 +37,6 @@ jobs:
3637
3738
- name: Check links in top level documentation Markdown files
3839
if: ${{ ! env.skip_link_check}}
39-
run: npx --yes [email protected] --verbose --alive=200,202,206 --retry README.md COMMANDS.md GETTING_STARTED.md
40+
run: npx --yes [email protected] --verbose --alive=200,202,206 --retry README.md COMMANDS.md GETTING_STARTED.md INTEGRATION.md
4041
# Temporarily, everything is done using command line options rather than with the config file, which doesn't seem to work.
4142
# Maybe related to https://github.com/tcort/markdown-link-check/issues/379 ?
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
name: Java Code Structure Graph Analysis
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
# Ignore changes in documentation, general configuration and reports for push events
8+
paths-ignore:
9+
- 'results/**'
10+
- '**/*.md'
11+
- '**/*.txt'
12+
- '**/*.css'
13+
- '**/*.html'
14+
- '**/*.js'
15+
- '.gitignore'
16+
- '.gitattributes'
17+
- 'renovate.json'
18+
- 'changelogTemplate.mustache'
19+
- '**.code-workspace'
20+
- '.github/workflows/typescript-code-analysis.yml'
21+
- '.github/workflows/*documentation.yml'
22+
pull_request:
23+
branches:
24+
- main
25+
# Ignore changes in documentation, general configuration and reports for pull request events
26+
paths-ignore:
27+
- 'results/**'
28+
- '**/*.md'
29+
- '**/*.txt'
30+
- '**/*.css'
31+
- '**/*.html'
32+
- '**/*.js'
33+
- '.gitignore'
34+
- '.gitattributes'
35+
- 'renovate.json'
36+
- 'changelogTemplate.mustache'
37+
- '**.code-workspace'
38+
- '.github/workflows/typescript-code-analysis.yml'
39+
- '.github/workflows/*documentation.yml'
40+
41+
# Requires the secret NEO4J_INITIAL_PASSWORD to be configured
42+
jobs:
43+
prepare-code-to-analyze:
44+
runs-on: ubuntu-latest
45+
outputs:
46+
analysis-name: ${{ steps.set-analysis-name.outputs.analysis-name }}
47+
sources-upload-name: ${{ steps.set-sources-upload-name.outputs.sources-upload-name }}
48+
artifacts-upload-name: ${{ steps.set-artifacts-upload-name.outputs.artifacts-upload-name }}
49+
50+
env:
51+
PROJECT_NAME: AxonFramework
52+
# Version variable names matches renovate.json configuration entry
53+
AXON_FRAMEWORK_VERSION: 4.10.3
54+
55+
steps:
56+
- name: Checkout GIT Repository
57+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
58+
59+
- name: Set Set output variable 'analysis-name'
60+
id: set-analysis-name
61+
run: echo "analysis-name=${{ env.PROJECT_NAME }}-${{ env.AXON_FRAMEWORK_VERSION }}" >> "$GITHUB_OUTPUT"
62+
63+
- name: Setup temp directory if missing
64+
run: mkdir -p ./temp
65+
66+
- name: Download ${{ steps.set-analysis-name.outputs.analysis-name }}
67+
working-directory: temp
68+
run: |
69+
mkdir -p ${{ steps.set-analysis-name.outputs.analysis-name }}
70+
cd ${{ steps.set-analysis-name.outputs.analysis-name }}
71+
echo "Working directory: $( pwd -P )"
72+
./../../scripts/downloader/downloadAxonFramework.sh ${{ env.AXON_FRAMEWORK_VERSION }}
73+
74+
- name: Debug folder structure in temp directory
75+
if: runner.debug == '1'
76+
working-directory: temp
77+
run: |
78+
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
79+
80+
- name: (Prepare Code to Analyze) Generate ARTIFACT_UPLOAD_ID
81+
run: echo "ARTIFACT_UPLOAD_ID=$(LC_ALL=C tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 10)" >> $GITHUB_ENV
82+
83+
- name: (Prepare Code to Analyze) Set sources-upload-name
84+
id: set-sources-upload-name
85+
run: echo "sources-upload-name=${{ steps.set-analysis-name.outputs.analysis-name }}-analysis-sources_input-${{ env.ARTIFACT_UPLOAD_ID }}" >> "$GITHUB_OUTPUT"
86+
87+
- name: (Prepare Code to Analyze) Set output variable 'artifacts-upload-name'
88+
id: set-artifacts-upload-name
89+
run: echo "artifacts-upload-name=${{ steps.set-analysis-name.outputs.analysis-name }}-analysis-artifacts-input-${{ env.ARTIFACT_UPLOAD_ID }}" >> "$GITHUB_OUTPUT"
90+
91+
- name: (Prepare Code to Analyze) Upload sources to analyze
92+
if: success()
93+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
94+
with:
95+
name: ${{ steps.set-sources-upload-name.outputs.sources-upload-name }}
96+
path: ./temp/${{ steps.set-analysis-name.outputs.analysis-name }}/source
97+
include-hidden-files: true
98+
if-no-files-found: error
99+
retention-days: 1
100+
101+
- name: (Prepare Code to Analyze) Upload artifacts to analyze
102+
if: success()
103+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
104+
with:
105+
name: ${{ steps.set-artifacts-upload-name.outputs.artifacts-upload-name }}
106+
path: ./temp/${{ steps.set-analysis-name.outputs.analysis-name }}/artifacts
107+
if-no-files-found: error
108+
retention-days: 1
109+
110+
111+
112+
analyze-code-graph:
113+
needs: [prepare-code-to-analyze]
114+
uses: ./.github/workflows/public-analyze-code-graph.yml
115+
with:
116+
analysis-name: ${{ needs.prepare-code-to-analyze.outputs.analysis-name }}
117+
artifacts-upload-name: ${{ needs.prepare-code-to-analyze.outputs.artifacts-upload-name }}
118+
sources-upload-name: ${{ needs.prepare-code-to-analyze.outputs.sources-upload-name }}
119+
120+
121+
122+
commit-analysis-results:
123+
if: github.event_name == 'push'
124+
needs: [prepare-code-to-analyze, analyze-code-graph]
125+
runs-on: ubuntu-latest
126+
127+
env:
128+
CI_COMMIT_MESSAGE: Automated code structure analysis analysis-results (CI)
129+
CI_COMMIT_AUTHOR: ${{ github.event.repository.name }} Continuous Integration
130+
131+
steps:
132+
- name: Checkout GIT Repository
133+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
134+
with:
135+
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
136+
137+
- name: (Code Analysis Setup) Download source code and artifacts for analysis
138+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
139+
with:
140+
name: ${{ needs.analyze-code-graph.outputs.uploaded-analysis-results }}
141+
path: ./results/${{ needs.prepare-code-to-analyze.outputs.analysis-name }}
142+
143+
- name: Commit "results" directory containing the reports
144+
# Only run when a pull request gets merged or a commit is pushed to the main branch
145+
# git add parameters need to match paths-ignore parameters above
146+
# Git pull before add/commit/push to reduce race conditions on parallel builds
147+
run: |
148+
git config --global user.name '${{ env.CI_COMMIT_AUTHOR }}'
149+
git config --global user.email "[email protected]"
150+
git config --local http.postBuffer 524288000
151+
git fetch origin
152+
git status
153+
git add results
154+
git status
155+
git commit -m "${{ env.CI_COMMIT_MESSAGE }}"
156+
git status
157+
git rebase --strategy-option=theirs origin/main --verbose
158+
git status
159+
git push --verbose
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
name: Typescript Code Structure Graph Analysis
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
# Ignore changes in documentation, general configuration and reports for push events
8+
paths-ignore:
9+
- 'results/**'
10+
- '**/*.md'
11+
- '**/*.txt'
12+
- '**/*.css'
13+
- '**/*.html'
14+
- '**/*.js'
15+
- '.gitignore'
16+
- '.gitattributes'
17+
- 'renovate.json'
18+
- 'changelogTemplate.mustache'
19+
- '**.code-workspace'
20+
- '.github/workflows/java-code-analysis.yml'
21+
- '.github/workflows/*documentation.yml'
22+
pull_request:
23+
branches:
24+
- main
25+
# Ignore changes in documentation, general configuration and reports for pull request events
26+
paths-ignore:
27+
- 'results/**'
28+
- '**/*.md'
29+
- '**/*.txt'
30+
- '**/*.css'
31+
- '**/*.html'
32+
- '**/*.js'
33+
- '.gitignore'
34+
- '.gitattributes'
35+
- 'renovate.json'
36+
- 'changelogTemplate.mustache'
37+
- '**.code-workspace'
38+
- '.github/workflows/java-code-analysis.yml'
39+
- '.github/workflows/*documentation.yml'
40+
41+
jobs:
42+
43+
prepare-code-to-analyze:
44+
runs-on: ubuntu-latest
45+
outputs:
46+
analysis-name: ${{ steps.set-analysis-name.outputs.analysis-name }}
47+
sources-upload-name: ${{ steps.set-sources-upload-name.outputs.sources-upload-name }}
48+
49+
env:
50+
PROJECT_NAME: react-router
51+
# Version variable name matches renovate.json configuration entry
52+
REACT_ROUTER_VERSION: 6.28.1
53+
54+
steps:
55+
- name: (Prepare Code to Analyze) Checkout GIT repository
56+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
57+
58+
59+
- name: Set Set output variable 'analysis-name'
60+
id: set-analysis-name
61+
run: echo "analysis-name=${{ env.PROJECT_NAME }}-${{ env.REACT_ROUTER_VERSION }}" >> "$GITHUB_OUTPUT"
62+
63+
- name: Setup temp directory if missing
64+
run: mkdir -p ./temp
65+
66+
- name: Setup Cache for "temp/downloads" folder
67+
uses: actions/cache@v4
68+
with:
69+
path: ./temp/downloads
70+
key:
71+
${{ runner.os }}-${{ hashFiles('**/*.sh') }}
72+
73+
- name: Download ${{ steps.set-analysis-name.outputs.analysis-name }}
74+
working-directory: temp
75+
run: |
76+
mkdir -p ${{ steps.set-analysis-name.outputs.analysis-name }}
77+
cd ${{ steps.set-analysis-name.outputs.analysis-name }}
78+
echo "Working directory: $( pwd -P )"
79+
./../../scripts/downloader/downloadReactRouter.sh ${{ env.REACT_ROUTER_VERSION }}
80+
81+
- name: (Prepare Code to Analyze) Setup pnpm for react-router
82+
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
83+
with:
84+
package_json_file: temp/${{ steps.set-analysis-name.outputs.analysis-name }}/source/${{ steps.set-analysis-name.outputs.analysis-name }}/package.json
85+
86+
- name: (Prepare Code to Analyze) Install dependencies with pnpm
87+
working-directory: temp/${{ steps.set-analysis-name.outputs.analysis-name }}/source/${{ steps.set-analysis-name.outputs.analysis-name }}
88+
run: pnpm install --frozen-lockfile --strict-peer-dependencies
89+
90+
- name: Debug folder structure in temp directory
91+
if: runner.debug == '1'
92+
working-directory: temp
93+
run: |
94+
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
95+
96+
- name: (Prepare Code to Analyze) Generate ARTIFACT_UPLOAD_ID
97+
run: echo "ARTIFACT_UPLOAD_ID=$(LC_ALL=C tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 10)" >> $GITHUB_ENV
98+
99+
- name: (Prepare Code to Analyze) Set sources-upload-name
100+
id: set-sources-upload-name
101+
run: echo "sources-upload-name=${{ steps.set-analysis-name.outputs.analysis-name }}-analysis-sources_input-${{ env.ARTIFACT_UPLOAD_ID }}" >> "$GITHUB_OUTPUT"
102+
103+
- name: (Prepare Code to Analyze) Upload code to analyze
104+
if: success()
105+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
106+
with:
107+
name: ${{ steps.set-sources-upload-name.outputs.sources-upload-name }}
108+
path: ./temp/${{ steps.set-analysis-name.outputs.analysis-name }}/source
109+
if-no-files-found: error
110+
retention-days: 1
111+
112+
113+
114+
analyze-code-graph:
115+
needs: [prepare-code-to-analyze]
116+
uses: ./.github/workflows/public-analyze-code-graph.yml
117+
with:
118+
analysis-name: ${{ needs.prepare-code-to-analyze.outputs.analysis-name }}
119+
sources-upload-name: ${{ needs.prepare-code-to-analyze.outputs.sources-upload-name }}
120+
121+
122+
123+
commit-analysis-results:
124+
if: github.event_name == 'push'
125+
needs: [prepare-code-to-analyze, analyze-code-graph]
126+
runs-on: ubuntu-latest
127+
128+
env:
129+
CI_COMMIT_MESSAGE: Automated code structure analysis analysis-results (CI)
130+
CI_COMMIT_AUTHOR: ${{ github.event.repository.name }} Continuous Integration
131+
132+
steps:
133+
- name: Checkout GIT Repository
134+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
135+
with:
136+
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
137+
138+
- name: (Code Analysis Setup) Download source code and artifacts for analysis
139+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
140+
with:
141+
name: ${{ needs.analyze-code-graph.outputs.uploaded-analysis-results }}
142+
path: results/${{ needs.prepare-code-to-analyze.outputs.analysis-name }}
143+
144+
- name: Commit "results" directory containing the reports
145+
# Only run when a pull request gets merged or a commit is pushed to the main branch
146+
# git add parameters need to match paths-ignore parameters above
147+
# Git pull before add/commit/push to reduce race conditions on parallel builds
148+
run: |
149+
git config --global user.name '${{ env.CI_COMMIT_AUTHOR }}'
150+
git config --global user.email "[email protected]"
151+
git config --local http.postBuffer 524288000
152+
git fetch origin
153+
git status
154+
git add results
155+
git status
156+
git commit -m "${{ env.CI_COMMIT_MESSAGE }}"
157+
git status
158+
git rebase --strategy-option=theirs origin/main --verbose
159+
git status
160+
git push --verbose

0 commit comments

Comments
 (0)