"main" branch has not been analyzed yet and you have multiple branches already. It looks like it is

Hello everyone,

I hope you’re doing well! I’m experiencing an issue with my GitHub Actions workflow and I was hoping someone could point me in the right direction.

When I create a pull request (PR) to the main branch, I only see the PR itself along with the Quality Gates report. However, I don’t get the overview on the main branch, which I would normally expect to see when the PR is opened or merged.

Here’s some more information about the setup:

ALM Used:

  • GitHub

CI System Used:

  • GitHub Actions

Scanner Command Used:

  • SonarCloud analysis is triggered in the Build_Test_Coverage_Analyse job using the SonarSource/sonarcloud-github-action GitHub Action.

Languages in the Repository:

  • JavaScript (Frontend code in the front folder of the repository)

SonarCloud Project (if applicable):

Error Observed:

  • When opening a PR against the main branch, the overview of the PR does not appear as expected on the main branch, and I only see the Quality Gates in the PR checks.

Steps to Reproduce:

  1. Open a pull request targeting the main branch in the repository.
  2. The quality gates are visible, but the overview for the main branch is missing.

Potential Workaround:

  • I have tried triggering the PR with the GitHub Actions workflow, but I haven’t been able to figure out how to show the main branch overview in the pull request. Any suggestions would be much appreciated!

Thanks a lot in advance!


Hey there.

Your backend workflow seems to be pushing to a SonarCloud project on the main branch (SonarCloud), but your frontend workflow is only running on Pull Requests.

name: Frontend Workflow

on:
  # Déclenche le workflow lors d'un push sur la branche "feature/workflow" dans le dossier "front" pour tester pendant le developpement 
#  push:
#    branches:
#      - feature/workflow-app
#    paths:
#      - 'front/**'

  # Déclenche le workflow lors d'une pull request vers la branche "main" dans le dossier "front"
  pull_request:
    branches:
      - main
    paths:
      - 'front/**'

You probably want the on/push section of this workflow (which is currently commented out) to look more like your backend workflow (which isn’t commented out!) if you want it running on more than PRs.

am facing same issue, this is my first post in community, am on free cloud plan developer, and the sonar and bitbucket shows always zero no matter how i try with configurations and inclusion and exclusion here is my pipeline

what am missing !?

definitions:
  caches:
    sonar: ~/.sonar/cache # Cache for SonarCloud scanner
    yarn: ~/.cache/yarn # Cache for Yarn dependencies
    turbo: .turbo # TurboRepo's task cache for builds and other operations

clone:
  depth: full

  steps:
    # Yarn Install Step
    - step: &yarn-install-step
        name: Install Dependencies
        image: node:18.17.1
        caches:
          - yarn
        script:
          - echo "Starting Yarn install step..." # Log the start
          - yarn install --immutable # Install dependencies using Yarn with lockfile integrity
          - echo "Yarn install step completed successfully!" # Log the completion

    # Turbo Build Step
    - step: &turbo-build-step
        name: Turbo Build
        image: node:18.17.1
        caches:
          - turbo
          - yarn
        script:
          - echo "Starting TurboRepo build..." # Log the start
          - yarn build # This triggers the TurboRepo build task defined in your package.json
          - echo "TurboRepo build completed successfully!" # Log the completion

    # SonarCloud Analysis Step
    - step: &sonar-scan-step
        name: SonarCloud Analysis
        caches:
          - sonar
        script:
          - echo "Starting SonarCloud analysis..." # Log the start
          - echo "Current directory: $(pwd)"
          - echo "List of files in the project directory:"
          - ls -la
          - echo "List of apps directory:"
          - ls -la apps
          - echo "List of packages directory:"
          - ls -la packages
          - echo "SonarCloud analysis in progress..."
          - pipe: sonarsource/sonarcloud-scan:3.0.0
            variables:
              SONAR_TOKEN: ${SONAR_TOKEN} # Must be set in repository variables
          - echo "SonarCloud analysis completed!" # Log the completion

    # SonarCloud Quality Gate (Optional)
    - step: &quality-gate-step
        name: SonarCloud Quality Gate
        script:
          - echo "Starting SonarCloud Quality Gate check..." # Log the start
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.6
          - echo "SonarCloud Quality Gate check completed!" # Log the completion

    # Lint, Type Check, and Audit Step (Optional, Currently Commented Out)
    # - step: &build-test-step
    #     name: Build, Lint, and Type Check
    #     image: node:18.17.1
    #     caches:
    #       - node
    #     script:
    #       - echo "Starting lint, type check, and audit step..." # Log the start
    #       - yarn install --pure-lockfile # Install dependencies
    #       - npx eslint . --ext .ts,.tsx --format json > eslint-report.json # Run ESLint and save the report
    #       - npx tsc --noEmit > typescript-report.txt # Run TypeScript type and save the report
    #       - npm audit --json > npm-audit-report.json # Run npm audit and save the report
    #       - echo "Lint, type check, and audit step completed!" # Log the completion
    #     artifacts:
    #       - eslint-report.json # Saves the ESLint output as a report file
    #       - typescript-report.txt # Saves TypeScript type check results
    #       - npm-audit-report.json # Saves the NPM audit results

pipelines:
  branches:
    '{google-cloud-staging}': # Your development branch
      # - step: *yarn-install-step
      # - step: *turbo-build-step
      - step: *sonar-scan-step
      # Uncomment the following step if you want to enforce Quality Gate checks:
      # - step: *quality-gate-step

    '{main}': # Main branch
      # - step: *yarn-install-step
      # - step: *turbo-build-step
      - step: *sonar-scan-step
      # Uncomment the following step if you want to enforce Quality Gate checks:
      # - step: *quality-gate-step

    '{google-cloud}': # Production branch
      # - step: *yarn-install-step
      # - step: *turbo-build-step
      - step: *sonar-scan-step
      # Uncomment the following step if you want to enforce Quality Gate checks:
      # - step: *quality-gate-step

    'CU-*': # For feature branches or PRs
      # - step: *yarn-install-step
      # - step: *turbo-build-step
      - step: *sonar-scan-step
      # Uncomment if Quality Gate checks are required for PRs:
      # - step: *quality-gate-step

@shareef_hiasat_saj It would probably be a good idea to create a new thread, and include your analysis logs (preferably at DEBUG level, see how to add that to your pipeline in the docs)

1 Like