Skip to content

Commit 6d0cda9

Browse files
sayantandeydanieledwardgeorgehitchcockDaniel Hitchcock
authored
In House HTML Report, Update framework and dependencies (#17)
* Update framework and dependencies (#16) * Update project dependencies * Added missing dependency to Newtonsoft.json * Modified references to SQLClient libraries * Update project to .NET core 8 * Changing InvariantGlobalization to false to avoid runtime error * Added SQL Server 2022 Support * Corrected SQL Parsers --------- Co-authored-by: Daniel Hitchcock <Daniel.Hitchcock@zigup.com> * test data, net8 comp * HTML Report In house, other bug fixes.. --------- Co-authored-by: danieledwardgeorgehitchcock <daniel.edward.george.hitchcock@gmail.com> Co-authored-by: Daniel Hitchcock <Daniel.Hitchcock@zigup.com>
1 parent aea57e3 commit 6d0cda9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+5681
-6050
lines changed

.github/workflows/dotnet-desktop.yml

Lines changed: 67 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,93 @@
1-
# This workflow uses actions that are not certified by GitHub.
2-
# They are provided by a third-party and are governed by
3-
# separate terms of service, privacy policy, and support
4-
# documentation.
5-
6-
# This workflow will build, test, sign and package a WPF or Windows Forms desktop application
7-
# built on .NET Core.
8-
# To learn how to migrate your existing application to .NET Core,
9-
# refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework
10-
#
11-
# To configure this workflow:
12-
#
13-
# 1. Configure environment variables
14-
# GitHub sets default environment variables for every workflow run.
15-
# Replace the variables relative to your project in the "env" section below.
16-
#
17-
# 2. Signing
18-
# Generate a signing certificate in the Windows Application
19-
# Packaging Project or add an existing signing certificate to the project.
20-
# Next, use PowerShell to encode the .pfx file using Base64 encoding
21-
# by running the following Powershell script to generate the output string:
22-
#
23-
# $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte
24-
# [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt'
25-
#
26-
# Open the output file, SigningCertificate_Encoded.txt, and copy the
27-
# string inside. Then, add the string to the repo as a GitHub secret
28-
# and name it "Base64_Encoded_Pfx."
29-
# For more information on how to configure your signing certificate for
30-
# this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing
31-
#
32-
# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key".
33-
# See "Build the Windows Application Packaging project" below to see how the secret is used.
34-
#
35-
# For more information on GitHub Actions, refer to https://github.com/features/actions
36-
# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications,
37-
# refer to https://github.com/microsoft/github-actions-for-desktop-apps
38-
39-
name: .NET Core Desktop
1+
name: Release Build
402

413
on:
424
push:
435
branches: [ "main" ]
44-
# pull_request:
45-
# branches: [ "main" ]
46-
47-
env:
48-
APP_NAME: SQLServerCoverage
49-
APP_VERSION: 2.2
50-
DOTNET_VERSION: '7.0.x'
6+
paths:
7+
- 'src/**'
8+
- '.github/workflows/**'
519

5210
permissions:
5311
contents: write
5412

5513
jobs:
14+
prepare:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
version: ${{ steps.get_version.outputs.version }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
# Extract version from csproj
22+
- name: Get Version
23+
id: get_version
24+
shell: pwsh
25+
run: |
26+
$xml = [xml](Get-Content ./src/SQLServerCoverageCore/SQLServerCoverageCore.csproj)
27+
$version = $xml.Project.PropertyGroup.Version
28+
echo "version=$version" >> $env:GITHUB_OUTPUT
29+
echo "Extracted version: $version"
30+
5631
build:
32+
needs: prepare
5733
runs-on: windows-latest
5834
strategy:
5935
matrix:
36+
# Define target platforms
6037
os: [win10-x64, ubuntu.20.04-x64, linux-x64, osx-x64]
6138

62-
# Build Steps
39+
env:
40+
APP_NAME: SQLServerCoverage
41+
APP_VERSION: ${{ needs.prepare.outputs.version }}
42+
DOTNET_VERSION: '8.0.x'
43+
6344
steps:
64-
- name: Checkout
65-
uses: actions/checkout@v3
45+
- name: Checkout Repository
46+
uses: actions/checkout@v4
6647

67-
# Refer : https://github.com/actions/setup-dotnet/blob/main/action.yml
6848
- name: Setup .NET
69-
uses: actions/setup-dotnet@v3
49+
uses: actions/setup-dotnet@v4
7050
with:
7151
dotnet-version: ${{ env.DOTNET_VERSION }}
7252

73-
- name: 'Show dotnet info'
74-
run: dotnet --info
75-
76-
- name: Build and publish app for multiple platform
77-
run: >
78-
dotnet publish src/SQLServerCoverageCore/SQLServerCoverageCore.csproj
79-
-c Release -r ${{ matrix.os }} -o "releases/${{ matrix.os }}/${{env.APP_NAME}}"
80-
--sc true
53+
# Build and publish for each platform
54+
- name: Build and Publish
55+
run: |
56+
dotnet publish src/SQLServerCoverageCore/SQLServerCoverageCore.csproj `
57+
-c Release `
58+
-r ${{ matrix.os }} `
59+
-o "releases/${{ matrix.os }}/${{env.APP_NAME}}" `
60+
--sc true `
61+
-p:Version=${{ env.APP_VERSION }}
8162
82-
- name: 'Zipping ${{env.APP_NAME}}_${{ env.APP_VERSION }} for release'
83-
run: >
84-
echo "current path $pwd" &&
85-
New-Item -ItemType Directory -Force -Path ./releases/packages &&
86-
Compress-Archive -Path "./releases/${{ matrix.os }}/${{env.APP_NAME}}/*" -DestinationPath "./releases/packages/${{env.APP_NAME}}_${{ env.APP_VERSION }}_${{ matrix.os }}.zip"
63+
# Create release packages
64+
- name: Create Release Package
65+
run: |
66+
New-Item -ItemType Directory -Force -Path ./releases/packages
67+
Compress-Archive `
68+
-Path "./releases/${{ matrix.os }}/${{env.APP_NAME}}/*" `
69+
-DestinationPath "./releases/packages/${{env.APP_NAME}}_${{ env.APP_VERSION }}_${{ matrix.os }}.zip"
8770
88-
89-
- name: Releasing github package for ${{ matrix.os }}
90-
uses: softprops/action-gh-release@v1
71+
# Create GitHub release and upload artifacts
72+
- name: Create GitHub Release
73+
uses: softprops/action-gh-release@v2
9174
with:
92-
name: SQLServerCoverage V${{ env.APP_VERSION }}
93-
body: Releasing ${{env.APP_NAME}}_${{ env.APP_VERSION }}
75+
name: SQLServerCoverage v${{ env.APP_VERSION }}
76+
body: |
77+
SQLServerCoverage Version ${{ env.APP_VERSION }}
78+
79+
## Platform Specific Builds
80+
- Windows (win10-x64)
81+
- Ubuntu 20.04 (ubuntu.20.04-x64)
82+
- Linux (linux-x64)
83+
- macOS (osx-x64)
84+
85+
Please check the release notes for detailed changes.
9486
tag_name: v${{ env.APP_VERSION }}
95-
files: ./releases/packages/${{env.APP_NAME}}_${{ env.APP_VERSION }}_${{ matrix.os }}.zip
96-
token: ${{ secrets.GITHUB_TOKEN }}
87+
files: ./releases/packages/${{env.APP_NAME}}_${{ env.APP_VERSION }}_${{ matrix.os }}.zip
88+
token: ${{ secrets.GITHUB_TOKEN }}
9789
generate_release_notes: true
90+
draft: false
91+
prerelease: false
92+
93+

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# SQLServerCoverage
2-
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/sayantandey/SQLServerCoverage/blob/main/LICENSE)
3-
[![GitHub release](https://img.shields.io/github/release/sayantandey/SQLServerCoverage.svg)](https://github.com/sayantandey/SQLServerCoverage/releases/latest)
4-
[![.NET Core Desktop](https://github.com/sayantandey/SQLServerCoverage/actions/workflows/dotnet-desktop.yml/badge.svg)](https://github.com/sayantandey/SQLServerCoverage/actions/workflows/dotnet-desktop.yml)
5-
[![Github All Releases](https://img.shields.io/github/downloads/sayantandey/SQLServerCoverage/total.svg)]()
2+
63
##### Code coverage for SQL Server T-SQL
74

85
##### Extended From [SQLCover](https://github.com/GoEddie/SQLCover).
@@ -26,6 +23,11 @@
2623
:white_check_mark: Output SQL Server Generated Messages during Execution
2724

2825
:white_check_mark: Generate latest Cobertura Report using 0.4 DTD
26+
27+
:white_check_mark: Custom HTML Report (Without 3rd party dependency)
28+
29+
:white_check_mark: Upgraded to `.NET 8.0`
30+
2931
____
3032

3133
# Index
@@ -54,7 +56,7 @@ Read the [build](#build ) section for building the tool.
5456
* From the project root directory
5557

5658
```
57-
dotnet publish src/SQLServerCoverageCore/SQLServerCoverageCore.csproj -c Release -r <RUNTIME_IDENTIFIER> -o "releases/<RUNTIME_IDENTIFIER>" --self-contained true -p:PublishSingleFile=true
59+
dotnet publish src/SQLServerCoverageCore/SQLServerCoverageCore.csproj -c Release -r win-x64 -o "releases/<RUNTIME_IDENTIFIER>" --self-contained true -p:PublishSingleFile=true
5860
```
5961

6062
> For `RUNTIME_IDENTIFIER` put the os version for your system.
@@ -75,13 +77,14 @@ ___
7577
### 1. CLI
7678

7779
```bash
78-
SQLServerCoverageCore
80+
SQLServerCoverageCore --help
81+
Copyright (C) 2024 SQLServerCoverageCore
7982

8083
-v, --verbose Set output to verbose messages.
8184

8285
-c, --command Required. Choose command to run: Currently only Get-CoverTSql available
8386

84-
-e, --exportType Required. Choose export options : Export-OpenXml, Export-Html, Export-Cobertura
87+
-e, --exportType Required. Choose export options: Export-OpenXml, Export-Html, Export-ReportGeneratorHtml, Export-Cobertura
8588

8689
-b, --debug Prints out detailed output.
8790

@@ -97,8 +100,7 @@ SQLServerCoverageCore
97100

98101
-t, --timeout Wait time in Seconds before terminating the attempt to execute test SQL command
99102

100-
-i, --ignore Space separated list of database objects to ignore. Regex Accepted. Case
101-
sensitive depending on collation. Ex."sp_dummy_proc* sp_test_proc"
103+
-i, --ignore Space separated list of database objects to ignore. Regex Accepted. Case sensitive depending on collation. Ex."sp_dummy_proc* sp_test_proc"
102104

103105
--help Display this help screen.
104106

@@ -112,7 +114,7 @@ SQLServerCoverageCore
112114
Generate the coverage report as xml
113115

114116
```bash
115-
SQLServerCoverageCore -v true -c Get-CoverTSql -e Export-OpenXml -d <DATABASE_NAME> -q <Query> -o <OUTPUT_PATH> -k <CONNECTION_STRING> -t <connection_timeout> -i <ignore_sql_objects>
117+
SQLServerCoverageCore -v true -c Get-CoverTSql -e Export-OpenXml -d <DATABASE_NAME> -q <Query> -o <OUTPUT_PATH> -k <CONNECTION_STRING>
116118
```
117119

118120
This will generate the OpenCover xml report in `OUTPUT_PATH` along with the source files in the database it is executed.
@@ -122,7 +124,7 @@ This will generate the OpenCover xml report in `OUTPUT_PATH` along with the sour
122124
Generate the coverage report as html. It leverages ReportGenerator to Generate Inline HTML Report of Coverage.
123125

124126
```bash
125-
SQLServerCoverageCore -v true -c Get-CoverTSql -e Export-Html -d <DATABASE_NAME> -q <Query> -o <OUTPUT_PATH> -k <CONNECTION_STRING> -t <connection_timeout> -i <ignore_sql_objects>
127+
SQLServerCoverageCore -v true -c Get-CoverTSql -e Export-Html -d <DATABASE_NAME> -q <Query> -o <OUTPUT_PATH> -k <CONNECTION_STRING>
126128
```
127129

128130
![](./example/Coverage%20Check%20CLI.gif)
@@ -137,7 +139,7 @@ It can be used with tSQLt framework to check the coverage.
137139

138140
If you have a script you want to cover then you can call:
139141
```
140-
SQLServerCoverageCore -v true -c Get-CoverTSql -e Export-OpenXml -d <DATABASE_NAME> -q "exec tSQLt.RunAll" -o <OUTPUT_PATH> -k <CONNECTION_STRING> -t <connection_timeout> -i <ignore_sql_objects>
142+
SQLServerCoverageCore -v true -c Get-CoverTSql -e Export-OpenXml -d <DATABASE_NAME> -q "exec tSQLt.RunAll" -o <OUTPUT_PATH> -k <CONNECTION_STRING>
141143
```
142144

143145
This will generate a openxml coverage report where you can either examine the amount of statement covered or use the report to generate HTML report using [ReportGenerator](https://github.com/danielpalme/ReportGenerator).

0 commit comments

Comments
 (0)