Skip to content

Merge pull request #93 #283

Merge pull request #93

Merge pull request #93 #283

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
build:
name: CI
runs-on: ubuntu-latest
env:
SONAR_ARGS: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name && format('/d:sonar.token="{0}"', secrets.SONAR_TOKEN) || ''}}
CONFIGURATION: Release
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
3.1.x
7.x
8.x
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: microsoft
java-version: 17
- 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'
run: dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
- name: Start analyzation with SonarCloud
run: ./.sonar/scanner/dotnet-sonarscanner begin /k:"TryAtSoftware_Extensions" /o:"tryatsoftware" /d:sonar.cs.opencover.reportsPaths="**/*.opencover.xml" /d:sonar.host.url="https://sonarcloud.io" ${{ env.SONAR_ARGS }}
- name: Restore dependencies
run: dotnet restore
- name: Build the solution
run: dotnet build --no-restore --configuration "${{ env.CONFIGURATION }}"
- name: Test the solution
run: dotnet test --no-build --configuration "${{ env.CONFIGURATION }}" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
- name: Finalize analyzation with SonarCloud
run: ./.sonar/scanner/dotnet-sonarscanner end ${{ env.SONAR_ARGS }}