-
Notifications
You must be signed in to change notification settings - Fork 5
120 lines (93 loc) · 5.02 KB
/
CodeQuality.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
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
name: Build & Test & SonarQube
on:
push:
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up Docker
uses: docker/setup-buildx-action@v3
- name: cdp4-test-database-community-edition Image
run: docker pull stariongroup/cdp4-test-database-community-edition:3.4.0
- name: Start PostgreSQL Container
run: |
docker run -it -d \
-e POSTGRES_PASSWORD=postgres \
-p 5432:5432 \
--tmpfs /var/lib/postgresql/data:rw \
--name comet-db \
stariongroup/cdp4-test-database-community-edition:3.4.0
- name: Wait for PostgreSQL to be ready
run: |
until docker exec comet-db pg_isready -U postgres; do
echo "Waiting for PostgreSQL to be ready..."
sleep 5
done
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
overwrite-settings: false
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: add Starion GitHub nuget feed
run: dotnet nuget add source https://nuget.pkg.github.com/STARIONGROUP/index.json -n GHRHEA -u gh -p ${{ secrets.GH_PR_TOKEN }} --store-password-in-clear-text
- name: Restore dependencies
run: dotnet restore COMET-WebServices.sln
- name: Sonarqube Begin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet tool install --global dotnet-sonarscanner
dotnet sonarscanner begin /k:"STARIONGROUP_CDP4-COMET-WebServices-Community-Edition" /o:"stariongroup" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.coverageReportPaths="./CoverageResultsReport/SonarQube.xml"
- name: Build
run: dotnet build COMET-WebServices.sln -c Debug --no-restore /p:ContinuousIntegrationBuild=true
- name: Run Unit Tests and Compute Coverage
run: dotnet test COMET-WebServices.sln --no-restore --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutput="../CoverageResults/" /p:MergeWith="../CoverageResults/coverage.json" /p:CoverletOutputFormat=\"cobertura,opencover,json\"
- name: install dotnet-coverage
run: dotnet tool install --global dotnet-coverage
- name: install dotnet-reportgenerator-globaltool
run: dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Start API
run: dotnet-coverage collect --output CoverageResults/integration.test.report.coverage.xml --output-format cobertura --session-id integrationtestsession "dotnet run --project CometServer/CometServer.csproj -c Debug" &
- name: Wait for API to start
run: sleep 60 # Adjust as necessary to ensure the API is up
- name: Checkout Integration Test Suite
uses: actions/checkout@v4
with:
repository: STARIONGROUP/ecss-10-25-annexc-integration-tests
path: integration-tests
- name: Zip Integration Test Results
run: |
cd integration-tests/Data
zip -r Data.zip .
- name: Post Zipped Results to REST API
run: |
curl --form file=@"integration-tests/Data/Data.zip" http://localhost:5000/Data/Exchange
- name: Restore Dependencies for Integration Tests
run: dotnet restore integration-tests/IntegrationTestSuite/WebservicesIntegrationTests.sln
- name: Run Integration Tests
run: dotnet test integration-tests/IntegrationTestSuite/WebservicesIntegrationTests.sln --logger "trx;LogFileName=test_results.trx" --verbosity detailed
- name: Shutdown Integration Test session
run: dotnet-coverage shutdown integrationtestsession
- name: merge integration tests with unit tests
run: dotnet-coverage merge --output-format cobertura --output CoverageResults/merged-coverage.cobertura.xml CoverageResults/*.cobertura.xml
- name: generate SonarQube compatible coverage report
run: reportgenerator -reports:CoverageResults/merged-coverage.cobertura.xml -targetdir:CoverageResultsReport -reporttypes:SonarQube -assemblyfilters:"-CDP4Common;-CDP4DalCommon;-CDP4JsonSerializer;-CDP4MessagePackSerializer;-FluentValidation;-HangFire*;-Serilog*"
- name: Stop PostgreSQL Container
run: docker stop comet-db && docker rm comet-db
- name: Sonarqube end
run: dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}