Skip to content

CI improvements

CI improvements #1238

Workflow file for this run

name: "Static Analysis"
on:
workflow_dispatch:
push:
paths-ignore:
- 'Postman/**'
- 'AUTHORS.md'
- 'CODE_OF_CONDUCT.md'
- 'CONTRIBUTING.md'
- 'Changelog.md'
- 'LICENSE.md'
- 'PublishRelease.txt'
- 'README.md'
- 'coding_style.md'
- 'docs/**'
pull_request:
paths-ignore:
- 'Postman/**'
- 'AUTHORS.md'
- 'CODE_OF_CONDUCT.md'
- 'CONTRIBUTING.md'
- 'Changelog.md'
- 'LICENSE.md'
- 'PublishRelease.txt'
- 'README.md'
- 'coding_style.md'
- 'docs/**'
env:
BUILD_TYPE: Release
PROJECT_NAME: 'Source\Lib\Trakt.NET\Trakt.NET.csproj'
jobs:
sonarcloud:
name: SonarCloud
if: ${{ github.actor == 'henrikfroehling' }}
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
dotnet-quality: 'ga'
- name: Restore dependencies
run: dotnet restore ${{ env.PROJECT_NAME }}
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v4
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
- 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:"henrikfroehling_Trakt.NET" /o:"henrikfroehling-github" /n:"Trakt.NET" /d:sonar.sources="Source/" /d:sonar.sourceEncoding="UTF-8" /d:sonar.exclusions="Source/Tests/**" /d:sonar.dotnet.excludeTestProjects=true /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build ${{ env.PROJECT_NAME }} --configuration ${{ env.BUILD_TYPE }} --no-restore
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"