Skip to content

Merge pull request #53 from p-rivero/dependabot/nuget/DiscordAudioStr… #251

Merge pull request #53 from p-rivero/dependabot/nuget/DiscordAudioStr…

Merge pull request #53 from p-rivero/dependabot/nuget/DiscordAudioStr… #251

Workflow file for this run

name: Code analysis
on:
push:
branches:
- master
- dev
pull_request:
types: [opened, synchronize, reopened]
branches:
- master
- dev
jobs:
analyze:
name: CodeQL + SonarCloud
runs-on: windows-latest
steps:
# Prepare project
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Setup MSBuild Path
uses: microsoft/setup-msbuild@v1
- name: Setup NuGet
uses: NuGet/setup-nuget@v1
- name: Restore NuGet Packages
run: nuget restore DiscordAudioStream.sln
# Install SonarCloud scanner
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v3
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
# SonarCloud scan
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"p-rivero_DiscordAudioStream" /o:"p-rivero" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
msbuild DiscordAudioStream.sln /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=FolderProfile
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
# CodeQL scan
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: csharp
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
dotnet-format:
runs-on: windows-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x
- name: Run dotnet format
run: dotnet format .\DiscordAudioStream.sln --verify-no-changes --verbosity diagnostic