Skip to content

Commit 649dcef

Browse files
committed
Share common analysis setup
1 parent f0342a7 commit 649dcef

File tree

2 files changed

+94
-54
lines changed

2 files changed

+94
-54
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,69 +61,23 @@ 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
73+
analysis-name: ${{ env.ANALYSIS_NAME }}
74+
neo4j-password: ${{ secrets.NEO4J_INITIAL_PASSWORD }}
10175

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') }}
117-
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
@@ -134,6 +88,7 @@ jobs:
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: |
@@ -175,7 +130,7 @@ jobs:
175130
# Commit and push the native image agent analysis-results
176131
- name: Display environment variable "github.event_name"
177132
run: echo "github.event_name=${{ github.event_name }}"
178-
- name: Commit "analysis-results" directory containing the analysis-results
133+
- name: Commit "analysis-results" directory
179134
# Only run when a pull request gets merged or a commit is pushed to the main branch
180135
# git add parameters need to match paths-ignore parameters above
181136
# Git pull before add/commit/push to reduce race conditions on parallel builds

0 commit comments

Comments
 (0)