-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
316 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
name: Build library | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
#- feature/* | ||
paths: | ||
- 'src/SvR.ContentPrep/**' | ||
- '.github/workflows/build-library.yml' | ||
pull_request: | ||
branches: | ||
- main | ||
- devevelop | ||
paths: | ||
- 'src/SvR.ContentPrep/**' | ||
- '.github/workflows/build-library.yml' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
name: 🛠️ Build and Test | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
issues: read | ||
checks: write | ||
steps: | ||
- name: 👨💻 Check-out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: 👨🔧 Setup .NET Core SDK | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 7.x | ||
|
||
- name: 🔍 Enable problem matchers | ||
run: echo "::add-matcher::.github/matchers/dotnet.json" | ||
|
||
- name: 🦸♂️ Restore steriods | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.nuget/packages | ||
# Look to see if there is a cache hit for the corresponding requirements file | ||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-nuget | ||
- name: 🎒 Load packages | ||
run: dotnet restore | ||
|
||
- name: 🛠️ Build code | ||
run: dotnet build --configuration Release --no-restore | ||
|
||
- name: ✔️ Testing code | ||
run: dotnet test --configuration Release -v minimal --no-build --logger GitHubActions '/p:CollectCoverage=true;CoverletOutputFormat="json,lcov,cobertura";MergeWith=${{github.workspace}}/coverage.json;CoverletOutput=${{github.workspace}}/coverage' -- RunConfiguration.CollectSourceInformation=true | ||
|
||
- name: 📝 Code Coverage report | ||
run: | | ||
dotnet tool install --global dotnet-reportgenerator-globaltool --version 5.1.23 | ||
reportgenerator -reports:${{github.workspace}}/coverage.cobertura.xml -targetdir:${{github.workspace}}/report -reporttypes:MarkdownSummaryGithub -filefilters:-*.g.cs "-classfilters:-WixSharp.*;-WingetIntune.Os.*;-WingetIntune.Internal.MsStore.*" -verbosity:Warning | ||
sed -i 's/# Summary/## 📝 Code Coverage/g' ${{github.workspace}}/report/SummaryGithub.md | ||
sed -i 's/## Coverage/### 📝 Code Coverage details/g' ${{github.workspace}}/report/SummaryGithub.md | ||
cat ${{github.workspace}}/report/*.md >> $GITHUB_STEP_SUMMARY | ||
- name: 📃 Check code formatting | ||
if: always() | ||
run: dotnet format --verify-no-changes | ||
|
||
publish: | ||
name: 📦 Publish nuget library | ||
runs-on: ubuntu-latest | ||
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/dev') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') | ||
needs: [test] | ||
steps: | ||
- name: 👨💻 Check-out code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: 👨🔧 Setup .NET Core SDK | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 7.x | ||
|
||
- name: 🛠️ Compute version with GitVersion | ||
run: | | ||
dotnet tool install --global GitVersion.Tool --version 5.* | ||
echo "## 📦 Calculated version" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
dotnet-gitversion /updateprojectfiles /output buildserver /nofetch | ||
dotnet-gitversion /nofetch /output json /showvariable NuGetVersionV2 >> $GITHUB_STEP_SUMMARY | ||
- name: 🔍 Enable problem matchers | ||
run: echo "::add-matcher::.github/matchers/dotnet.json" | ||
|
||
- name: 🦸♂️ Restore steriods | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.nuget/packages | ||
# Look to see if there is a cache hit for the corresponding requirements file | ||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-nuget | ||
- name: 🎒 Load packages | ||
run: dotnet restore | ||
|
||
- name: 🛠️ Build code | ||
run: dotnet build --configuration Release --no-restore ./src/SvR.ContentPrep/SvR.ContentPrep.csproj | ||
|
||
- name: 📦 Pack library | ||
run: dotnet pack --configuration Release --no-build --no-restore ./src/SvR.ContentPrep/SvR.ContentPrep.csproj | ||
|
||
- name: ✈️ Publish SvR.ContentPrep to nuget.org | ||
run: dotnet nuget push ./src/SvR.ContentPrep/bin/Release/SvRooij.ContentPrep.*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json | ||
env: | ||
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -363,4 +363,7 @@ MigrationBackup/ | |
FodyWeavers.xsd | ||
|
||
# Dist folder | ||
dist/ | ||
dist/ | ||
|
||
# Live unit testing files | ||
*.lutconfig |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
assembly-versioning-scheme: MajorMinorPatch | ||
mode: Mainline | ||
branches: | ||
feature: | ||
tag: beta | ||
ignore: | ||
sha: [] | ||
major-version-bump-message: "^(build|ci|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)" | ||
minor-version-bump-message: "^(feat)(\\([\\w\\s-]*\\))?:" | ||
patch-version-bump-message: "^(build|ci|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:" |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
namespace SvRooij.ContentPrep.Tests; | ||
|
||
[TestClass] | ||
public class PackagerTests | ||
{ | ||
[TestMethod] | ||
public void CreatePackage_NullFolder_ThrowsArgumentNull() | ||
{ | ||
// Arrange | ||
var packager = new Packager(); | ||
|
||
Assert.ThrowsExceptionAsync<ArgumentNullException>(() => packager.CreatePackage(null, null, null)); | ||
} | ||
|
||
[TestMethod] | ||
public void CreatePackage_NullSetupFile_ThrowsArgumentNull() | ||
{ | ||
// Arrange | ||
var packager = new Packager(); | ||
|
||
Assert.ThrowsExceptionAsync<ArgumentNullException>(() => packager.CreatePackage("test", null, null)); | ||
} | ||
|
||
[TestMethod] | ||
public void CreatePackage_NullOutput_ThrowsArgumentNull() | ||
{ | ||
// Arrange | ||
var packager = new Packager(); | ||
|
||
Assert.ThrowsExceptionAsync<ArgumentNullException>(() => packager.CreatePackage("test", "test", null)); | ||
} | ||
|
||
[TestMethod] | ||
public void CreatePackage_NonExistingFolder_ThrowsDirectoryNotFound() | ||
{ | ||
// Arrange | ||
var packager = new Packager(); | ||
var inputFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); | ||
|
||
|
||
Assert.ThrowsExceptionAsync<DirectoryNotFoundException>(() => packager.CreatePackage(inputFolder, "test", "test")); | ||
} | ||
|
||
[TestMethod] | ||
public void CreatePackage_NonExistingSetup_ThrowsFileNotFound() | ||
{ | ||
// Arrange | ||
var packager = new Packager(); | ||
var inputFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); | ||
Directory.CreateDirectory(inputFolder); | ||
var setup = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".msi"); | ||
|
||
Assert.ThrowsExceptionAsync<FileNotFoundException>(() => packager.CreatePackage(inputFolder, setup, "test")); | ||
Directory.Delete(inputFolder); | ||
} | ||
|
||
[TestMethod] | ||
public void CreatePackage_ExistingSetupWrongFolder_ThrowsArgumentException() | ||
{ | ||
// Arrange | ||
var packager = new Packager(); | ||
var inputFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); | ||
Directory.CreateDirectory(inputFolder); | ||
var setup = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".msi"); | ||
File.CreateText(setup).Close(); | ||
|
||
Assert.ThrowsExceptionAsync<ArgumentException>(() => packager.CreatePackage(inputFolder, setup, "test")); | ||
Directory.Delete(inputFolder, true); | ||
} | ||
|
||
[TestMethod] | ||
public void CreatePackage_NoOutputDir_ThrowsDirectoryNotFound() | ||
{ | ||
// Arrange | ||
var packager = new Packager(); | ||
var inputFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); | ||
var outputFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); | ||
Directory.CreateDirectory(inputFolder); | ||
var setup = Path.Combine(inputFolder, Guid.NewGuid().ToString() + ".msi"); | ||
File.CreateText(setup).Close(); | ||
|
||
Assert.ThrowsExceptionAsync<DirectoryNotFoundException>(() => packager.CreatePackage(inputFolder, setup, outputFolder)); | ||
Directory.Delete(inputFolder, true); | ||
//Directory.Delete(outputFolder, true); | ||
} | ||
|
||
[TestMethod] | ||
public void Unpack_NullPackage_ThrowsArgumentNull() | ||
{ | ||
// Arrange | ||
var packager = new Packager(); | ||
|
||
Assert.ThrowsExceptionAsync<ArgumentNullException>(() => packager.Unpack(null, null)); | ||
} | ||
|
||
[TestMethod] | ||
public void Unpack_NullOutput_ThrowsArgumentNull() | ||
{ | ||
// Arrange | ||
var packager = new Packager(); | ||
|
||
Assert.ThrowsExceptionAsync<ArgumentNullException>(() => packager.Unpack("test", null)); | ||
} | ||
|
||
[TestMethod] | ||
public void Unpack_NonExistingPackage_ThrowsFileNotFound() | ||
{ | ||
// Arrange | ||
var packager = new Packager(); | ||
var package = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".msi"); | ||
|
||
Assert.ThrowsExceptionAsync<FileNotFoundException>(() => packager.Unpack(package, "test")); | ||
} | ||
|
||
[TestMethod] | ||
public void Unpack_NonExistingOutput_ThrowsDirectoryNotFound() | ||
{ | ||
var packager = new Packager(); | ||
var package = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".msi"); | ||
File.CreateText(package).Close(); | ||
var outputFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); | ||
|
||
Assert.ThrowsExceptionAsync<DirectoryNotFoundException>(() => packager.Unpack(package, outputFolder)); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<DefaultNamespace>SvRooij.ContentPrep.Tests</DefaultNamespace> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
<NoWarn>CS8625</NoWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" /> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\SvR.ContentPrep\SvR.ContentPrep.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using Microsoft.VisualStudio.TestTools.UnitTesting; |