/
Migration to SonarCloud with GitHub Actions

Migration to SonarCloud with GitHub Actions

Introduction

We're migrating to SonarCloud because SonarQube's rule set has become outdated, lacking many of the latest checks. This move will ensure we're utilizing the most current standards for code quality and security directly in our GitHub workflow. The document will serve as your roadmap through the migration process. It’ll provide a comprehensive guide on configuring a GitHub workflow for code analysis with SonarCloud, applicable to both our Front-end and Back-end repositories.

Most of the repositories are already migrated. You can check it HERE.

IMPORTANT: To create or add new projects within the openLMIS organization on the SonarCloud platform, one must possess "Owner" rights. This requirement is crucial for disabling automatic analysis.

Step-by-Step Guide for SonarCloud with GitHub Actions for a Front-End Repository

For demonstration purposes, we'll use the openlmis-requisition-ui repository to illustrate how to configure SonarCloud with GitHub Actions, providing a blueprint for enhancing code analysis in your front-end projects.

Step 1: Sonar Project Setup

  1. SonarCloud Account: Ensure you have a SonarCloud account connected to your GitHub.

  2. Add a New Project:

    • Click on plus button near your avatar on the top right corner of the SonarCloud dashboard.

    • Select “Analyze new project”.

    • From the list of available repositories, select the repository that you want to analyze.

IMPORTANT: You do not have to worry about creating individual SonarCloud tokens for your project. They have been pre-configured at the organization level, making them available for all repositories under OpenLMIS.

Step 2: Sonar Configuration

Prior to setting up the configuration files, you need to adjust settings on the SonarCloud platform.

  1. SonarCloud Project: Navigate to your project on the SonarCloud website.

  2. Disable Automatic Analysis:

    • Click on Administration at the bottom-left corner of the page.

    • Select Analysis Method.

    • Disable Automatic Analysis which is Recommended.

  3. Set Up Analysis with GitHub Actions:

    • After disabling automatic analysis, choose to set up analysis With GitHub Actions.

    • You will be presented with instructions specific to GitHub Actions – since the tokens are managed at the organization level, you can bypass the token setup.

    • Click on Other (for JS, TS, Go, Python, PHP, ...). Upon selecting this option, SonarCloud will provide specif