Skip to content

Sonar

Sonar #1085

Workflow file for this run

name: Sonar
'on':
push:
branches:
- "**"
pull_request_target:
branches:
- "**"
types: [opened, synchronize, reopened, labeled]
schedule:
- cron: 0 16 * * *
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check for external PR
if: ${{ !(contains(github.event.pull_request.labels.*.name, 'safe') ||
github.event.pull_request.head.repo.full_name == github.repository ||
github.event_name != 'pull_request_target') }}
run: echo "Unsecure PR, must be labelled with the 'safe' label, then run the workflow again" && exit 1
- name: Setup .NET 8
uses: actions/setup-dotnet@v4.3.1
with:
dotnet-version: 8.0.x
- name: Setup java
uses: actions/setup-java@v1
with:
java-version: '11'
- name: Test
env:
NETCORE_TEST_PROJECT: >-
Mastercard.Developer.ClientEncryption.Tests/Mastercard.Developer.ClientEncryption.Tests.csproj
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}'
run: >
export PATH="$PATH:$HOME/.dotnet/tools"
dotnet tool install --global dotnet-sonarscanner
dotnet sonarscanner begin \
/k:"Mastercard_client-encryption-csharp" \
/n:"client-encryption-csharp" \
/o:"mastercard" \
/d:sonar.host.url="https://sonarcloud.io" \
/d:sonar.login="$SONAR_TOKEN" \
/d:sonar.cs.vstest.reportsPaths="./Mastercard.Developer.ClientEncryption.Tests/bin/tests.trx" \
/d:sonar.cs.opencover.reportsPaths="./Mastercard.Developer.ClientEncryption.Tests/bin/coverage.xml"
dotnet test $NETCORE5_TEST_PROJECT -c Release
-l:"trx;LogFileName=tests.trx" -r:"./Mastercard.Developer.ClientEncryption.Tests/bin/" /p:CollectCoverage=true
/p:CoverletOutputFormat="opencover"
/p:CoverletOutput="bin/coverage.xml"
dotnet publish $NETCORE5_TEST_PROJECT -c Release
dotnet sonarscanner end /d:sonar.login="$SONAR_TOKEN"