Skip to content

Commit

Permalink
Refactor to CompressionExtensions usages
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoch committed Mar 16, 2023
1 parent 9dd4b07 commit 37196e6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
3 changes: 1 addition & 2 deletions build/Build.ReleaseImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using static Nuke.Common.IO.CompressionTasks;
using static Nuke.Common.IO.HttpTasks;

partial class Build
Expand All @@ -40,7 +39,7 @@ partial class Build
.Executes(() =>
{
FontDownloadUrls.ForEach(x => HttpDownloadFile(x, FontDirectory / new Uri(x).Segments.Last()));
FontArchives.ForEach(x => Uncompress(x, FontDirectory / Path.GetFileNameWithoutExtension(x)));
FontArchives.ForEach(x => x.UncompressTo(FontDirectory / x.NameWithoutExtension));
FontFiles.ForEach(x => FontCollection.Add(x));
FontCollection.Families.ForEach(x => Log.Information("Installed font {Font}", x.Name));
Expand Down
6 changes: 3 additions & 3 deletions source/Nuke.Common.Tests/CompressionTasksTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public void Test(string archiveFile)
RootFile.WriteAllText("root", eofLineBreak: false);
NestedFile.WriteAllText("nested", eofLineBreak: false);

var archive = Path.Combine(TestTempDirectory, archiveFile);
CompressionTasks.Compress(TestTempDirectory, archive);
var archive = TestTempDirectory / archiveFile;
TestTempDirectory.CompressTo(archive);
File.Exists(archive).Should().BeTrue();

File.Delete(RootFile);
File.Delete(NestedFile);
Directory.GetFiles(TestTempDirectory, "*").Should().HaveCount(1);

CompressionTasks.Uncompress(archive, TestTempDirectory);
archive.UncompressTo(TestTempDirectory);
File.Exists(RootFile).Should().BeTrue();
File.ReadAllText(RootFile).Should().Be("root");
File.Exists(NestedFile).Should().BeTrue();
Expand Down
10 changes: 3 additions & 7 deletions source/Nuke.Components/IReportCoverage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Nuke.Common.Tools.Codecov;
using Nuke.Common.Tools.ReportGenerator;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.IO.CompressionTasks;
using static Nuke.Common.Tools.Codecov.CodecovTasks;
using static Nuke.Common.Tools.ReportGenerator.ReportGeneratorTasks;

Expand All @@ -26,8 +25,8 @@ public interface IReportCoverage : ITest, IHazReports, IHazGitRepository
bool ReportToCodecov { get; }
[Parameter] [Secret] string CodecovToken => TryGetValue(() => CodecovToken);

string CoverageReportDirectory => ReportDirectory / "coverage-report";
string CoverageReportArchive => Path.ChangeExtension(CoverageReportDirectory, ".zip");
AbsolutePath CoverageReportDirectory => ReportDirectory / "coverage-report";
AbsolutePath CoverageReportArchive => CoverageReportDirectory.WithExtension("zip");

Target ReportCoverage => _ => _
.DependsOn(Test)
Expand All @@ -50,10 +49,7 @@ public interface IReportCoverage : ITest, IHazReports, IHazGitRepository
.Apply(ReportGeneratorSettingsBase)
.Apply(ReportGeneratorSettings));
CompressZip(
directory: CoverageReportDirectory,
archiveFile: CoverageReportArchive,
fileMode: FileMode.Create);
CoverageReportDirectory.ZipTo(CoverageReportArchive, fileMode: FileMode.Create);
}
UploadCoverageData();
Expand Down
9 changes: 4 additions & 5 deletions source/Nuke.Components/ISignPackages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Nuke.Common.CI.AppVeyor;
using Nuke.Common.IO;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.IO.CompressionTasks;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.Tools.SignPath.SignPathTasks;

Expand Down Expand Up @@ -61,8 +60,8 @@ public interface ISignPackages : INukeBuild
AbsolutePath SignPathTemporaryDirectory => TemporaryDirectory / "signpath";
AbsolutePath SignPathRequestDirectory => SignPathTemporaryDirectory / "signing-request";
AbsolutePath SignPathResponseDirectory => SignPathTemporaryDirectory / "signing-response";
string SignPathRequestArchive => Path.ChangeExtension(SignPathRequestDirectory, ".zip");
string SignPathResponseArchive => Path.ChangeExtension(SignPathResponseDirectory, ".zip");
AbsolutePath SignPathRequestArchive => Path.ChangeExtension(SignPathRequestDirectory, ".zip");
AbsolutePath SignPathResponseArchive => Path.ChangeExtension(SignPathResponseDirectory, ".zip");

IEnumerable<AbsolutePath> SignPathPackages { get; }
bool SignPathReplacePackages => true;
Expand All @@ -81,7 +80,7 @@ public interface ISignPackages : INukeBuild
{
SignPathRequestDirectory.CreateOrCleanDirectory();
SignPathPackages.ForEach(x => CopyFileToDirectory(x, SignPathRequestDirectory));
CompressZip(SignPathRequestDirectory, SignPathRequestArchive);
SignPathRequestDirectory.ZipTo(SignPathRequestArchive);
AppVeyor.PushArtifact(SignPathRequestArchive);
Expand All @@ -106,7 +105,7 @@ await DownloadSignedArtifactFromUrl(
ReportSummary(_ => _);
}
UncompressZip(SignPathResponseArchive, SignPathResponseDirectory);
SignPathResponseArchive.UnZipTo(SignPathResponseDirectory);
if (SignPathReplacePackages)
{
Expand Down

0 comments on commit 37196e6

Please sign in to comment.