Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code coverage to static analysis #497

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/static-analysis.yml
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"
TestPath: /home/runner/work/Html2Markdown/Html2Markdown/test/Html2Markdown.Test/Files/
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 }}"
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added support extending existing Schemes for customisation
- Migrated to using xUnit and FluentAssertions for testing
- Added code coverage to static analysis

## [7.0.0.8] - 2024-08-15

Expand Down
Loading