-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add code coverage to static analysis
Closes #496
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Static Analysis | ||
on: | ||
push: | ||
branches: | ||
- develop | ||
paths: | ||
- 'src/**' | ||
- 'test/**' | ||
- '**.sln' | ||
- '.github/workflows/static-analysis.yml' | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
paths: | ||
- 'src/**' | ||
- 'test/**' | ||
- '**.sln' | ||
- '.github/workflows/static-analysis.yml' | ||
|
||
env: | ||
PROJECT_NAME: 'baynezy_Html2Markdown' | ||
ORGANISATION: 'baynezy' | ||
TEST_FILTER: "Category!=LocalTest" | ||
|
||
jobs: | ||
build: | ||
name: Build and analyse | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 17 | ||
distribution: 'zulu' | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # This disables shallow clones. This allows SonarQube to access the history of the project to perform analysis. | ||
- name: Cache SonarQube Cloud packages | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.sonar/cache | ||
key: ${{ runner.os }}-sonar | ||
restore-keys: ${{ runner.os }}-sonar | ||
- name: Cache SonarQube Cloud scanner | ||
id: cache-sonar-scanner | ||
uses: actions/cache@v4 | ||
with: | ||
path: .sonar/scanner | ||
key: ${{ runner.os }}-sonar-scanner | ||
restore-keys: ${{ runner.os }}-sonar-scanner | ||
- name: Install SonarQube Cloud scanner | ||
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' | ||
shell: bash | ||
run: | | ||
mkdir -p .sonar/scanner | ||
dotnet tool update dotnet-sonarscanner --tool-path .sonar/scanner | ||
- name: Install dotCover | ||
shell: bash | ||
run: | | ||
dotnet tool install --global JetBrains.dotCover.GlobalTool | ||
- name: Build, run code coverage, and analyze | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
shell: bash | ||
run: | | ||
filter="" | ||
if [ "${{ env.TEST_FILTER }}" != "" ]; then | ||
filter="--filter ${{ env.TEST_FILTER }}" | ||
fi | ||
.sonar/scanner/dotnet-sonarscanner begin /k:"${{ env.PROJECT_NAME }}" /o:"${{ env.ORGANISATION }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.dotcover.reportsPaths=dotCover.Output.html | ||
dotnet build | ||
dotnet dotcover test $filter --dcReportType=HTML | ||
.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" |