Merge pull request #1286 from DFE-Digital/607-git-api-add-statuscake-… #3155
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Sonar scanner | |
on: | |
pull_request: | |
types: [assigned, opened, synchronize, reopened] | |
push: | |
branches: [ master ] | |
jobs: | |
sonarcloud: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: set-up-environment | |
uses: DFE-Digital/github-actions/set-up-environment@master | |
- uses: Azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- uses: DfE-Digital/keyvault-yaml-secret@v1 | |
id: keyvault-yaml-secret | |
with: | |
keyvault: ${{ secrets.KEY_VAULT}} | |
secret: INFRA-KEYS | |
key: SLACK-WEBHOOK, SONAR-TOKEN | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '7.0' | |
- name: Install dotnet-sonarscanner | |
run: dotnet tool install --global dotnet-sonarscanner --version 5.9.1 | |
- name: Install dependencies | |
run: dotnet restore | |
- name: Spin Up Stack | |
run: docker-compose up -d | |
- name: SonarCloud | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
dotnet sonarscanner begin \ | |
/k:"DFE-Digital_get-into-teaching-api" \ | |
/o:"dfe-digital" \ | |
/n:"get-into-teaching-api" \ | |
/d:sonar.login="${{ steps.keyvault-yaml-secret.outputs.SONAR-TOKEN }}" \ | |
/d:sonar.host.url="https://sonarcloud.io" \ | |
/d:sonar.cpd.exclusions="GetIntoTeachingApi/Migrations/*.cs" \ | |
/d:sonar.cs.opencover.reportsPaths="GetIntoTeachingApiTests/coverage.opencover.xml" \ | |
/d:sonar.cs.vstest.reportsPaths="**/*.trx" \ | |
/d:sonar.coverage.exclusions="\ | |
GetIntoTeachingApiTests/**/*,\ | |
GetIntoTeachingApi/Migrations/*.cs,\ | |
GetIntoTeachingApi/Adapters/*.cs,\ | |
GetIntoTeachingApi/Database/GetIntoTeachingDbContextFactory.cs,\ | |
GetIntoTeachingApi/OperationFilters/AuthOperationFilter.cs,\ | |
GetIntoTeachingApi/Startup.cs,\ | |
GetIntoTeachingApi/Program.cs\ | |
" \ | |
/d:sonar.verbose=true \ | |
/d:sonar.log.level="DEBUG" | |
dotnet build | |
dotnet test --no-build --logger:trx -e:CollectCoverage=true -e:CoverletOutputFormat=opencover | |
dotnet sonarscanner end /d:sonar.login="${{ steps.keyvault-yaml-secret.outputs.SONAR-TOKEN }}" | |
- name: Slack Notification | |
if: failure() && github.ref == 'refs/heads/master' | |
uses: rtCamp/action-slack-notify@master | |
env: | |
SLACK_COLOR: ${{env.SLACK_FAILURE }} | |
SLACK_MESSAGE: Pipeline Failure carrying out job ${{github.job}} | |
SLACK_TITLE: 'Failure: ${{ github.workflow }}' | |
SLACK_WEBHOOK: ${{ steps.keyvault-yaml-secret.outputs.SLACK-WEBHOOK }} |