Skip to content

Commit

Permalink
Introduce a composite action to run module tests (#72)
Browse files Browse the repository at this point in the history
* Introduce a composite action to run module tests
* Treat Core as yet another module except creating NuGet package
  • Loading branch information
piotrzajac authored Oct 18, 2023
1 parent 8dd1fe0 commit accc4da
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 40 deletions.
47 changes: 47 additions & 0 deletions .github/actions/test-module/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Test module
description: Run tests against specified module
inputs:
module-name:
description: Name of the module
required: true
module-namespace:
description: Name of the module namespace
required: true
codecov-token:
description: Value of Codecov token used to upload code coverage results
required: true
coverage-directory:
description: Path to code coverage directory where results are being stored
required: false
default: ${{ github.workspace }}\src\opencover
outputs:
file-path:
description: Signing key file path
value: ${{ steps.signing-key.outputs.PATH }}
runs:
using: composite
steps:
- name: 🧪 test ${{ matrix.package_module }} in net7.0 & collect coverage
id: module-code-coverage
run: |
$path = [IO.Path]::Combine("$env:CoverageDirectory","$env:ModuleFullName.xml")
dotnet test ./src/$env:ModuleFullName.Tests/ --no-build -f $env:TargetFramework -e:CollectCoverage=true -e:CoverletOutputFormat=opencover -e:Exclude="[xunit*]*" -e:CoverletOutput=$path
"FILE=$env:ModuleFullName.$env:TargetFramework.xml" >> $env:GITHUB_OUTPUT
shell: pwsh
env:
CoverageDirectory: ${{ inputs.coverage-directory }}
ModuleFullName: ${{ inputs.module-namespace }}.${{ inputs.module-name }}
TargetFramework: net7.0
- name: 🧪 test ${{ matrix.package_module }} in net472
run: dotnet test ./src/${{ inputs.module-namespace }}.${{ inputs.module-name }}.Tests/ --no-build -f net472
shell: pwsh
- name: 🧪 test ${{ matrix.package_module }} in net48
run: dotnet test ./src/${{ inputs.module-namespace }}.${{ inputs.module-name }}.Tests/ --no-build -f net48
shell: pwsh
- name: 📤 upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ inputs.codecov-token }}
files: ${{ steps.module-code-coverage.outputs.FILE }}
directory: ${{ inputs.coverage-directory }}
flags: unittests
40 changes: 8 additions & 32 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
$matrix = @{
package_module = @(Foreach ($module in ($allModules.GetEnumerator() | Where-Object { $_.Value })) {$module.Name})
}
if ($matrix.package_module.count -gt 0) { $matrix.package_module = @("Core") + $matrix.package_module }
"MATRIX=$($matrix | ConvertTo-JSON -Compress)" >> $env:GITHUB_OUTPUT
- name: 📥 checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -106,46 +107,21 @@ jobs:
CI: true
StrongNameKey: ${{ secrets.SIGNING_KEY }}
StrongNameKeyPath: ${{ steps.signing-key.outputs.file-path }}
- name: 🧪 test Core in net7.0 & collect coverage
id: core-code-coverage
run: |
$path = [IO.Path]::Combine("$env:CoverageDirectory","$env:CoverageFileName.xml")
dotnet test ./src/${{ env.Namespace }}.Core.Tests/ --no-build -f $env:TargetFramework -e:CollectCoverage=true -e:CoverletOutputFormat=opencover -e:Exclude="[xunit*]*" -e:CoverletOutput=$path
"FILE=$env:CoverageFileName.$env:TargetFramework.xml" >> $env:GITHUB_OUTPUT
env:
CoverageFileName: ${{ env.Namespace }}.Core
TargetFramework: net7.0
- name: 🧪 test Core in net472
run: dotnet test ./src/${{ env.Namespace }}.Core.Tests/ --no-build -f net472
- name: 🧪 test Core in net48
run: dotnet test ./src/${{ env.Namespace }}.Core.Tests/ --no-build -f net48
- name: 🧪 test ${{ matrix.package_module }} in net7.0 & collect coverage
id: module-code-coverage
run: |
$path = [IO.Path]::Combine("$env:CoverageDirectory","$env:CoverageFileName.xml")
dotnet test ./src/${{ env.Namespace }}.${{ matrix.package_module }}.Tests/ --no-build -f $env:TargetFramework -e:CollectCoverage=true -e:CoverletOutputFormat=opencover -e:Exclude="[xunit*]*" -e:CoverletOutput=$path
"FILE=$env:CoverageFileName.$env:TargetFramework.xml" >> $env:GITHUB_OUTPUT
env:
CoverageFileName: ${{ env.Namespace }}.${{ matrix.package_module }}
TargetFramework: net7.0
- name: 🧪 test ${{ matrix.package_module }} in net472
run: dotnet test ./src/${{ env.Namespace }}.${{ matrix.package_module }}.Tests/ --no-build -f net472
- name: 🧪 test ${{ matrix.package_module }} in net48
run: dotnet test ./src/${{ env.Namespace }}.${{ matrix.package_module }}.Tests/ --no-build -f net48
- name: 📤 upload coverage reports to Codecov
uses: codecov/codecov-action@v3
- name: 🧪 test
uses: ./.github/actions/test-module
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ steps.core-code-coverage.outputs.FILE }},${{ steps.module-code-coverage.outputs.FILE }}
directory: ${{ env.CoverageDirectory }}
flags: unittests
module-name: ${{ matrix.package_module }}
module-namespace: ${{ env.Namespace }}
codecov-token: ${{ secrets.CODECOV_TOKEN }}
- name: 📦 pack
if: ${{ startsWith(matrix.package_module, 'Auto' ) }}
run: dotnet pack ./src/${{ env.Namespace }}.${{ matrix.package_module }} --no-restore
env:
CI: true
StrongNameKey: ${{ secrets.SIGNING_KEY }}
StrongNameKeyPath: ${{ steps.signing-key.outputs.file-path }}
- name: 🔼 upload packages
if: ${{ startsWith(matrix.package_module, 'Auto' ) }}
uses: actions/upload-artifact@v3
with:
name: packages
Expand Down
4 changes: 2 additions & 2 deletions src/Objectivity.AutoFixture.XUnit2.AutoFakeItEasy.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29409.12
# Visual Studio Version 17
VisualStudioVersion = 17.7.34202.233
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Objectivity.AutoFixture.XUnit2.Core", "Objectivity.AutoFixture.XUnit2.Core\Objectivity.AutoFixture.XUnit2.Core.csproj", "{B889895A-FC17-470A-B28E-61AAA8DBC1A4}"
EndProject
Expand Down
4 changes: 2 additions & 2 deletions src/Objectivity.AutoFixture.XUnit2.AutoMock.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29409.12
# Visual Studio Version 17
VisualStudioVersion = 17.7.34202.233
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Objectivity.AutoFixture.XUnit2.Core", "Objectivity.AutoFixture.XUnit2.Core\Objectivity.AutoFixture.XUnit2.Core.csproj", "{7FF963AD-E151-4E45-9093-7B9E6441BFA0}"
EndProject
Expand Down
4 changes: 2 additions & 2 deletions src/Objectivity.AutoFixture.XUnit2.AutoMoq.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29409.12
# Visual Studio Version 17
VisualStudioVersion = 17.7.34202.233
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Objectivity.AutoFixture.XUnit2.AutoMoq", "Objectivity.AutoFixture.XUnit2.AutoMoq\Objectivity.AutoFixture.XUnit2.AutoMoq.csproj", "{B7ADCA12-249E-4A13-90A3-16AD9E3EDFD0}"
EndProject
Expand Down
4 changes: 2 additions & 2 deletions src/Objectivity.AutoFixture.XUnit2.AutoNSubstitute.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29409.12
# Visual Studio Version 17
VisualStudioVersion = 17.7.34202.233
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Objectivity.AutoFixture.XUnit2.AutoNSubstitute", "Objectivity.AutoFixture.XUnit2.AutoNSubstitute\Objectivity.AutoFixture.XUnit2.AutoNSubstitute.csproj", "{D3E477EA-F0A1-4287-A22D-C8D982231849}"
EndProject
Expand Down
31 changes: 31 additions & 0 deletions src/Objectivity.AutoFixture.XUnit2.Core.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34202.233
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Objectivity.AutoFixture.XUnit2.Core", "Objectivity.AutoFixture.XUnit2.Core\Objectivity.AutoFixture.XUnit2.Core.csproj", "{A639D1F4-C3D5-499F-944B-DEE361C20082}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Objectivity.AutoFixture.XUnit2.Core.Tests", "Objectivity.AutoFixture.XUnit2.Core.Tests\Objectivity.AutoFixture.XUnit2.Core.Tests.csproj", "{D9095A71-49FC-47FE-8C49-1677EBE42B53}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A639D1F4-C3D5-499F-944B-DEE361C20082}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A639D1F4-C3D5-499F-944B-DEE361C20082}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A639D1F4-C3D5-499F-944B-DEE361C20082}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A639D1F4-C3D5-499F-944B-DEE361C20082}.Release|Any CPU.Build.0 = Release|Any CPU
{D9095A71-49FC-47FE-8C49-1677EBE42B53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9095A71-49FC-47FE-8C49-1677EBE42B53}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9095A71-49FC-47FE-8C49-1677EBE42B53}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9095A71-49FC-47FE-8C49-1677EBE42B53}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D092E697-BEB8-4A00-B37E-4109FD2B17E7}
EndGlobalSection
EndGlobal

0 comments on commit accc4da

Please sign in to comment.