test: updating tests to run in ci
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
D. Moonfire 2023-07-12 20:31:25 -05:00
parent 1892c49f24
commit 1ee5765e2b
12 changed files with 641 additions and 655 deletions

View file

@ -5,25 +5,31 @@ set dotenv-load := true
# Cleans out the packages.
clean:
dotnet clean
dotnet clean -v:m
# Builds all of the components of this repository.
build:
dotnet build
# Runs all the known tests in the repository.
test: restore-tools
dotnet test \
--test-adapter-path:. \
--logger:"junit;LogFilePath=../artifacts/{assembly}-test-result.xml;MethodFormat=Default;FailureBodyFormat=Verbose" \
--collect:"XPlat Code Coverage" \
-v:q --nologo
test:
#!/usr/bin/env bash
for i in tests/*/*.csproj
do
dotnet test \
$i \
--test-adapter-path:. \
--logger:"junit;LogFilePath=../artifacts/{assembly}-test-result.xml;MethodFormat=Default;FailureBodyFormat=Verbose" \
--collect:"XPlat Code Coverage" \
-v:q --nologo || exit 1
done
dotnet tool run reportgenerator \
-reports:tests/*/TestResults/*/coverage.cobertura.xml \
-targetdir:./coverage \
"-reporttypes:Cobertura;TextSummary"
grep "Line coverage" coverage/Summary.txt
dotnet tool run reportgenerator \
-reports:tests/*/TestResults/*/coverage.cobertura.xml \
-targetdir:./coverage \
"-reporttypes:Cobertura;TextSummary"
grep "Line coverage" coverage/Summary.txt
# Restores all the tools and NuGet packages.
restore: restore-tools restore-packages
@ -38,39 +44,39 @@ restore-packages:
# Performs a release on all the packages.
release: clean build
#!/usr/bin/env bash
#!/usr/bin/env bash
# Verify that all the variables are set.
if [ "x$GITEA_TOKEN" = "x" ]; then
echo "the environment variable GITEA_TOKEN is not defined"
exit 1
fi
# Verify that all the variables are set.
if [ "x$GITEA_TOKEN" = "x" ]; then
echo "the environment variable GITEA_TOKEN is not defined"
exit 1
fi
# Publish the packages.
dotnet pack -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg || exit 1
dotnet nuget remove source publish >&/dev/null
#dotnet nuget add source --name publish --username dmoonfire --password $GITEA_TOKEN https://src.mfgames.com/api/packages/mfgames-cil/nuget/index.json --store-password-in-clear-text || exit 1
#dotnet nuget push --skip-duplicate --source publish src/*/bin/Debug/*.nupkg || exit 1
dotnet nuget remove source publish >&/dev/null
# Publish the packages.
dotnet pack -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg || exit 1
dotnet nuget remove source publish >&/dev/null
#dotnet nuget add source --name publish --username dmoonfire --password $GITEA_TOKEN https://src.mfgames.com/api/packages/mfgames-cil/nuget/index.json --store-password-in-clear-text || exit 1
#dotnet nuget push --skip-duplicate --source publish src/*/bin/Debug/*.nupkg || exit 1
dotnet nuget remove source publish >&/dev/null
# Go through and tag everything.
git remote add publish https://dmoonfire:$GITEA_TOKEN@src.mfgames.com/mfgames-cil/$(basename $(git config --get remote.origin.url))
# Go through and tag everything.
git remote add publish https://dmoonfire:$GITEA_TOKEN@src.mfgames.com/mfgames-cil/$(basename $(git config --get remote.origin.url))
for i in src/*/GitVersion.yml
do
# Move into the proper directory.
dir=$(dirname $i)
pkg=$(basename $dir)
pushd $dir
for i in src/*/GitVersion.yml
do
# Move into the proper directory.
dir=$(dirname $i)
pkg=$(basename $dir)
pushd $dir
# Check the version and see if we've tagged it already.
tag="$pkg-$(dotnet gitversion /output json | jq -r .SemVer)"
echo "tagging $pkg with $tag"
#git tag $tag
#git push publish $tag
# Check the version and see if we've tagged it already.
tag="$pkg-$(dotnet gitversion /output json | jq -r .SemVer)"
echo "tagging $pkg with $tag"
#git tag $tag
#git push publish $tag
# Move back so we can finish.
popd
done
# Move back so we can finish.
popd
done
git remote remove publish
git remote remove publish

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,4 @@
using Serilog;
using Serilog.Core;
using MfGames.TestSetup;
using Xunit.Abstractions;
@ -9,32 +8,10 @@ namespace MfGames.Gallium.Tests;
/// Common initialization logic for Gallium-based tests including setting
/// up containers, logging, and Serilog.
/// </summary>
public abstract class GalliumTestsBase
public abstract class GalliumTestsBase : TestBase<TestContext>
{
protected GalliumTestsBase(ITestOutputHelper output)
{
this.Output = output;
// Set up logging.
const string Template =
"[{Level:u3}] "
+ "({SourceContext}) {Message}"
+ "{NewLine}{Exception}";
this.Logger = new LoggerConfiguration()
.WriteTo.TestOutput(
output,
outputTemplate: Template)
.CreateLogger();
}
/// <summary>
/// Gets the output for the tests.
/// </summary>
public ITestOutputHelper Output { get; }
/// <summary>
/// Gets the logger used to report messages about the test.
/// </summary>
protected Logger Logger { get; }
protected GalliumTestsBase(ITestOutputHelper output)
: base(output)
{
}
}

View file

@ -6,13 +6,13 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Serilog.Sinks.XUnit" Version="3.0.5" />
<PackageReference Include="JunitXml.TestLogger" Version="3.0.125" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -21,5 +21,6 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MfGames.Gallium\MfGames.Gallium.csproj" />
<ProjectReference Include="..\..\src\MfGames.TestSetup\MfGames.TestSetup.csproj" />
</ItemGroup>
</Project>

View file

@ -97,7 +97,7 @@ namespace MfGames.ToolBuilder.Tests
.GetType()
.GetDirectory()
.FindGitRoot()
!.GetFile("tests", "SampleTool", "SampleTool.csproj");
!.GetFile("examples", "SampleTool", "SampleTool.csproj");
return file;
}