What is a Monorepo?

In software development, a monorepo is a strategy where a single repository stores code for numerous projects. Many organizations prefer this approach due to its benefits, such as improved developer mobility, enhanced code sharing, and reduced overhead in dependency management.

Monorepo Workflow and DeepSource Integration

As a collection of different projects, the traditional git entity of a monorepo doesn’t directly map to a repository entity in DeepSource. To address this, we provide granular control at each project level within the monorepo, rather than at the git object level. This approach enables you to define metrics, thresholds, and configurations for individual projects within the monorepo.

Monorepo Support Features

With the monorepo mode enabled on your DeepSource account, you gain access to the following features:

  • Convert any existing project on DeepSource into a monorepo structure.
  • Onboard a new Git repository as a monorepo, making it easier to manage large projects.
  • Activate code analysis on specific paths within the monorepo, ensuring targeted code quality checks.

    Please note that to utilize the monorepo support, you need to be on either the Business or Enterprise plan.

Sub-Repositories in DeepSource

In DeepSource, we refer to each path inside a monorepo as a sub-repository. A sub-repository can exist at any depth within the monorepo and doesn’t need to be at the root directory. Ideally, each project you want to analyze independently should be treated as a separate sub-repository.

DeepSource provides the ability to perform all actions available for a regular repository on a sub-repository, with the exception of adding repository members.

Onboarding a Monorepo

To onboard a monorepo on DeepSource, follow these simple steps:

  1. Go to the “Activate a repository” page and select the desired repository.
  1. Click on the “onboard as Monorepo” button located in the top right corner.
  1. Your repository will now be onboarded as a monorepo, and you can proceed to add sub-repositories.

Converting an Existing Repository to a Monorepo

If you have an existing DeepSource repository that you want to convert to a monorepo, follow these steps:

  1. Navigate to the repository dashboard and go to the settings page.
  2. In the ‘General’ tab, scroll down to find the “Monorepo settings” section.
  1. Click on ‘Convert to Monorepo’ and confirm the conversion by providing the name of the repository.

Please be aware that converting to a monorepo is a destructive action that will delete all current metrics, reports, issues, and ignored issues. Additionally, any public API integrations running on this repository might start failing. If you were sending test coverage artifacts to DeepSource for this repository, they will be ignored after the conversion.

Activating Analysis on Sub-Repositories

Once you have a monorepo set up on DeepSource, you can activate analysis on specific sub-repositories. To do this:

  1. For a newly created monorepo, you can add a sub-repository directly from the monorepo dashboard. Simply enter the whole path for the sub-repository you want to activate.

  1. Alternatively, you can use the “Activate new repository” option in the sidebar, navigate to the monorepo section, and then select “New sub-repository.”

With monorepo support on DeepSource, you can seamlessly manage and ensure code health at the project level for even the most extensive projects. This feature empowers developers to focus on individual projects while still benefiting from the advantages of a unified repository.

FAQs