Skip to content
file-text

GitHub Action

Depcruise PR Check

v1.0.0 Latest version

Depcruise PR Check

file-text

Depcruise PR Check

Generate depcruise report in markdown format and comment to designated PR

Installation

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

              

- name: Depcruise PR Check

uses: josteph/[email protected]

Learn more about this action in josteph/depcruise-pull-request

Choose a version

Depcruise PR Check - GitHub Actions

What is it ?

GitHub action to comment depcruise report to a pull request, also provides an optional status check for the job.

Usage

Classic usage

on: pull_request

jobs:
  example_depcruise_pr:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
      checks: write
    name: An example job to comment depcruise report to a PR
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Depcruise
        uses: josteph/[email protected]
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Specifying which pull request to comment on

You can explicitly input which pull request should be commented on by passing the pr_number input. That is particularly useful for manual workflow for instance (workflow_run).

...
- name: Depcruise
  uses: josteph/[email protected]
  with:
    pr_number: 100 # This will comment on pull request #100
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Specifying baseDir and depcruise config file

You can also override the baseDir and depcruise config file path. The path must be relative to root directory.

...
- name: Depcruise
  uses: josteph/[email protected]
  with:
    depcruise_base_dir: 'packages/monorepo-a'
    depcruise_config: 'packages/monorepo-a/.dependency-cruiser.js'
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Permissions

Minimum permissions for this GitHub action to work correctly:

permissions:
  contents: read
  pull-requests: write
  checks: write

Inputs

Action inputs

Name Description Required Default
GITHUB_TOKEN Token that is used to create comments
depcruise_base_dir The baseDir for depcruise to start the scanning 'src'
depcruise_config Path to the config file for depcruise. ./.dependency-cruiser.js
pr_number The number of the pull request where to create the comment current PR number (deduced from context)
comment_includes The text that should be used to find comment in case of replacement. 'Forbidden dependency check'
status_check If there is any rules violation detected, it will exit the job with status code. true

Build

The build steps bundles the src/main.ts to lib/index.js which is used in a NodeJS environment. It is handled by esbuild compiler.

$ npm run build