-
Notifications
You must be signed in to change notification settings - Fork 2
159 lines (134 loc) · 5.87 KB
/
CodeQuality.yml
File metadata and controls
159 lines (134 loc) · 5.87 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Build & Test & SonarQube
on:
push:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
checks: write # dorny/test-reporter check run + annotations
pull-requests: write # sticky coverage comment
jobs:
# SonarCloud analysis. Kept as a single instance on a single OS: running
# SonarScanner across an OS matrix would double-submit analysis to SonarCloud.
# The job id/name "build" is preserved so existing branch-protection checks keep working.
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v5.2.0
with:
distribution: 'temurin'
java-version: '17'
overwrite-settings: false
- name: Setup dotnet
uses: actions/setup-dotnet@v5.1.0
with:
dotnet-version: '10.0.x'
- name: Restore dependencies
run: dotnet restore EcoreNetto.sln
- name: Sonarqube Begin
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_SCANNER_OPTS: "-Xmx4096m"
run: |
dotnet tool install --global dotnet-sonarscanner
dotnet tool install --global dotnet-coverage
dotnet sonarscanner begin /k:"STARIONGROUP_EcoreNetto" /o:"stariongroup" /d:sonar.token="$SONAR_TOKEN" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
- name: Build
run: dotnet build --no-restore --no-incremental /p:ContinuousIntegrationBuild=true
- name: Test with the dotnet CLI
run: dotnet-coverage collect "dotnet test EcoreNetto.sln --no-restore --no-build --verbosity normal" -f xml -o "coverage.xml"
- name: Sonarqube end
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN"
# Cross-platform build & test that surfaces results/coverage on the PR.
# Needs no secrets, so it also produces signal on fork PRs (where SONAR_TOKEN is absent).
build-test:
name: Build & Test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6.0.2
- name: Setup dotnet
uses: actions/setup-dotnet@v5.1.0
with:
dotnet-version: '10.0.x'
- name: Restore dependencies
run: dotnet restore EcoreNetto.sln
- name: Build
run: dotnet build EcoreNetto.sln --no-restore
# Cobertura (the default XPlat Code Coverage format) is what the coverage
# summary action below consumes, so the opencover coverlet.runsettings is
# intentionally not passed here.
- name: Test
run: >
dotnet test EcoreNetto.sln --no-build
--logger "trx;LogFileName=test-results.trx"
--collect:"XPlat Code Coverage"
--results-directory ${{ github.workspace }}/TestResults
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}
path: TestResults/**
- name: Publish test report
if: always()
uses: dorny/test-reporter@d3cb5605561a46347256b466ef836b85076ad522 # v2.5.0
with:
name: Tests (${{ matrix.os }})
path: TestResults/**/*.trx
reporter: dotnet-trx
fail-on-error: false
# Coverage comment: only once (ubuntu leg) and only on pull requests.
# The per-project test runs each emit their own coverage.cobertura.xml that also
# includes the shared production assemblies. Merge them into a single, de-duplicated
# report first so each assembly's coverage is the union across all suites (otherwise a
# shared assembly is counted once per file and its reported coverage is diluted).
- name: Merge coverage reports
if: matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request'
uses: danielpalme/ReportGenerator-GitHub-Action@ee3806a36b8b2eb9594cb3e5fae045af7e5ead10 # v5.5.6
with:
reports: TestResults/**/coverage.cobertura.xml
targetdir: CoverageReport
reporttypes: Cobertura
- name: Code coverage summary
if: matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request'
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
with:
filename: CoverageReport/Cobertura.xml
format: markdown
output: both
- name: Append coverage to job summary
if: matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request'
run: cat code-coverage-results.md >> "$GITHUB_STEP_SUMMARY"
- name: Post coverage comment on PR
if: matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd # v2.8.0
with:
header: code-coverage
recreate: true
path: code-coverage-results.md
# Validate the publishable single-file tool binary that release.yml ships.
# Keep the publish command in sync with .github/workflows/release.yml.
validate-tool:
name: Validate ECoreNetto.Tools binary
runs-on: windows-latest
steps:
- uses: actions/checkout@v6.0.2
- name: Setup dotnet
uses: actions/setup-dotnet@v5.1.0
with:
dotnet-version: '10.0.x'
- name: Publish ECoreNetto.Tools (win-x64 single-file, self-contained)
run: dotnet publish ECoreNetto.Tools/ECoreNetto.Tools.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -o ReleaseBuilds
- name: Smoke-run the published binary
run: ./ReleaseBuilds/ECoreNetto.Tools.exe --help