diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 0000000..d5172d6 --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -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 }}" \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index f23e909..623127f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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