Skip to content

Commit 7a0276a

Browse files
committed
Share common analysis setup
1 parent a72caa4 commit 7a0276a

File tree

3 files changed

+131
-123
lines changed

3 files changed

+131
-123
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: 'Setup Code Graph Analysis'
2+
description: 'Sets up Code Graph Analysis with code-graph-analysis-pipeline'
3+
inputs:
4+
java-version:
5+
description: "The java version (temurin distribution) to use for packaging the plugin"
6+
required: true
7+
python-version:
8+
description: "The version of Python to use for the conda environment"
9+
required: true
10+
miniforge-version:
11+
description: "The version of MiniForge to use for the conda environment"
12+
required: true
13+
analysis-name:
14+
description: "The name of the project to analyze. E.g. MyProject-1.0.0"
15+
required: true
16+
neo4j-password:
17+
description: "The password to use to replace the initial one"
18+
required: true
19+
20+
runs:
21+
using: "composite"
22+
steps:
23+
- name: Checkout code-graph-analysis-pipeline
24+
uses: actions/checkout@v4
25+
with:
26+
repository: JohT/code-graph-analysis-pipeline
27+
ref: 41f3e22b5bd65351474dd23effeee91fab849a12
28+
path: code-graph-analysis-pipeline
29+
persist-credentials: false
30+
31+
- name: (Java Setup) Use Java Development Kit (JDK) ${{ inputs.java-version }}
32+
uses: actions/setup-java@v4
33+
with:
34+
distribution: 'adopt'
35+
java-version: ${{ inputs.java-version }}
36+
37+
# "Setup Python" can be skipped if jupyter notebook analysis-results aren't needed
38+
- name: (Python Setup) Setup Cache for Conda package manager Miniforge
39+
uses: actions/cache@v4
40+
env:
41+
# Increase this value to reset cache if etc/example-environment.yml has not changed
42+
# Reference: https://github.com/conda-incubator/setup-miniconda#caching
43+
CACHE_NUMBER: 0
44+
with:
45+
path: ~/conda_pkgs_dir
46+
key:
47+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-environments-${{hashFiles('**/environment.yml', '.github/workflows/*.yml') }}
48+
49+
- name: (Python Setup) Use version ${{ inputs.python-version }} with Conda package manager Miniforge
50+
uses: conda-incubator/setup-miniconda@v3
51+
with:
52+
python-version: ${{ inputs.python-version }}
53+
miniforge-version: ${{ inputs.miniforge-version }}
54+
activate-environment: codegraph
55+
environment-file: ./code-graph-analysis-pipeline/jupyter/environment.yml
56+
auto-activate-base: false
57+
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
58+
- name: (Python Setup) Conda environment info
59+
shell: bash -el {0}
60+
run: conda info
61+
62+
- name: (Code Analysis Setup) Add code-graph-analysis-pipeline temporarily to .gitignore
63+
shell: bash
64+
run: |
65+
echo "" >> .gitignore
66+
echo "# Code Graph Analysis Pipeline" >> .gitignore
67+
echo "code-graph-analysis-pipeline/" >> .gitignore
68+
69+
- name: (Code Analysis Setup) Setup Cache Analysis Downloads
70+
uses: actions/cache@v4
71+
with:
72+
path: ./code-graph-analysis-pipeline/temp/downloads
73+
key:
74+
${{ runner.os }}-${{ hashFiles('**/*.sh') }}
75+
76+
# - name: (Code Analysis Setup) Generate NEO4J_INITIAL_PASSWORD
77+
# shell: bash
78+
# run: echo "NEO4J_INITIAL_PASSWORD=$(LC_ALL=C tr -dc 'A-Za-z0-9!?%=' < /dev/urandom | head -c 10)" >> $GITHUB_ENV
79+
80+
- name: (Code Analysis) Initialize Analysis
81+
shell: bash
82+
working-directory: code-graph-analysis-pipeline
83+
env:
84+
NEO4J_INITIAL_PASSWORD: ${{ inputs.neo4j-password }}
85+
run: ./init.sh ${{ inputs.analysis-name }}

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

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -61,79 +61,34 @@ jobs:
6161
with:
6262
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
6363

64-
- name: Checkout code-graph-analysis-pipeline
65-
uses: actions/checkout@v4
66-
with:
67-
repository: JohT/code-graph-analysis-pipeline
68-
ref: 41f3e22b5bd65351474dd23effeee91fab849a12
69-
path: code-graph-analysis-pipeline
70-
persist-credentials: false
64+
- name: (Code Analysis Setup) Set ANALYSIS_NAME
65+
run: echo "ANALYSIS_NAME=${{ env.PROJECT_NAME }}-${{ env.AXON_FRAMEWORK_VERSION }}" >> $GITHUB_ENV
7166

72-
- name: (Java Setup) Use Java Development Kit (JDK) ${{ matrix.java }}
73-
uses: actions/setup-java@v4
67+
- name: Setup Code Analysis
68+
uses: ./.github/actions/setup-code-analysis
7469
with:
75-
distribution: 'adopt'
7670
java-version: ${{ matrix.java }}
77-
78-
# "Setup Python" can be skipped if jupyter notebook analysis-results aren't needed
79-
- name: (Python Setup) Setup Cache for Conda package manager Miniforge
80-
uses: actions/cache@v4
81-
env:
82-
# Increase this value to reset cache if etc/example-environment.yml has not changed
83-
# Reference: https://github.com/conda-incubator/setup-miniconda#caching
84-
CACHE_NUMBER: 0
85-
with:
86-
path: ~/conda_pkgs_dir
87-
key:
88-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-environments-${{hashFiles('**/environment.yml', '.github/workflows/*.yml') }}
89-
- name: (Python Setup) Use version ${{ matrix.python }} with Conda package manager Miniforge
90-
uses: conda-incubator/setup-miniconda@v3
91-
with:
9271
python-version: ${{ matrix.python }}
9372
miniforge-version: ${{ matrix.miniforge }}
94-
activate-environment: codegraph
95-
environment-file: ./code-graph-analysis-pipeline/jupyter/environment.yml
96-
auto-activate-base: false
97-
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
98-
- name: (Python Setup) Conda environment info
99-
shell: bash -el {0}
100-
run: conda info
101-
102-
- name: (Code Analysis Setup) Add code-graph-analysis-pipeline temporarily to .gitignore
103-
run: |
104-
echo "" >> .gitignore
105-
echo "# Code Graph Analysis Pipeline" >> .gitignore
106-
echo "code-graph-analysis-pipeline/" >> .gitignore
107-
- name: (Code Analysis Setup) Set ANALYSIS_NAME
108-
run: echo "ANALYSIS_NAME=${{ env.PROJECT_NAME }}-${{ env.AXON_FRAMEWORK_VERSION }}" >> $GITHUB_ENV
109-
- name: (Code Analysis Setup) Generate NEO4J_INITIAL_PASSWORD
110-
run: echo "NEO4J_INITIAL_PASSWORD=$(LC_ALL=C tr -dc 'A-Za-z0-9!?%=' < /dev/urandom | head -c 10)" >> $GITHUB_ENV
111-
- name: (Code Analysis Setup) Setup Cache Analysis Downloads
112-
uses: actions/cache@v4
113-
with:
114-
path: ./code-graph-analysis-pipeline/temp/downloads
115-
key:
116-
${{ runner.os }}-${{ hashFiles('**/*.sh') }}
73+
analysis-name: ${{ env.ANALYSIS_NAME }}
74+
neo4j-password: ${{ secrets.NEO4J_INITIAL_PASSWORD }}
11775

118-
- name: (Code Analysis) Initialize Analysis
119-
working-directory: code-graph-analysis-pipeline
120-
env:
121-
NEO4J_INITIAL_PASSWORD: ${{ env.NEO4J_INITIAL_PASSWORD }}
122-
run: ./init.sh ${{ env.ANALYSIS_NAME }}
12376
- name: (Code Analysis) Download ${{ env.ANALYSIS_NAME }}
12477
working-directory: code-graph-analysis-pipeline/temp/${{ env.ANALYSIS_NAME }}
12578
run: |
12679
./../../scripts/downloader/downloadAxonFramework.sh ${{ env.AXON_FRAMEWORK_VERSION }}
80+
12781
- name: (Code Analysis) Analyze ${{ env.ANALYSIS_NAME }}
12882
working-directory: code-graph-analysis-pipeline/temp/${{ env.ANALYSIS_NAME }}
12983
# Shell type can be skipped if jupyter notebook analysis-results (and therefore conda) aren't needed
13084
shell: bash -el {0}
13185
env:
132-
NEO4J_INITIAL_PASSWORD: ${{ env.NEO4J_INITIAL_PASSWORD }}
86+
NEO4J_INITIAL_PASSWORD: ${{ secrets.NEO4J_INITIAL_PASSWORD }}
13387
ENABLE_JUPYTER_NOTEBOOK_PDF_GENERATION: "true"
13488
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT: "" # Options: "none", "aggregated", "full". default = "plugin" or ""
13589
run: |
13690
./../../scripts/analysis/analyze.sh --profile Neo4jv5-low-memory
91+
13792
- name: (Code Analysis) Collect analysis results
13893
working-directory: code-graph-analysis-pipeline/temp/${{ env.ANALYSIS_NAME }}
13994
run: |

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

Lines changed: 37 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Typescript Code Structure Graph Analysis
1+
name: react-router Typescript Code Structure Graph Analysis
22

33
on:
44
push:
@@ -15,7 +15,6 @@ on:
1515
- '.gitignore'
1616
- '.gitattributes'
1717
- 'renovate.json'
18-
- 'changelogTemplate.mustache'
1918
- '**.code-workspace'
2019
- '.github/workflows/java-code-analysis.yml'
2120
- '.github/workflows/*documentation.yml'
@@ -33,16 +32,12 @@ on:
3332
- '.gitignore'
3433
- '.gitattributes'
3534
- 'renovate.json'
36-
- 'changelogTemplate.mustache'
3735
- '**.code-workspace'
3836
- '.github/workflows/java-code-analysis.yml'
3937
- '.github/workflows/*documentation.yml'
4038

41-
# Requires the secret NEO4J_INITIAL_PASSWORD to be configured
4239
jobs:
4340
analysis-results:
44-
# This workflow is disabled for now and will be enabled as soon as the everything is set up correctly
45-
if: false
4641
runs-on: ubuntu-latest
4742
strategy:
4843
matrix:
@@ -65,84 +60,57 @@ jobs:
6560
with:
6661
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
6762

68-
- name: Setup Java JDK ${{ matrix.java }}
69-
uses: actions/setup-java@v4
70-
with:
71-
distribution: 'adopt'
72-
java-version: ${{ matrix.java }}
73-
74-
- name: Setup Cache for Conda package manager Miniforge
75-
uses: actions/cache@v4
76-
env:
77-
# Increase this value to reset cache if etc/example-environment.yml has not changed
78-
# Reference: https://github.com/conda-incubator/setup-miniconda#caching
79-
CACHE_NUMBER: 0
80-
with:
81-
path: ~/conda_pkgs_dir
82-
key:
83-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-environments-${{hashFiles('**/environment.yml', '.github/workflows/*.yml') }}
63+
- name: (Code Analysis Setup) Set ANALYSIS_NAME
64+
run: echo "ANALYSIS_NAME=${{ env.PROJECT_NAME }}-${{ env.REACT_ROUTER_VERSION }}" >> $GITHUB_ENV
8465

85-
# "Setup Python" can be skipped if jupyter notebook analysis-results aren't needed
86-
- name: Setup Python ${{ matrix.python }} with Conda package manager Miniforge
87-
uses: conda-incubator/setup-miniconda@v3
66+
- name: (Code Analysis Setup) Generate Neo4j Initial Password
67+
id: generate_neo4j_initial_password
68+
shell: bash
69+
run: |
70+
generated_password=$( LC_ALL=C tr -dc '[:graph:]' </dev/urandom | head -c 12; echo )
71+
echo "::add-mask::$generated_password"
72+
echo "neo4j_initial_password=$generated_password" >> "$GITHUB_OUTPUT"
73+
74+
- name: Setup Code Analysis
75+
uses: ./.github/actions/setup-code-analysis
8876
with:
77+
java-version: ${{ matrix.java }}
8978
python-version: ${{ matrix.python }}
9079
miniforge-version: ${{ matrix.miniforge }}
91-
activate-environment: codegraph
92-
environment-file: ./jupyter/environment.yml
93-
auto-activate-base: false
94-
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
95-
96-
- name: Conda environment info
97-
shell: bash -el {0}
98-
run: conda info
99-
100-
- name: Conda environment list updates
101-
shell: bash -el {0}
102-
run: conda update --all --dry-run | grep -Fe '-->'
103-
104-
- name: Setup temp directory if missing
105-
run: mkdir -p ./temp
106-
107-
- name: Setup Cache for "temp/downloads" folder
108-
uses: actions/cache@v4
109-
with:
110-
path: ./temp/downloads
111-
key:
112-
${{ runner.os }}-${{ hashFiles('**/*.sh') }}
113-
114-
- name: Download ${{ env.PROJECT_NAME }}-${{ env.REACT_ROUTER_VERSION }}
115-
working-directory: temp
80+
analysis-name: ${{ env.ANALYSIS_NAME }}
81+
neo4j-password: ${{ steps.generate_neo4j_initial_password.outputs.neo4j_initial_password }}
82+
83+
- name: (Code Analysis Setup) Download ${{ env.ANALYSIS_NAME }}
84+
working-directory: code-graph-analysis-pipeline/temp/${{ env.ANALYSIS_NAME }}
11685
run: |
117-
mkdir -p ${{ env.PROJECT_NAME }}-${{ env.REACT_ROUTER_VERSION }}
118-
cd ${{ env.PROJECT_NAME }}-${{ env.REACT_ROUTER_VERSION }}
119-
echo "Working directory: $( pwd -P )"
12086
./../../scripts/downloader/downloadReactRouter.sh ${{ env.REACT_ROUTER_VERSION }}
12187
122-
- name: Setup pnpm for react-router
88+
- name: (Code Analysis Setup) Setup pnpm for react-router
12389
uses: pnpm/action-setup@v4.0.0
12490
with:
125-
package_json_file: temp/${{env.PROJECT_NAME}}-${{env.REACT_ROUTER_VERSION}}/source/${{env.PROJECT_NAME}}-${{env.REACT_ROUTER_VERSION}}/package.json
91+
package_json_file: code-graph-analysis-pipeline/temp/${{ env.ANALYSIS_NAME }}/source/${{ env.ANALYSIS_NAME }}/package.json
12692

127-
- name: Install dependencies with pnpm
128-
working-directory: temp/${{ env.PROJECT_NAME }}-${{ env.REACT_ROUTER_VERSION }}/source/${{ env.PROJECT_NAME }}-${{ env.REACT_ROUTER_VERSION }}
93+
- name: (Code Analysis Setup) Install dependencies with pnpm
94+
working-directory: code-graph-analysis-pipeline/temp/${{ env.ANALYSIS_NAME }}/source/${{ env.ANALYSIS_NAME }}
12995
run: |
13096
pnpm install --frozen-lockfile --strict-peer-dependencies
13197
132-
- name: Analyze ${{ env.PROJECT_NAME }}-${{ env.REACT_ROUTER_VERSION }}
133-
working-directory: temp/${{ env.PROJECT_NAME }}-${{ env.REACT_ROUTER_VERSION }}
98+
- name: Analyze ${{ env.ANALYSIS_NAME }}
99+
working-directory: code-graph-analysis-pipeline/temp/${{ env.ANALYSIS_NAME }}
134100
# Shell type can be skipped if jupyter notebook analysis-results (and therefore conda) aren't needed
135101
shell: bash -el {0}
136102
env:
137-
NEO4J_INITIAL_PASSWORD: ${{ secrets.NEO4J_INITIAL_PASSWORD }}
103+
NEO4J_INITIAL_PASSWORD: ${{ steps.generate_neo4j_initial_password.outputs.neo4j_initial_password }}
138104
ENABLE_JUPYTER_NOTEBOOK_PDF_GENERATION: "true"
139105
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT: "" # Options: "none", "aggregated", "full". default = "plugin" or ""
140106
run: |
141-
./../../scripts/analysis/analyze.sh
107+
./../../scripts/analysis/analyze.sh --profile Neo4jv5-low-memory
142108
143-
- name: Move analysis-results from the temp to the analysis-results directory preserving their surrounding directory
144-
working-directory: temp
145-
run: ./../scripts/copyReportsIntoResults.sh
109+
- name: (Code Analysis) Collect analysis results
110+
working-directory: code-graph-analysis-pipeline/temp/${{ env.ANALYSIS_NAME }}
111+
run: |
112+
mkdir -p ./../../../analysis-results/${{ env.ANALYSIS_NAME }}
113+
cp -Rp reports ./../../../analysis-results/${{ env.ANALYSIS_NAME }}
146114
147115
# Upload logs and unfinished analysis-results in case of an error for troubleshooting
148116
- name: Archive failed run with logs and unfinished analysis-results
@@ -151,8 +119,8 @@ jobs:
151119
with:
152120
name: typescript-code-analysis-logs-java-${{ matrix.java }}-python-${{ matrix.python }}-miniforge-${{ matrix.miniforge }}
153121
path: |
154-
./temp/**/runtime/*
155-
./temp/**/analysis-results/*
122+
./code-graph-analysis-pipeline/temp/**/runtime/*
123+
./code-graph-analysis-pipeline/temp/**/results/*
156124
retention-days: 5
157125

158126
# Upload successful analysis-results in case they are needed for troubleshooting
@@ -161,7 +129,7 @@ jobs:
161129
uses: actions/upload-artifact@v4
162130
with:
163131
name: typescript-code-analysis-analysis-results-java-${{ matrix.java }}-python-${{ matrix.python }}-miniforge-${{ matrix.miniforge }}
164-
path: ./temp/**/analysis-results/*
132+
path: ./analysis-results/${{ env.ANALYSIS_NAME }}/*
165133
if-no-files-found: error
166134
retention-days: 5
167135

@@ -172,14 +140,14 @@ jobs:
172140
# uses: actions/upload-artifact@v3
173141
# with:
174142
# name: typescript-code-analysis-database-export-${{ matrix.java }}-python-${{ matrix.python }}-miniforge-${{ matrix.miniforge }}
175-
# path: ./temp/**/import
143+
# path: ./code-graph-analysis-pipeline/temp/**/import
176144
# if-no-files-found: error
177145
# retention-days: 5
178146

179147
# Commit and push the native image agent analysis-results
180148
- name: Display environment variable "github.event_name"
181149
run: echo "github.event_name=${{ github.event_name }}"
182-
- name: Commit "analysis-results" directory containing the analysis-results
150+
- name: Commit changes in the "analysis-results" directory
183151
# Only run when a pull request gets merged or a commit is pushed to the main branch
184152
# git add parameters need to match paths-ignore parameters above
185153
# Git pull before add/commit/push to reduce race conditions on parallel builds

0 commit comments

Comments
 (0)