Skip to content
check-circle

GitHub Action

NDepend

ndependv1.0 Latest version

NDepend

check-circle

NDepend

NDepend parser

Installation

Copy and paste the following snippet into your .yml file.

              

- name: NDepend

uses: ndepend/[email protected]

Learn more about this action in ndepend/ndepend-action

Choose a version

NDepend GitHub Action

This GitHub Action lets run an NDepend analysis after each rebuild and explore results in a shared interactive HTML+js report (see some sample reports here. Reports generated by the GitHub action contain links to code source hosted by GitHub.

This Action can also fail the build upon some Quality Gate(s) failure.

With a Developer license, the standalone app VisualNDepend.exe or the NDepend Visual Studio extension can download the NDepend Github Action analysis results locally for further exploration.

The NDepend GitHub Action runs only on the worker machine and zero data (source code, account, analysis result, or anything) is shared remotely with ndepend.com or any other third-party. Indeed, the NDepend analysis result is stored as an artifact of your build.

Activate the trial license for your repository

Get the license trial data from this page on ndepend.com

Got to the settings of your repository alt text

From the left side bar goto Secrets->Actions, create a new secret named NDependLicense and paste the license data retrieved from the ndepend website.

Usage

The ndepend action must be added after your build and unit testing actions, note that only the license parameter is mandatory.

- name: NDepend
    uses: ndepend/ndepend-action@v1
    with:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  
      license: ${{ secrets.NDependLicense }}

After the analysis, the ndepend result is stored as an artifact of your build, and to explore it you have two options:

  • Download the zipped ndepend artifact from your build summary, and open the generated HTML + js report it contains.
  • Access the result from VisualNDepend as explained here.

Action options

Custom NDepend Configuration:

By default the ndepend action uses the out of the box configuration, so this parameter is not mandatory. However, if you need to use a custom configuration you have to specify the customconfig parameter

- name: NDepend
    uses: ndepend/ndepend-action@v1
    with:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  
      license: ${{ secrets.NDependLicense }}
      customconfig: project.ndproj

The project.ndproj file must be uploaded to your repository, its path is relative to your repository root. And its name could be any name of your choice.

Visual Studio Solution:

By default the ndepend action parse the .sln existing in your repository. However, if many .sln files are found you have to secify which solution to parse. For that you can use solution parameter

- name: NDepend
    uses: ndepend/ndepend-action@v1
    with:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  
      license: ${{ secrets.NDependLicense }}
      solution: src/mysolution.sln

The solution path is relative to your repository root.

Comparison baseline:

NDepend can report Code & Quality Diff since a baseline. To define the ndepend baseline you have to specify the baseline parameter

- name: NDepend
    uses: ndepend/ndepend-action@v1
    with:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  
      license: ${{ secrets.NDependLicense }}
      baseline: recent

The baseline parameter could have these values:

  • recent: to compare with the most recent build analyzed by ndepend.
  • branchname_recent: To compare with the most recent build of the branch with name 'branchname', for example if you want to compare with the recent build of the branch named mydev
- name: NDepend
    uses: ndepend/ndepend-action@v1
    with:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  
      license: ${{ secrets.NDependLicense }}
      baseline: mydev_recent
  • run number: The run number of a build already analyzed by NDepend., for example if you want to compare with the build having the run number 30
- name: NDepend
    uses: ndepend/ndepend-action@v1
    with:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  
      license: ${{ secrets.NDependLicense }}
      baseline: 30

Quality check:

A Quality Gate is a code quality goal. Such quality goal must be enforced before releasing and eventually, before committing to source control.

A Quality Gate can be seen as a PASS/FAIL criterion for software quality.

A dozen of default Quality Gates are proposed by NDepend. They are related to measures like technical debt amount, code coverage or amount of issues with particular severity.

To break the build if at least one quality gate failed, just specify the stopIfQGFailed parameter

- name: NDepend
    uses: ndepend/ndepend-action@v1
    with:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  
      license: ${{ secrets.NDependLicense }}
      stopIfQGFailed: true

NDepend makes it easy to modify existing Quality Gates or create your own ones. This is explained here.

Coverage folder:

Code coverage data is imported from coverage result files generated by the coverage tools. To import coverage data, you have to specify the coveragefolder parameter

- name: NDepend
    uses: ndepend/ndepend-action@v1
    with:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  
      license: ${{ secrets.NDependLicense }}
      coveragefolder: ${{ env.GITHUB_WORKSPACE }}/CoverageOut

This way the NDepend default rules about code coverage will be executed. See this documentation about coverage technologies and formats supported by NDepend and other code coverage data usage.