GreyWoulf / Sonar-Cloud-and-GitHub-Actions

Play with Docker in a node app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

logo

Sonar Cloud and GitHub Actions CI

GOAL: Setup SonarCloud to run as a part of your GitHub Actions!

Instructions

  1. Fork this repository that contains an example Inventory App starter code from Bootcamp.
  2. Navigate to SonarCloud dashboard and press the ✚ sign to analyze a new project.
  3. Select the project that you forked from GitHub.
  4. Select "GitHub Actions" as your analysis method

Screenshot 2022-12-06 at 2 16 34 PM

The next steps may disappear on the initial setup as a report finishes. To access these if they disappear go to the following on the project page Admistration → Analysis Method → GitHub Actions Follow the Tutorial

  1. In GitHub, copy and add the provided SONAR_TOKEN and value as a repository secret.

Screenshot 2022-12-06 at 2 16 41 PM

  1. Select "Other (for JS, TS, Go, Python, PHP, …)

Screenshot 2022-12-06 at 2 17 58 PM

  1. Copy the provided code into your build.yml file. The code should look similar to the one shown below.
name: Jest -> SonarCloud

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  sonarcloud:
    name: SonarCloud
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - name: SonarCloud Scan
        uses: SonarSource/sonarcloud-github-action@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

        #  These commands exist in the original file.
      - name: Install Dependencies
        run: npm i

      - name: Run tests
        run: npm run test
      
      # Add deployment commands here
  1. Create a sonar-project.properties file in the root directory of the project. Copy the provided code.
  2. Disable automatic analysis.

Screenshot 2022-12-06 at 2 18 27 PM

  1. Save and push your changes and GitHub Actions will now run your analysis on SonarCloud.

About

Play with Docker in a node app


Languages

Language:JavaScript 70.5%Language:CSS 15.3%Language:Handlebars 13.5%Language:Dockerfile 0.7%