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
Configuration files
To configure Qodana for inspecting two projects, you need to create two YAML-formatted configuration files, one for each linter. In this example, these will be the qodana-backend.yaml
and qodana-frontend.yaml
files.
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 for running Qodana.
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. The --config
option specifies which Qodana configuration file to employ. 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. The --config
option specifies which Qodana configuration file to employ. 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: 'Qodana Backend' uses: JetBrains/qodana-action@v2024.3 with: args: | --source-directory,backend,--config,qodana-backend.yaml 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: 'Qodana Frontend' uses: JetBrains/qodana-action@v2024.3 with: args: | --source-directory,frontend,--config,qodana-frontend.yaml artifact-name: qodana-frontend env: QODANA_TOKEN: ${{ secrets.QODANA_TOKEN_FRONTEND }}
View inspection results
Congratulations, now you can navigate to Qodana Cloud and review the inspection results for each project inside your monorepo project!