From d339a95825f5e92e7fcc9d98f8892b71378a5be5 Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Thu, 11 Nov 2021 09:24:22 -0600 Subject: [PATCH] ci: sonarcloud code analysis support Squashed commit of the following: commit 673f4b7441d910cf25dce6842552a06bf5f76490 Author: Robert Dailey Date: Wed Nov 10 12:37:55 2021 -0600 Add SonarCloud integration commit 5dfe5cf7a2c2a96ecdc0c684c605334460efbf73 Author: Robert Dailey Date: Wed Nov 10 12:46:40 2021 -0600 Reformat YAML commit d210104ffee6fea81304312588e9fa89fb1a86f0 Author: Robert Dailey Date: Wed Nov 10 12:46:16 2021 -0600 Remove stale comments in build.yml commit 66f18519c39b1cece888d7028cd2056d2f8dfbe3 Author: Robert Dailey Date: Wed Nov 10 12:44:28 2021 -0600 Set up schema for build.yml --- .github/workflows/build.yml | 60 +++++++++++++++++++++++++++++++------ README.md | 1 + 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 08987fd7..68dbc59c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,17 +1,18 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json name: Build & Test on: push: paths-ignore: - - 'wiki/**' - - '**.md' + - "wiki/**" + - "**.md" pull_request: paths-ignore: - - 'wiki/**' - - '**.md' + - "wiki/**" + - "**.md" env: - dotnetVersion: 6.0.x + dotnetVersion: "6.0.x" jobs: build: @@ -56,15 +57,56 @@ jobs: name: trash path: publish/zip/trash-*.zip + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + env: + DOTNET_ROLL_FORWARD: LatestMajor + GITHUB_TOKEN: ${{ secrets.PAT }} + steps: + - name: Get Source Code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup NBGV + uses: dotnet/nbgv@master + id: nbgv + + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: ${{ env.dotnetVersion }} + + - name: Install Sonar Scanner + run: dotnet tool install --global dotnet-sonarscanner + + - name: Begin Sonar Scanner + run: > + dotnet sonarscanner begin + -o:"rcdailey" + -k:"rcdailey_trash-updater" + -n:"Trash Updater" + -v:"${{ steps.nbgv.outputs.SimpleVersion }}" + -d:"sonar.login=${{ secrets.SONAR_TOKEN }}" + -d:"sonar.host.url=https://sonarcloud.io" + + - name: Build + run: dotnet build src + + - name: Test + run: dotnet test src + + - name: End Sonar Scanner + run: > + dotnet sonarscanner end + -d:"sonar.login=${{ secrets.SONAR_TOKEN }}" + release: name: Release needs: build runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') - # github.event.create.ref_type == 'tag' - # startsWith(github.event.push.ref, 'refs/heads/release/') - # github.event.pull_request.merged == true && - # startsWith(github.event.pull_request.head.ref, 'release/') steps: - name: Checkout uses: actions/checkout@v2 diff --git a/README.md b/README.md index c5ee1e81..a6f63aea 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/rcdailey/trash-updater/blob/master/LICENSE) ![build status](https://github.com/rcdailey/trash-updater/actions/workflows/build.yml/badge.svg?branch=master) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=rcdailey_trash-updater&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=rcdailey_trash-updater) [![GitHub release](https://img.shields.io/github/release/rcdailey/trash-updater.svg)](https://github.com/rcdailey/trash-updater/releases/) [![Support Server](https://img.shields.io/discord/492590071455940612.svg?color=7289da&label=TRaSH-Guides&logo=discord&style=flat-square)](https://discord.com/invite/Vau8dZ3)