Skip to content

Commit 60acf7c

Browse files
authored
Merge pull request #9 from JohT/fix/missing-git-history
Fix missing git history
2 parents 436acca + 0f1baf6 commit 60acf7c

File tree

3 files changed

+102
-2
lines changed

3 files changed

+102
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
repository: AxonFramework/AxonFramework
6060
ref: axon-${{ env.AXON_FRAMEWORK_VERSION }}
6161
path: ./source
62+
fetch-depth: 0 # Include the full git history for analysis
6263

6364
- name: (Prepare Code to Analyze) Setup Java Development Kit for Maven JARs downloading (JDK) ${{ env.JAVA_VERSION}}
6465
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
with:
5757
repository: remix-run/react-router
5858
ref: react-router@${{ env.REACT_ROUTER_VERSION }}
59+
fetch-depth: 0 # Include the full git history for enhanced analysis
5960

6061
- name: (Prepare Code to Analyze) Setup pnpm for react-router
6162
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0

README.md

Lines changed: 100 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,100 @@
1-
# code-graph-analysis-examples
2-
Shows how to use the [code-graph-analysis-pipeline](https://github.com/JohT/code-graph-analysis-pipeline) based on some examples
1+
# Code Graph Analysis Pipeline Examples
2+
3+
This repository provides examples of how to analyze TypeScript code and Java artifacts using a fully automated GitHub Workflows pipeline with the [code-graph-analysis-pipeline](https://github.com/JohT/code-graph-analysis-pipeline).
4+
5+
The process involves three steps:
6+
7+
1. **Extract**: Upload TypeScript source code and/or Java artifacts, optionally including their git history, using [actions/upload-artifact](https://github.com/actions/upload-artifact).
8+
9+
1. **Analyze**: Use the shared workflow [JohT/code-graph-analysis-pipeline/.github/workflows/public-analyze-code-graph.yml](https://github.com/JohT/code-graph-analysis-pipeline/blob/main/.github/workflows/public-analyze-code-graph.yml) to analyze the code and artifacts, then upload the results.
10+
11+
1. **Use**: Download the analysis results with [actions/download-artifact](https://github.com/actions/download-artifact) and utilize them as needed.
12+
13+
## Example for TypeScript Code
14+
15+
This example demonstrates how to analyze TypeScript code in a GitHub Workflows pipeline.
16+
17+
1. The first job, [prepare-code-to-analyze](https://github.com/JohT/code-graph-analysis-examples/blob/23143b34d8fc6e0ab7d80102d8de0b6e6a4ec98e/.github/workflows/typescript-code-analysis.yml#L40), in the GitHub Actions Workflow [typescript-code-analysis.yml](https://github.com/JohT/code-graph-analysis-examples/blob/23143b34d8fc6e0ab7d80102d8de0b6e6a4ec98e/.github/workflows/typescript-code-analysis.yml), shows how to extract TypeScript code from a repository and upload it for analysis.
18+
19+
2. The second job, [analyze-code-graph](https://github.com/JohT/code-graph-analysis-examples/blob/23143b34d8fc6e0ab7d80102d8de0b6e6a4ec98e/.github/workflows/typescript-code-analysis.yml#L89), calls the shared analysis workflows using the uploaded artifacts' names as parameters. Here is a simple example:
20+
21+
```yaml
22+
name: Analyze Code Graph
23+
needs: [prepare-code-to-analyze]
24+
uses: JohT/code-graph-analysis-pipeline/.github/workflows/public-analyze-code-graph.yml
25+
with:
26+
analysis-name: ${{ needs.prepare-code-to-analyze.outputs.analysis-name }}
27+
sources-upload-name: ${{ needs.prepare-code-to-analyze.outputs.sources-upload-name }}
28+
```
29+
30+
3. The third job, [analyze-code-graph](https://github.com/JohT/code-graph-analysis-examples/blob/23143b34d8fc6e0ab7d80102d8de0b6e6a4ec98e/.github/workflows/typescript-code-analysis.yml#L99), demonstrates how to download the analysis results and commit them back to the repository.
31+
32+
## Example for Java Artifacts
33+
34+
Java artifacts are analyzed similarly to TypeScript code. The main difference is that Java artifacts are downloaded from a Maven repository instead of being part of the repository.
35+
36+
To include the git history in the analysis, checkout the corresponding source repository and upload it as the source artifact, similar to the TypeScript example. The Java source code isn't used for the analysis, so a bare git clone is sufficient.
37+
38+
The first job, [prepare-code-to-analyze](https://github.com/JohT/code-graph-analysis-examples/blob/23143b34d8fc6e0ab7d80102d8de0b6e6a4ec98e/.github/workflows/java-code-analysis.yml#L40), in the GitHub Actions Workflow [java-code-analysis.yml](https://github.com/JohT/code-graph-analysis-examples/blob/23143b34d8fc6e0ab7d80102d8de0b6e6a4ec98e/.github/workflows/java-code-analysis.yml), shows how to prepare the Java artifacts and git history for analysis.
39+
40+
The second and third jobs are the same as for the TypeScript example.
41+
42+
## Analysis Results
43+
44+
Here are ten examples from over a hundred reports generated by the analysis. These examples illustrate the results of analyzing [AxonFramework](https://github.com/AxonFramework/AxonFramework), a Java framework for Evolutionary Message-Driven Microservices on the JVM. For the complete set of reports, visit the [analysis-results](./analysis-results) directory.
45+
46+
### External Dependencies of Java Packages
47+
48+
<img src="./analysis-results/AxonFramework/AxonFramework-4.10.3/external-dependencies-java/ExternalDependenciesJava_files/ExternalDependenciesJava_20_1.png" width="600" alt="External dependencies of Java packages">
49+
50+
### Dependencies Graph of Java Artifacts
51+
52+
<img src="./analysis-results/AxonFramework/AxonFramework-4.10.3/internal-dependencies-visualization/JavaArtifactBuildLevels.svg" width="600" alt="Dependencies graph of Java artifacts">
53+
54+
### Longest Path(s) of Java Artifacts
55+
56+
<img src="./analysis-results/AxonFramework/AxonFramework-4.10.3/path-finding-visualization/JavaArtifactLongestPaths.svg" width="600" alt="Longest path of Java artifacts">
57+
58+
### All Pairs Shortest Paths of Java Packages per Artifact
59+
60+
<img src="./analysis-results/AxonFramework/AxonFramework-4.10.3/path-finding-java/PathFindingJava_files/PathFindingJava_47_1.png" width="600" alt="All pairs shortest paths of Java packages per artifact">
61+
62+
### Object-Oriented Design Metrics for Java Packages
63+
64+
<img src="./analysis-results/AxonFramework/AxonFramework-4.10.3/object-oriented-design-metrics-java/ObjectOrientedDesignMetricsJava_files/ObjectOrientedDesignMetricsJava_41_0.png" width="600" alt="Object-Oriented Design Metrics for Java packages">
65+
66+
### Effective Line Count of Java Methods
67+
68+
<img src="./analysis-results/AxonFramework/AxonFramework-4.10.3/method-metrics-java/MethodMetricsJava_files/MethodMetricsJava_14_1.png" width="600" alt="Effective line count of Java methods">
69+
70+
### Cyclomatic Complexity Distribution for Java Methods
71+
72+
<img src="./analysis-results/AxonFramework/AxonFramework-4.10.3/method-metrics-java/MethodMetricsJava_files/MethodMetricsJava_26_1.png" width="600" alt="Cyclomatic complexity distribution for Java methods">
73+
74+
### Visibility of Java Types
75+
76+
<img src="./analysis-results/AxonFramework/AxonFramework-4.10.3/visibility-metrics-java/VisibilityMetricsJava_files/VisibilityMetricsJava_24_2.png" width="600" alt="Visibility of Java types">
77+
78+
### Communities and Node Embeddings of Java Packages
79+
80+
<img src="./analysis-results/AxonFramework/AxonFramework-4.10.3/node-embeddings-java/NodeEmbeddingsJava_files/NodeEmbeddingsJava_21_0.png" width="600" alt="Communities and node embeddings of Java packages">
81+
82+
### Word Cloud of Git Authors
83+
84+
<img src="./analysis-results/AxonFramework/AxonFramework-4.10.3/wordcloud/Wordcloud_files/Wordcloud_17_0.png" width="600" alt="Word cloud of git authors">
85+
86+
## Keeping the Analysis Workflow Updated with Renovate
87+
88+
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:
89+
90+
```json
91+
"extends": [
92+
"github>JohT/code-graph-analysis-pipeline//renovate-presets/code-graph-analysis-workflow-latest-digest.json5"
93+
]
94+
```
95+
96+
You can find the complete configuration in the [renovate.json](./renovate.json) file.
97+
98+
## License
99+
100+
This repository is licensed under the Apache License, Version 2.0. See [LICENSE](./LICENSE) for the full license text.

0 commit comments

Comments
 (0)