Skip to content

Fix unit tests

Fix unit tests #213

Workflow file for this run

name: CI
on:
push:
branches: [ master ]
pull_request: ~
workflow_dispatch: ~
jobs:
lint:
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
- name: Install .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x.x
- name: Set up dotnet tools
run: make install-tools
- name: Check style with dotnet-format
run: make lint
Security_Code_Scan:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Install .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x.x
- name: Set up dotnet tools and dependencies
run: make install
- name: Run security analysis
run: make scan
Coverage_Requirements:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x.x
- name: Set up dotnet tools and dependencies
run: make install
- name: Check if test suite coverage meets requirements
run: make coverage-check
Upload_Coverage_Report:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up dotnet tools and dependencies
run: make install
- name: Generate coverage report
run: make coverage
- name: Upload lcov coverage report to Coveralls
uses: coverallsapp/github-action@master
with:
path-to-lcov: coveragereport/lcov.info
github-token: ${{ secrets.GITHUB_TOKEN }}
NET_Tests:
# derived from https://dev.to/felipetofoli/github-actions-for-net-full-framework-build-and-test-299h
runs-on: windows-2022
env:
EASYPOST_TEST_API_KEY: "123"
EASYPOST_PROD_API_KEY: "123"
strategy:
matrix:
name: [ 'net462', 'netstandard2.0', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0' ]
include:
- name: net462
framework: net462
- name: netstandard2.0
# can't run tests on .NET Standard, it's just a bridge between .NET Framework and .NET.
# So we'll target .NET Framework 4.6.2
# More notes at the bottom of this file
framework: net462
- name: netcoreapp3.1
framework: netcoreapp3.1
- name: net5.0
framework: net5.0
- name: net6.0
framework: net6.0
- name: net7.0
framework: net7.0
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install .NET SDK
uses: actions/setup-dotnet@v3
with:
# .NET Core 3.1 and .NET 5 are deprecated and removed from GitHub Actions, we need to manually install them
dotnet-version: |
3.1.x
5.x.x
7.x.x
- name: Setup MSBuild
uses: microsoft/[email protected]
- name: Setup Nuget
uses: NuGet/[email protected]
- name: Load NuGet package cache
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ matrix.framework }}-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore NuGet Packages
run: make restore
# Pull in fixtures submodule
- name: Set up dotnet tools and dependencies
run: make install
# Run the unit tests in a specific framework (verify that the library works in that framework)
- name: Run Tests
run: make test-fw fw=${{ matrix.framework }}
FSharp_Compatibility:
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x.x
- name: Setup MSBuild
uses: microsoft/[email protected]
- name: Setup Nuget
uses: NuGet/[email protected]
- name: Setup VSTest
uses: darenm/[email protected]
- name: Restore NuGet Packages
run: make restore
# Pull in fixtures submodule
- name: Set up dotnet tools and dependencies
run: make install
# Build the test project
- name: Build Solution
run: msbuild EasyVCR.Tests.FSharp\EasyVCR.Tests.FSharp.fsproj /p:platform="Any CPU" /p:configuration="Debug" /p:outputPath="bin/Test" /p:target="Rebuild" -restore
Visual_Basic_Compatibility:
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x.x
- name: Setup MSBuild
uses: microsoft/[email protected]
- name: Setup Nuget
uses: NuGet/[email protected]
- name: Setup VSTest
uses: darenm/[email protected]
- name: Restore NuGet Packages
run: make restore
# Pull in fixtures submodule
- name: Set up dotnet tools and dependencies
run: make install
# Build the test project
- name: Build Solution
run: msbuild EasyVCR.Tests.VB\EasyVCR.Tests.VB.vbproj /p:platform="Any CPU" /p:configuration="Debug" /p:outputPath="bin/Test" /p:target="Rebuild" -restore
# .NET Standard notes:
# - NET Standard 2.0 is compatible with minimum .NET Framework 4.6.1: https://docs.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0
# - NET Framework 4.6.1 is EOL after April 26, 2022, due to its security concerns (was affected by the SHA-1 crack): https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-framework
# - GitHub's Windows 2022 runner only supports minimum .NET Framework 4.6.2 anyway: https://github.com/actions/virtual-environments/issues/5055#issuecomment-1040757930
# - .NET Standard is not a framework, but a set of shared APIs between the old .NET Framework and new .NET/.NET Core
# - `EasyVCR` targets .NET Standard 2.0, meaning it is compatible with specific versions of both .NET and .NET Framework: https://docs.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0
# - When you want to actually run code, however, you can't run it in .NET Standard. You have to run it in either .NET or .NET Framework: https://stackoverflow.com/a/48885500/13343799
# - So, while `EasyVCR` targets .NET Standard 2.0, `EasyVCR.Tests`, the code we're actually executing, targets .NET Framework 4.6.2
# - By extension, this is ensuring we are testing that the `EasyVCR` source code can run in a .NET Framework environment