-
Notifications
You must be signed in to change notification settings - Fork 2
84 lines (74 loc) · 3.21 KB
/
sonarcloud.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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 }}
- name: Fetch secrets from key vault
uses: azure/CLI@v1
id: fetch-secrets
with:
inlineScript: |
SECRET_VALUE=$(az keyvault secret show --name "SLACK-WEBHOOK" --vault-name "${{ secrets.INFRA_KEY_VAULT}}" --query "value" -o tsv)
echo "::add-mask::$SECRET_VALUE"
echo "SLACK-WEBHOOK=$SECRET_VALUE" >> $GITHUB_OUTPUT
SECRET_VALUE=$(az keyvault secret show --name "SONAR-TOKEN" --vault-name "${{ secrets.INFRA_KEY_VAULT}}" --query "value" -o tsv)
echo "::add-mask::$SECRET_VALUE"
echo "SONAR-TOKEN=$SECRET_VALUE" >> $GITHUB_OUTPUT
- 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.fetch-secrets.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.fetch-secrets.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.fetch-secrets.outputs.SLACK-WEBHOOK }}