Skip to content

♻️ CI

♻️ CI #59

Workflow file for this run

# .github/workflows/ci.yml
name: CI Pipeline
on:
workflow_dispatch:
pull_request_target:
branches:
- '*'
push:
branches:
- master
env:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
jobs:
pipeline:
name: Build and Test
runs-on: windows-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
- name: Cache SonarQube Cloud packages
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarQube Cloud 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 SonarQube Cloud 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: Start SonarQube Analysis
shell: powershell
run: |
$sonarArgs = @(
".\.sonar\scanner\dotnet-sonarscanner begin"
"/k:`"CloudFlare.Client`""
"/o:`"zingz0r-github`""
"/d:sonar.token=`"${{ secrets.SONAR_TOKEN }}`""
"/d:sonar.host.url=`"https://sonarcloud.io`""
"/d:sonar.exclusions=`"bin/**,obj/**`""
"/d:sonar.tests=`"CloudFlare.Client.Test/`""
"/d:sonar.cs.vstest.reportsPaths=`"**/*.trx`""
"/d:sonar.cs.opencover.reportsPaths=`"**/coverage.opencover.xml`""
)
if ($env:GITHUB_EVENT_NAME -eq "pull_request") {
$sonarArgs += "/d:sonar.pullrequest.key=`"${{ github.event.pull_request.number }}`""
$sonarArgs += "/d:sonar.pullrequest.branch=`"${{ github.event.pull_request.head.ref }}`""
$sonarArgs += "/d:sonar.pullrequest.base=`"${{ github.event.pull_request.base.ref }}`""
}
else {
$sonarArgs += "/d:sonar.branch=`"${{ github.ref_name }}`""
}
& $sonarArgs
- name: Build
run: dotnet build -restore --configuration ${{ env.buildConfiguration }}
- name: Run Tests
run: |
dotnet test --logger "trx;logfilename=TestResults.trx" --no-build --configuration ${{ env.buildConfiguration }} --collect "XPlat Code Coverage;Format=opencover,cobertura"
continue-on-error: false
- name: Finish SonarQube Analysis
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"