Skip to content

Commit

Permalink
Add jobs to fully test both netstandard2.0 and netstandard2.1 targets
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko committed Nov 19, 2024
1 parent a346138 commit 7ad31a6
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 22 deletions.
120 changes: 99 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,81 @@ concurrency:
# SEQUENTIAL_ENV: SEQUENTIAL_TEST_RUN

jobs:
test-windows:
name: Tests on Windows
test-windows-core:
name: Tests on Windows for Core
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
dotnet: ['net6.0', 'net7.0', 'net8.0', 'net462', 'net471', 'net472', 'net48', 'net481']
dotnet: ['net6.0', 'net7.0', 'net8.0']
cloud_env: ['AZURE', 'GCP', 'AWS']
target_framework: ['netstandard2.0', 'netstandard2.1']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
dotnet-quality: 'ga'
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Setup dotnet-coverage
run: dotnet tool install --global dotnet-coverage --version 17.8.4
- name: Decrypt Parameters
shell: bash
env:
PARAMETER_SECRET: ${{ secrets.PARAMETER_SECRET }}
run: |
gpg --quiet --batch --yes --decrypt --passphrase="$PARAMETER_SECRET" \
./.github/workflows/parameters/parameters_${{ matrix.cloud_env }}.json.gpg > Snowflake.Data.Tests/parameters.json
- name: Build Driver
run: |
cd Snowflake.Data.Tests
dotnet restore
dotnet build -f ${{ matrix.dotnet }} '-p:DefineAdditionalConstants=SF_PUBLIC_ENVIRONMENT'
env:
SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
- name: Run Tests
run: |
cd Snowflake.Data.Tests
dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build -l console;verbosity=normal" --output windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml --output-format cobertura --settings coverage.config
env:
snowflake_cloud_env: ${{ matrix.cloud_env }}
net_version: ${{ matrix.dotnet }}
SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
- name: Upload Code Coverage Report
uses: actions/upload-artifact@v4
with:
name: code-coverage-report_windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
path: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml

- name: Upload Test Performance Report
uses: actions/upload-artifact@v4
with:
name: tests-performance_windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
path: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_performance.csv
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
# without the token code cov may fail because of Github limits https://github.com/codecov/codecov-action/issues/557
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
fail_ci_if_error: true
files: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml

test-windows-framework:
name: Tests on Windows for Framework
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
dotnet: ['net462', 'net471', 'net472', 'net48', 'net481']
cloud_env: ['AZURE', 'GCP', 'AWS']
target_framework: ['netstandard2.0']
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -61,31 +128,34 @@ jobs:
cd Snowflake.Data.Tests
dotnet restore
dotnet build -f ${{ matrix.dotnet }} '-p:DefineAdditionalConstants=SF_PUBLIC_ENVIRONMENT'
env:
SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
- name: Run Tests
run: |
cd Snowflake.Data.Tests
dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build -l console;verbosity=normal" --output windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml --output-format cobertura --settings coverage.config
dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build -l console;verbosity=normal" --output windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml --output-format cobertura --settings coverage.config
env:
snowflake_cloud_env: ${{ matrix.cloud_env }}
net_version: ${{ matrix.dotnet }}
SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
- name: Upload Code Coverage Report
uses: actions/upload-artifact@v4
with:
name: code-coverage-report_windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}
path: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml
name: code-coverage-report_windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
path: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml

- name: Upload Test Performance Report
uses: actions/upload-artifact@v4
with:
name: tests-performance_windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}
path: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_performance.csv
name: tests-performance_windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
path: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_performance.csv
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
# without the token code cov may fail because of Github limits https://github.com/codecov/codecov-action/issues/557
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
fail_ci_if_error: true
files: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml
files: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml

test-linux:
name: Tests on Linux
Expand All @@ -95,6 +165,7 @@ jobs:
matrix:
dotnet: ['net6.0', 'net7.0', 'net8.0']
cloud_env: ['AZURE', 'GCP', 'AWS']
target_framework: ['netstandard2.0', 'netstandard2.1']
steps:
- uses: actions/checkout@v4
- name: Setup Dotnet
Expand All @@ -121,30 +192,33 @@ jobs:
run: |
dotnet restore
dotnet build '-p:DefineAdditionalConstants=SF_PUBLIC_ENVIRONMENT'
env:
SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
- name: Run Tests
run: |
cd Snowflake.Data.Tests
dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build -l console;verbosity=normal" --output linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml --output-format cobertura --settings coverage.config
dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build -l console;verbosity=normal" --output linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml --output-format cobertura --settings coverage.config
env:
snowflake_cloud_env: ${{ matrix.cloud_env }}
net_version: ${{ matrix.dotnet }}
SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
- name: Upload Code Coverage Report
uses: actions/upload-artifact@v4
with:
name: code-coverage-report_linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}
path: Snowflake.Data.Tests/linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml
name: code-coverage-report_linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
path: Snowflake.Data.Tests/linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml
- name: Upload Test Performance Report
uses: actions/upload-artifact@v4
with:
name: tests-performance_linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}
path: Snowflake.Data.Tests/linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_performance.csv
name: tests-performance_linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
path: Snowflake.Data.Tests/linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_performance.csv
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
# without the token code cov may fail because of Github limits https://github.com/codecov/codecov-action/issues/557
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
fail_ci_if_error: true
files: Snowflake.Data.Tests/linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml
files: Snowflake.Data.Tests/linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml

test-mac:
name: Tests on MAC
Expand All @@ -154,6 +228,7 @@ jobs:
matrix:
dotnet: ['net6.0', 'net7.0', 'net8.0']
cloud_env: ['AZURE', 'GCP', 'AWS']
target_framework: ['netstandard2.0', 'netstandard2.1']
steps:
- uses: actions/checkout@v4
- name: Setup Dotnet
Expand All @@ -180,27 +255,30 @@ jobs:
run: |
dotnet restore
dotnet build '-p:DefineAdditionalConstants=SF_PUBLIC_ENVIRONMENT'
env:
SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
- name: Run Tests
run: |
cd Snowflake.Data.Tests
dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build -l console;verbosity=normal" --output macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml --output-format cobertura --settings coverage.config
dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build -l console;verbosity=normal" --output macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml --output-format cobertura --settings coverage.config
env:
snowflake_cloud_env: ${{ matrix.cloud_env }}
net_version: ${{ matrix.dotnet }}
SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
- name: Upload Code Coverage Report
uses: actions/upload-artifact@v4
with:
name: code-coverage-report_macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}
path: Snowflake.Data.Tests/macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml
name: code-coverage-report_macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
path: Snowflake.Data.Tests/macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml
- name: Upload Test Performance Report
uses: actions/upload-artifact@v4
with:
name: tests-performance_macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}
path: Snowflake.Data.Tests/macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_performance.csv
name: tests-performance_macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
path: Snowflake.Data.Tests/macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_performance.csv
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
# without the token code cov may fail because of Github limits https://github.com/codecov/codecov-action/issues/557
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
fail_ci_if_error: true
files: Snowflake.Data.Tests/macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml
files: Snowflake.Data.Tests/macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml
12 changes: 11 additions & 1 deletion Snowflake.Data.Tests/Snowflake.Data.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="Tomlyn.Signed" Version="0.17.0" />
<ProjectReference Include="..\Snowflake.Data\Snowflake.Data.csproj" />
</ItemGroup>

<ItemGroup Condition="$(SF_TARGET_FRAMEWORK) != ''">
<ProjectReference Include="..\Snowflake.Data\Snowflake.Data.csproj">
<SetTargetFramework>TargetFramework=$(SF_TARGET_FRAMEWORK)</SetTargetFramework>
</ProjectReference>
</ItemGroup>

<ItemGroup Condition="$(SF_TARGET_FRAMEWORK) == ''">
<ProjectReference Include="..\Snowflake.Data\Snowflake.Data.csproj"/>
</ItemGroup>

<Target Name="CopyCustomContent" AfterTargets="AfterBuild">
<Copy SourceFiles="parameters.json" DestinationFolder="$(OutDir)" />
<Copy SourceFiles="App.config" DestinationFolder="$(OutDir)" />
Expand Down
15 changes: 15 additions & 0 deletions Snowflake.Data.Tests/UnitTests/TargetFrameworkReporterTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using NUnit.Framework;
using Snowflake.Data.Core;

namespace Snowflake.Data.Tests.UnitTests
{
[TestFixture]
public class TargetFrameworkReporterTest
{
[Test]
public void TestTargetFramework()
{
TargetFrameworkReporter.Report();
}
}
}
19 changes: 19 additions & 0 deletions Snowflake.Data/Core/TargetFrameworkReporter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Snowflake.Data.Log;

namespace Snowflake.Data.Core
{
internal class TargetFrameworkReporter
{
private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger<TargetFrameworkReporter>();

public static void Report()
{
#if NETSTANDARD2_1
s_logger.Warn($"Using library targeted to netstandard 2.1");
#endif
#if NETSTANDARD2_0
s_logger.Warn($"Using library targeted to netstandard 2.0");
#endif
}
}
}

0 comments on commit 7ad31a6

Please sign in to comment.