Inspect a monorepo project
A monorepo is a repository containing several projects, for example:
In this example, the backend/
folder contains a Java project, the frontend/
folder contains a JavaScript project, and the .git/
folder contains VCS-related information.
This section explains how to prepare and inspect a monorepo using:
Docker images of Qodana
The Qodana Scan GitHub action
Prepare your project
The qodana.yaml file
To configure Qodana for inspecting two projects, you need to create two separate qodana.yaml
files. Qodana also expects qodana.yaml
to be contained in the root folder of the monorepo project. This means that before running Qodana on the project from the backend/
folder, that project's qodana.yaml
file needs to be copied to both the root folder and the frontend/
folder. If you plan to run Qodana using Docker, you can copy files using the bootstrap
configuration option in qodana.yaml
, for example:
When Qodana runs, it uses the .git/
folder for linking detected problems to the corresponding source code in a Git repository, and for exploring inspection reports from within your IDE.
Here are the contents of the root/
folder:
Qodana Cloud
You can view inspection reports using Qodana Cloud. On the Qodana Cloud website, create one project for storing inspection reports for the frontend
project, and another one for the backend
project.
After you create the projects, you can use their project tokens.
Run Qodana
Because each Qodana linter can inspect a specific set of programming languages, Qodana CLI and Docker images of Qodana need to be run twice over the monorepo repository, once for each project contained in it.
These snippets use the QODANA_TOKEN
variables that refer to project tokens. The --source-directory
option specifies which project folder to inspect. Here is the snippet for the backend
project:
Here is the snippet for the frontend
project:
These snippets use the QODANA_TOKEN
variables that refer to project tokens. The --source-directory
option specifies which project directory to inspect. Here is the snippet for the backend
project:
Here is the snippet for the frontend
project:
You can use the Qodana Scan GitHub action for running Qodana on GitHub as explained in this procedure.
On the
tab of the GitHub UI, create theQODANA_TOKEN_BACKEND
andQODANA_TOKEN_FRONTEND
encrypted secrets and save the project tokens generated in Qodana Cloud as their values.On the
tab of the GitHub UI, set up a new workflow and create the.github/workflows/code_quality.yml
file.Save this workflow configuration to the
.github/workflows/code_quality.yml
file:name: Qodana on: workflow_dispatch: pull_request: push: jobs: qodana-backend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - name: 'Use qodana-backend config' run: cp ./qodana-backend.yaml ./qodana.yaml - name: 'Qodana Backend' uses: JetBrains/qodana-action@v2023.3 with: args: | --source-directory,backend, artifact-name: qodana-backend env: QODANA_TOKEN: ${{ secrets.QODANA_TOKEN_BACKEND }} qodana-frontend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - name: 'Use qodana-frontend config' run: cp ./qodana-frontend.yaml ./qodana.yaml - name: 'Qodana Frontend' uses: JetBrains/qodana-action@v2023.3 with: args: | --source-directory,frontend, artifact-name: qodana-frontend env: QODANA_TOKEN: ${{ secrets.QODANA_TOKEN_FRONTEND }}
View inspection results
Congratulations, now you can navigate to Qodana Cloud and study the inspection results for each project inside your monorepo project!