-
Notifications
You must be signed in to change notification settings - Fork 9
138 lines (116 loc) · 4.15 KB
/
Copy pathbuild-test-analyse.yml
File metadata and controls
138 lines (116 loc) · 4.15 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Build, Test, and Analyse
on:
workflow_call:
jobs:
build:
name: Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.nuget/packages
!~/.nuget/packages/unwanted
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- name: Install dependencies
run: dotnet restore --locked-mode
- name: Build
run: dotnet build -c Release --no-restore
- name: Test
run: dotnet test -c Release --no-restore --collect:"XPlat Code Coverage" --logger "trx;LogFilePrefix=TestResults" --results-directory TestResults -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- name: upload TestResults
uses: actions/upload-artifact@v3
with:
name: test-results-${{ github.sha }}
path: |
./TestResults/*.trx
./TestResults/**/coverage.opencover.xml
integration-test:
name: Report Tests
runs-on: ubuntu-latest
needs: [build]
permissions:
id-token: write
contents: read
checks: write
pull-requests: write
steps:
- uses: actions/checkout@v3
- name: download test results
uses: actions/download-artifact@v3
with:
name: test-results-${{ github.sha }}
- name: Report Tests
id: report-tests
uses: dorny/test-reporter@v1
with:
name: .Net Tests
path: "**.trx"
reporter: dotnet-trx
- name: Add Test Result PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
hide_and_recreate: true
hide_classify: "OUTDATED"
message: Tests run with ${{ steps.report-tests.outputs.passed }} passed and ${{ steps.report-tests.outputs.failed }} failed in ${{ steps.report-tests.outputs.time }}ms.
analysis:
name: Analyse
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: cache
uses: actions/cache@v3
with:
path: |
~/.nuget/packages
!~/.nuget/packages/unwanted
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- name: Install dependencies
run: dotnet restore --locked-mode
- name: Install SonarCloud scanners
run: |
dotnet tool install --global dotnet-sonarscanner
- name: download test results
uses: actions/download-artifact@v3
with:
name: test-results-${{ github.sha }}
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet-sonarscanner begin /k:"${{ secrets.SONAR_PROJECT_KEY }}" /o:"${{ secrets.SONAR_ORG_KEY }}" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="./*/coverage.opencover.xml"
dotnet build -c Release --no-restore
dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
checkov:
name: Checkov
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Test Terraform with Checkov
id: checkov
uses: bridgecrewio/checkov-action@master
with:
directory: terraform/
framework: terraform