SonarQube

sonarqube

NOTE: This action is currently disabled as the SonarQube instance is down. The following information exists in case we decide to spin up another instance at some point in the future.

This action runs the SonarQube workflow when given a SonarQube token and URL. These are preconfigured at the organization level as GitHub secrets but must be passed by the calling workflow. There is a preconfigured template in this directory that can be used as is, with the exception of updating branches to run the workflow on (should be at least the default branch of the repository).

Currently the template also runs pytest and passes on code coverage to SonarQube. If this is not desired (although it is recommended), remove/comment out the run-unit-tests job and remove/comment out the needs: run-unit-tests line from the run-sonarqube job. An example .coveragerc file for code coverage integration lives in internal-actions/reusable-actions/pytest. Integration for testing code written in other languages will be added sometime soon.

Templates

# This template is intended to be incorporated as a workflow in another repository to run on pushes
# to the default branch and to gate pull requests behind passing results
name: SonarQube

on:
  push:
    branches: [main]  # Replace with branches you want to run on
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  run-unit-tests:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [ '3.7', '3.10' ]
    steps:
      - name: Check out repository code
        uses: actions/checkout@v3
      - name: Run pytest, Python version ${{ matrix.python-version }}
        uses: GenapsysInc/internal-actions/reusable-actions/pytest@main
        with:
          python-version: ${{ matrix.python-version }}
          requirements-txt: path/to/python/requirements.txt  # Replace with path to requirements.txt (wildcards work)
  run-sonarqube:
    runs-on: ubuntu-latest
    needs: run-unit-tests
    steps:
      - uses: GenapsysInc/internal-actions/reusable-actions/sonarqube@main
        with:
          token: ${{ secrets.SONAR_TOKEN }}
          url: ${{ secrets.SONAR_HOST_URL }}