|
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