Api features #812
Workflow file for this run
This file contains hidden or 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
| name: Build and Test | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| paths-ignore: | |
| - '**.md' | |
| - 'SignNow.Net/SignNow.Net.Examples/**' | |
| - '.github/workflows/release.yml' | |
| tags-ignore: | |
| - '**' | |
| pull_request: | |
| branches: | |
| - 'main' | |
| - 'develop' | |
| paths-ignore: | |
| - '**.md' | |
| tags-ignore: | |
| - '**' | |
| pull_request_target: | |
| branches: | |
| - 'main' | |
| - 'develop' | |
| paths-ignore: | |
| - '**.md' | |
| tags-ignore: | |
| - '**' | |
| env: | |
| COREHOST_TRACE: false | |
| DOTNET_CLI_TELEMETRY_OPTOUT: 1 # Disable sending usage data to Microsoft | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 # prevent the caching of the packages on the build machine | |
| DOTNET_NOLOGO: true # removes logo and telemetry message from first run of dotnet cli | |
| NUGET_XMLDOC_MODE: skip # prevent the download of the XML documentation for the packages | |
| COVERAGE_PATH: SignNow.Net.Test/bin/Debug | |
| # Do not generate summary otherwise it leads to duplicate errors in build log | |
| DOTNET_BUILD_ARGS: /consoleloggerparameters:NoSummary /property:GenerateFullPaths=true | |
| defaults: | |
| run: | |
| shell: pwsh | |
| # Workflow | |
| jobs: | |
| build: | |
| name: ${{ matrix.name }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Ubuntu | |
| - { name: 'Linux .NET 8', os: ubuntu-22.04, framework: 'net8.0', net-sdk: '8.0.x', target: 'netstandard2.1' } | |
| # macOs - disabled due to the same behavior as in Ubuntu | |
| # - { name: 'macOS .NET 8', os: macos-13, framework: 'net8.0' } | |
| # Windows | |
| - { name: 'Windows .NET 7', os: windows-latest, framework: 'net7.0', net-sdk: '7.0.x', target: 'netstandard2.0' } | |
| - { name: 'Windows .NET 8', os: windows-latest, framework: 'net8.0', net-sdk: '8.0.x', target: 'netstandard2.1' } | |
| - { name: 'Windows .NET 4.6', os: windows-latest, framework: 'net462', net-sdk: '8.0.x', target: 'net462' } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| # For pull_request_target (dependabot), checkout the PR head SHA | |
| ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }} | |
| - name: Get SDK Version | |
| id: props | |
| run: | | |
| $Props = [xml](Get-Content ./SignNow.props) | |
| $Version = $Props.Project.PropertyGroup.Version | |
| Write-Output "version=${Version}" >> $Env:GITHUB_OUTPUT | |
| Write-Host "✓ Found SignNow.NET SDK project version: $Version" | |
| - name: Setup JDK 17 (SonarQube requirement) | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ matrix.net-sdk }} | |
| - name: Setup Nuget Cache | |
| uses: actions/cache@v4 | |
| id: nuget-cache | |
| with: | |
| path: ~/.nuget | |
| key: ${{ runner.os }}-nuget-${{ matrix.framework }}-${{ hashFiles('**/*.csproj') }} | |
| restore-keys: ${{ runner.os }}-nuget- | |
| - name: Install SonarQube Scanner | |
| run: dotnet tool install --global dotnet-sonarscanner | |
| - name: Restore Nuget packages | |
| run: dotnet restore -v:n | |
| - name: Configure signNow API | |
| run: echo '${{ secrets.TEST_CREDITS_JSON }}' >> ${{ github.workspace }}/api-eval.signnow.com.json | |
| - name: Get SonarQube Project Key | |
| id: sonar | |
| run: | | |
| $SonarConfigPath = "${{ github.workspace }}/SonarQube.Analysis.xml" | |
| if (Test-Path $SonarConfigPath) { | |
| [xml]$SonarConfig = Get-Content $SonarConfigPath | |
| $ProjectKey = $SonarConfig.SonarQubeAnalysisProperties.Property | Where-Object { $_.Name -eq "sonar.projectKey" } | Select-Object -ExpandProperty '#text' | |
| if (-not [string]::IsNullOrWhiteSpace($ProjectKey)) { | |
| Write-Host "✓ Found SonarQube project key: $ProjectKey" | |
| Write-Output "project-key=${ProjectKey}" >> $Env:GITHUB_OUTPUT | |
| Write-Output "has-project-key=true" >> $Env:GITHUB_OUTPUT | |
| } else { | |
| Write-Warning "SonarQube project key is empty in configuration file" | |
| } | |
| } else { | |
| Write-Warning "SonarQube configuration file not found: $SonarConfigPath" | |
| } | |
| - name: SonarQube begin | |
| if: steps.sonar.outputs.has-project-key == 'true' | |
| run: | | |
| dotnet-sonarscanner begin ` | |
| /key:${{ steps.sonar.outputs.project-key }} ` | |
| /s:${{ github.workspace }}/SonarQube.Analysis.xml ` | |
| /v:"${{ steps.props.outputs.version }}" ` | |
| /d:sonar.projectBaseDir="${{ github.workspace }}" ` | |
| /d:sonar.token="${{ secrets.SONAR_SECRET }}" ` | |
| /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" ` | |
| /d:sonar.scanner.skipJreProvisioning=true | |
| - name: Run Tests on ${{ matrix.framework }} for TargetFramework ${{ matrix.target }} with Coverage | |
| run: | | |
| # Build the main library with framework targeting for SonarQube | |
| dotnet build SignNow.Net --configuration Debug --no-incremental ` | |
| /p:TargetFramework=${{ matrix.target }} ` | |
| ${{ env.DOTNET_BUILD_ARGS }} | |
| # Build the test project for the specific framework | |
| dotnet build SignNow.Net.Test --configuration Debug --no-incremental ` | |
| --framework ${{ matrix.framework }} ` | |
| ${{ env.DOTNET_BUILD_ARGS }} | |
| dotnet test SignNow.Net.Test --configuration Debug --no-build ` | |
| --framework ${{ matrix.framework }} ` | |
| --logger:trx --results-directory ./SignNow.Net.Test/TestResults ` | |
| /p:CollectCoverage=true | |
| - name: Save Code Coverage Results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: CoverageReports-${{ runner.os }}-${{ matrix.framework }}.zip | |
| path: ${{ env.COVERAGE_PATH }}/**/coverage* | |
| - name: SonarQube end | |
| if: steps.sonar.outputs.has-project-key == 'true' | |
| continue-on-error: true | |
| run: dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_SECRET }}" | |
| - name: Test Release Notes parser | |
| if: (runner.os == 'macOS' || runner.os == 'Linux') | |
| shell: bash | |
| run: | | |
| .github/release-notes.sh CHANGELOG.md | |
| - name: Check entire Solution Compilation and Packaging | |
| run: | | |
| # Build entire solution normally to ensure all projects are compiled | |
| dotnet build SignNow.Net.sln --configuration Debug --no-restore ${{ env.DOTNET_BUILD_ARGS }} | |
| dotnet pack --configuration Release --output ./SignNow.Net/bin/Publish SignNow.Net | |
| - name: Upload Code Coverage Report (Codecov.io) | |
| if: env.CODECOV_TOKEN != '' | |
| continue-on-error: true | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| name: ${{ runner.os }}-codecov-${{ matrix.framework }} | |
| flags: ${{ runner.os }},${{ matrix.target }} | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ${{ env.COVERAGE_PATH }}/${{ matrix.framework }}/coverage.${{ matrix.framework }}.opencover.xml | |
| fail_ci_if_error: false |