Skip to content

JohT/code-graph-analysis-examples

Repository files navigation

Code Graph Analysis Pipeline Examples

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.

The process involves three steps:

  1. Extract: Upload TypeScript source code and/or Java artifacts, optionally including their git history, using actions/upload-artifact.

  2. Analyze: Use the shared workflow JohT/code-graph-analysis-pipeline/.github/workflows/public-analyze-code-graph.yml to analyze the code and artifacts, then upload the results.

  3. Use: Download the analysis results with actions/download-artifact and utilize them as needed.

Table of Contents

πŸš€ TypeScript Code Pipeline

This example demonstrates how to analyze TypeScript code in a GitHub Workflows pipeline.

  1. The first job, prepare-code-to-analyze, in the GitHub Actions Workflow typescript-code-analysis.yml, shows how to extract TypeScript code from a repository and upload it for analysis.

  2. The second job, analyze-code-graph, calls the shared analysis workflows using the uploaded artifacts' names as parameters. Here is a simple example:

name: Analyze Code Graph
needs: [prepare-code-to-analyze]
uses: JohT/code-graph-analysis-pipeline/.github/workflows/public-analyze-code-graph.yml
with:
  analysis-name: ${{ needs.prepare-code-to-analyze.outputs.analysis-name }}
  sources-upload-name: ${{ needs.prepare-code-to-analyze.outputs.sources-upload-name }}
  1. The third job, analyze-code-graph, demonstrates how to download the analysis results and commit them back to the repository.

β˜• Java Artifacts Pipeline

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.

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.

The first job, prepare-code-to-analyze, in the GitHub Actions Workflow java-code-analysis.yml, shows how to prepare the Java artifacts and git history for analysis.

The second and third jobs are the same as for the TypeScript example.

πŸ“‘ CSV Report Reference

CSV_REPORTS.md lists all CSV Cypher query result reports inside the results directory. It can be generated as described in Generate CSV Report Reference.

πŸ““ Jupyter Notebook Report Reference

JUPYTER_REPORTS.md lists all Jupyter Notebook reports inside the results directory. It can be generated as described in Generate Jupyter Notebook Report Reference.

πŸ–ΌοΈ Image Reference

IMAGES.md lists all PNG images inside the results directory. It can be generated as described in Generate Image Reference.

♻️ Update Analysis Workflow with Renovate

This repository uses Renovate to automatically update the analysis workflow to the latest version. To enable this, add the following extension to your Renovate configuration:

"extends": [
  "github>JohT/code-graph-analysis-pipeline//renovate-presets/code-graph-analysis-workflow-latest-digest.json5"
]

You can find the complete configuration in the renovate.json file.

πŸ“„ License

This repository is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

πŸ“Š Analysis Results

Here are ten examples from over a hundred reports generated by the analysis. These examples illustrate the results of analyzing AxonFramework, a Java framework for Evolutionary Message-Driven Microservices on the JVM. For the complete set of reports, visit the analysis-results directory.

External Dependencies of Java Packages

External dependencies of Java packages

Dependencies Graph of Java Artifacts

Dependencies graph of Java artifacts

Longest Path(s) of Java Artifacts

Longest path of Java artifacts

All Pairs Shortest Paths of Java Packages per Artifact

All pairs shortest paths of Java packages per artifact

Object-Oriented Design Metrics for Java Packages

Object-Oriented Design Metrics for Java packages

Effective Line Count of Java Methods

Effective line count of Java methods

Cyclomatic Complexity Distribution for Java Methods

Cyclomatic complexity distribution for Java methods

Visibility of Java Types

Visibility of Java types

Communities and Node Embeddings of Java Packages

Communities and node embeddings of Java packages

Word Cloud of Git Authors

Word cloud of git authors

Releases

No releases published

Contributors 2

  •  
  •