Skip to content

Commit

Permalink
SetupSnk: Small bug fix from RootDirectory to Folders.Source (#515)
Browse files Browse the repository at this point in the history
Migrate NUKE build to latest.
Migrate from secure-file.exe to ENC ZipFile.

Migrate Builder to net8.0.

Migrate/add net8.0 LTS for test project; remove net7.0 STS.
  • Loading branch information
bchavez authored Dec 12, 2023
1 parent 009c84e commit 3ccc2f5
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 35 deletions.
12 changes: 6 additions & 6 deletions Source/Bogus.Tests/Bogus.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net471;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net471;net6.0;net8.0</TargetFrameworks>
<AssemblyOriginatorKeyFile></AssemblyOriginatorKeyFile>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Appveyor.Testlogger" Version="2.0.0" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="morelinq" Version="3.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Rant" Version="3.0.530" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit" Version="2.6.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="XunitXml.TestLogger" Version="3.0.78" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="XunitXml.TestLogger" Version="3.1.17" />
<PackageReference Include="Z.ExtensionMethods.WithTwoNamespace" Version="2.0.13" />
</ItemGroup>
<ItemGroup>
Expand Down
16 changes: 8 additions & 8 deletions Source/Bogus.Tests/DataSetTests/DateTest.net60.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void can_get_dateonly_in_past()
var maxBehind = now.AddYears(-1);

var somePastDate = date.PastDateOnly(refDate: now);
somePastDate.Should().BeInRange(maxBehind, now);
somePastDate.Should().BeOnOrAfter(maxBehind).And.BeOnOrBefore(now);
}

[Fact]
Expand All @@ -27,7 +27,7 @@ public void can_get_dateonly_in_past_with_custom_options()

var somePastDate = date.PastDateOnly(5, now);

somePastDate.Should().BeInRange(maxBehind, now);
somePastDate.Should().BeOnOrAfter(maxBehind).And.BeOnOrBefore(now);
}

[Fact]
Expand All @@ -38,7 +38,7 @@ public void get_a_dateonly_that_will_happen_soon()

var someDateSoon = date.SoonDateOnly(3, now);

someDateSoon.Should().BeInRange(now, maxDate);
someDateSoon.Should().BeOnOrAfter(now).And.BeOnOrBefore(maxDate);
}

[Fact]
Expand All @@ -48,7 +48,7 @@ public void can_get_dateonly_in_future()
var maxDate = now.AddYears(1);

var someFutureDate = date.FutureDateOnly(refDate: now);
someFutureDate.Should().BeInRange(now, maxDate);
someFutureDate.Should().BeOnOrAfter(now).And.BeOnOrBefore(maxDate);
}

[Fact]
Expand All @@ -58,7 +58,7 @@ public void can_get_dateonly_in_future_with_options()
var maxDate = now.AddYears(5);

var someFutureDate = date.FutureDateOnly(5, now);
someFutureDate.Should().BeInRange(now, maxDate);
someFutureDate.Should().BeOnOrAfter(now).And.BeOnOrBefore(maxDate);
}

[Fact]
Expand All @@ -69,11 +69,11 @@ public void can_get_random_dateonly_between_two_dates()

var someDate = date.BetweenDateOnly(start, end);

someDate.Should().BeInRange(start, end);
someDate.Should().BeOnOrAfter(start).And.BeOnOrBefore(end);

//and reverse...
var otherDate = date.BetweenDateOnly(end, start);
otherDate.Should().BeInRange(start, end);
otherDate.Should().BeOnOrAfter(start).And.BeOnOrBefore(end);
}

[Fact]
Expand All @@ -84,7 +84,7 @@ public void can_get_dateonly_recently_within_the_year()

var someRecentDate = date.RecentDateOnly(refDate: now);

someRecentDate.Should().BeInRange(maxBehind, now);
someRecentDate.Should().BeOnOrAfter(maxBehind).And.BeOnOrBefore(now);
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion Source/Bogus.Tests/UniquenessTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void every_new_generation_should_have_a_new_unique_index()
.Select(u => u.Username.Left(1).ToInt32())
.ToArray();

values.Should().BeEquivalentTo(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
values.Should().BeEquivalentTo(new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });

var morefakes = faker.Generate(3);

Expand Down
2 changes: 0 additions & 2 deletions Source/Bogus.snk.enc

This file was deleted.

Binary file added Source/Bogus.snk.enc.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion Source/Bogus/Bogus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Roslynator.Analyzers" Version="1.9.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
Expand Down
23 changes: 10 additions & 13 deletions Source/Builder/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static class Files
public static AbsolutePath History = RootDirectory / "HISTORY.md";
public static AbsolutePath SolutionFile = Folders.Source / $"{ProjectName}.sln";
public static AbsolutePath SnkFile = Folders.Source / $"{ProjectName}.snk";
public static AbsolutePath SnkEncFile = Folders.Source / $"{ProjectName}.snk.enc";
public static AbsolutePath SnkEncZipFile = Folders.Source / $"{ProjectName}.snk.enc.zip";
public static AbsolutePath SnkFilePublic = Folders.Source / $"{ProjectName}.snk.pub";
}

Expand Down Expand Up @@ -128,8 +128,7 @@ protected override void OnBuildInitialized()
.Executes(() => {
var zipPath = Folders.Package / this.BogusProject.ZipFile();
CompressZip(Folders.CompileOutput, zipPath);
Folders.CompileOutput.ZipTo(zipPath);
});


Expand All @@ -139,9 +138,9 @@ protected override void OnBuildInitialized()
{
//Debugger.Launch();
EnsureCleanDirectory(Folders.Test);
EnsureCleanDirectory(Folders.CompileOutput);
EnsureCleanDirectory(Folders.Package);
Folders.Test.CreateOrCleanDirectory();
Folders.CompileOutput.CreateOrCleanDirectory();
Folders.Package.CreateOrCleanDirectory();
var projects = this.Solution.AllProjects.Where(p => !p.Name.Contains("Builder"));
foreach (var project in projects)
Expand Down Expand Up @@ -237,6 +236,8 @@ protected override void OnBuildInitialized()
});

[Parameter, Secret]
readonly string BogusSnkZipPassword;

Target SetupSnk => _ => _
.DependentFor(BuildInfo)
Expand All @@ -247,15 +248,11 @@ protected override void OnBuildInitialized()
{
Log.Information("Decrypting String Name Key (SNK) file.");
var secret = GetVariable<string>("SNKFILE_SECRET");
Assert.NotNullOrWhiteSpace(secret);
Assert.NotNullOrWhiteSpace(BogusSnkZipPassword);
Assert.FileExists(Files.SnkEncFile);
Assert.FileExists(Files.SnkEncZipFile);
SecureFile(
arguments: $"-decrypt {Files.SnkEncFile} -secret {secret}",
workingDirectory: Folders.Source,
outputFilter: l => l.Replace(secret, "****"));
Files.SnkEncZipFile.UnZipWithPasswordTo(Folders.Source, BogusSnkZipPassword);
Assert.FileExists(Files.SnkFile);
Expand Down
6 changes: 4 additions & 2 deletions Source/Builder/Builder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169;NU1701</NoWarn>
<NukeRootDirectory>..\..</NukeRootDirectory>
<NukeScriptDirectory>..</NukeScriptDirectory>
<NukeTelemetryVersion>1</NukeTelemetryVersion>
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DotNetZip" Version="1.16.0" />
<PackageReference Include="Fake.DotNet.AssemblyInfoFile" Version="6.0.0" />
<PackageReference Include="Nuke.Common" Version="6.3.0" />
<PackageReference Include="Nuke.Common" Version="7.0.6" />
<PackageReference Include="Z.ExtensionMethods.WithTwoNamespace" Version="2.0.13" />
</ItemGroup>

Expand Down
8 changes: 8 additions & 0 deletions Source/Builder/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Z.ExtensionMethods.ObjectExtensions;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using Ionic.Zip;

public static class BuildContext
{
Expand Down Expand Up @@ -150,5 +151,12 @@ public static DotNetBuildSettings SetNoWarns2(this DotNetBuildSettings toolSetti
var newSettings = toolSettings.AddProperty("NoWarn", arg);
return newSettings;
}

public static void UnZipWithPasswordTo(this AbsolutePath archiveFile, AbsolutePath destination, string password)
{
using var zip = ZipFile.Read(archiveFile);
zip.Password = password;
zip.ExtractAll(destination);
}
}

4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ image: Visual Studio 2022

environment:
NUKE_TELEMETRY_OPTOUT: 1
SNKFILE_SECRET: # OpenSource / Bogus.snk.enc
secure: Bce2VwNFEBM1oWspgNlpTXSH290GZmc5DCuxjnAX72nBWNbR0S2tq/odIdfv2+t3bA9xzFHEwqvjGVEWgg5ZdfWUYj+PSBr+con0PiUGng0=
BogusSnkZipPassword: # OpenSource / Bogus.snk.enc.zip
secure: OqTnyfgOL1S7+NYqo4f5Mc72RsozR4CwAQ6K/YwqPBlG2LOPSoRHm9JxIHHYTecR5B3IiEe0xEyjulbBjNwQuMMSCPX+nr6oH/KfBTx9rf4=

skip_commits:
message: /(//skip\W*ci)|(read\W*me)/
Expand Down

0 comments on commit 3ccc2f5

Please sign in to comment.