Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6773eb9
Started on splitting up GitHub release into smaller parts
rasmus Dec 17, 2024
b23ee7b
More split
rasmus Dec 17, 2024
5be3262
Merge branch 'develop' into split-up-releases
rasmus Dec 22, 2024
0a19d1e
Cleaning more up
rasmus Dec 22, 2024
8f0741f
Started on creating release files
rasmus Dec 22, 2024
5e60a23
Started on testing releases
rasmus Dec 22, 2024
87b9373
Now testing adding files to release
rasmus Dec 22, 2024
42ababd
Getting the GitHub part in shape as well
rasmus Dec 22, 2024
d50b3ab
Skip bake.local names in the release description
rasmus Dec 22, 2024
2b85179
Merge branch 'develop' into split-up-releases
rasmus Dec 23, 2024
edef4ec
Create destination directory
rasmus Dec 23, 2024
21f959b
Allow pushing to test nuget store
rasmus Dec 23, 2024
77e9979
Better name for release artifacts
rasmus Dec 23, 2024
d961bd9
Add a random name to the release directory
rasmus Dec 23, 2024
dc1eb91
Be able to read and write ReleaseFile
rasmus Dec 23, 2024
b09158c
Merge branch 'develop' into split-up-releases
rasmus Dec 23, 2024
61ca42d
Add name
rasmus Dec 23, 2024
d98a358
Merge branch 'develop' into split-up-releases
rasmus Jan 3, 2025
ba44e69
Add missing arch
rasmus Jan 6, 2025
75c2388
Merge remote-tracking branch 'origin/develop' into split-up-releases
rasmus Jan 6, 2025
c035119
Update file headers
rasmus Jan 6, 2025
6484395
Test release cook
rasmus Jan 6, 2025
c24ddbc
Merge branch 'develop' into split-up-releases
rasmus Jan 28, 2025
ed074b0
Merge branch 'develop' into split-up-releases
rasmus Jun 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions Source/Bake.Tests/ExplicitTests/GitHubReleaseCookTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
using Bake.Services;
using Bake.Tests.Helpers;
using Bake.ValueObjects;
using Bake.ValueObjects.Artifacts;
using Bake.ValueObjects.Recipes.GitHub;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -44,21 +43,14 @@ public async Task CreateRelease()
{
// Arrange
var recipe = new GitHubReleaseRecipe(
string.Empty,
new GitHubInformation(
"rasmus",
"testtest",
new Uri("https://github.com/rasmus/testtest"),
new Uri("https://api.guthub.com/")),
SemVer.Random,
"a108d8a38b4ac154172cb7eeea8530e316ead798",
new ReleaseNotes(SemVer.Random, "This is a test"),
new Artifact[]
{
new ExecutableArtifact(
"test_linux",
Path.Combine(WorkingDirectory, "README.md"),
new Platform(ExecutableOperatingSystem.Linux, ExecutableArchitecture.Intel64))
});
[]);

// Arrange
var result = await Sut.CookAsync(
Expand Down
6 changes: 6 additions & 0 deletions Source/Bake.Tests/Files/nuget-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="http-source" value="http://localhost:5555/v3/index.json" allowInsecureConnections="true" />
</packageSources>
</configuration>
25 changes: 7 additions & 18 deletions Source/Bake.Tests/Helpers/BakeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ namespace Bake.Tests.Helpers
{
public abstract class BakeTest : TestProject
{
private CancellationTokenSource? _timeout;

private List<Release> _releases = null!;
protected IReadOnlyCollection<Release> Releases => _releases;
protected CancellationToken Timeout => _timeout!.Token;
private List<GitHubRelease> _releases = null!;
protected IReadOnlyCollection<GitHubRelease> Releases => _releases;

protected BakeTest(string projectName) : base(projectName)
{
Expand All @@ -46,15 +43,7 @@ protected BakeTest(string projectName) : base(projectName)
[SetUp]
public void SetUpBakeTest()
{
_timeout = new CancellationTokenSource(TimeSpan.FromMinutes(5));
_releases = new List<Release>();
}

[TearDown]
public void TearDownBakeTest()
{
_timeout?.Dispose();
_timeout = null;
_releases = new List<GitHubRelease>();
}

protected Task<int> ExecuteAsync(
Expand Down Expand Up @@ -107,20 +96,20 @@ private static void ReplaceService<T>(IServiceCollection serviceCollection, T in

private class TestGitHub : IGitHub
{
private readonly List<Release> _releases;
private readonly List<GitHubRelease> _releases;

public TestGitHub(
List<Release> releases)
List<GitHubRelease> releases)
{
_releases = releases;
}

public Task CreateReleaseAsync(
Release release,
GitHubRelease gitHubRelease,
GitHubInformation gitHubInformation,
CancellationToken cancellationToken)
{
_releases.Add(release);
_releases.Add(gitHubRelease);
return Task.CompletedTask;
}

Expand Down
13 changes: 7 additions & 6 deletions Source/Bake.Tests/Helpers/TestFor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ namespace Bake.Tests.Helpers
{
public class TestFor<T> : TestIt
{
protected IServiceProvider ServiceProvider { get; private set; } = null!;
protected T Sut => _lazySut.Value;

private Lazy<T> _lazySut = null!;
private ServiceProvider _serviceProvider = null!;
private Logger _logger = null!;
protected T Sut => _lazySut.Value;

[SetUp]
public void SetUpTestFor()
Expand All @@ -45,18 +46,18 @@ public void SetUpTestFor()
.MinimumLevel.Verbose()
.WriteTo.Sink(new LogSink(A<ILogCollector>()))
.CreateLogger();
_serviceProvider = Configure(new ServiceCollection())
ServiceProvider = Configure(new ServiceCollection())
.AddLogging(b => b.AddSerilog(_logger))
.BuildServiceProvider();

Inject(_serviceProvider.GetRequiredService<ILogger<T>>());
Inject<IServiceProvider>(_serviceProvider);
Inject(ServiceProvider.GetRequiredService<ILogger<T>>());
Inject(ServiceProvider);
}

[TearDown]
public void TearDownTestFor()
{
_serviceProvider.Dispose();
((IDisposable)ServiceProvider).Dispose();
_logger.Dispose();
}

Expand Down
15 changes: 13 additions & 2 deletions Source/Bake.Tests/Helpers/TestIt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ namespace Bake.Tests.Helpers
{
public abstract class TestIt
{
private CancellationTokenSource? _timeout;
private List<string> _filesToDelete = null!;

protected IFixture Fixture { get; private set; } = null!;
protected CancellationToken Timeout => _timeout!.Token;

[SetUp]
public void SetUpTestIt()
{
_timeout = new CancellationTokenSource(TimeSpan.FromMinutes(5));
_filesToDelete = new List<string>();

Fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
Expand All @@ -46,6 +49,9 @@ public void SetUpTestIt()
[TearDown]
public void TearDownTestIt()
{
_timeout?.Dispose();
_timeout = null;

foreach (var file in _filesToDelete)
{
if (File.Exists(file))
Expand Down Expand Up @@ -96,7 +102,7 @@ protected async Task<string> ReadEmbeddedAsync(
var resourceName = resourceNames.Single(n => n.EndsWith(fileEnding, StringComparison.OrdinalIgnoreCase));
await using var stream = assembly.GetManifestResourceStream(resourceName);
using var streamReader = new StreamReader(stream!);
return await streamReader.ReadToEndAsync();
return await streamReader.ReadToEndAsync(Timeout);
}

protected string Lines(
Expand All @@ -105,12 +111,17 @@ protected string Lines(
return string.Join(Environment.NewLine, lines);
}

protected void DeleteAfter(string filePath)
{
_filesToDelete.Add(filePath);
}

protected async Task<string> WriteEmbeddedAsync(
string fileEnding)
{
var content = await ReadEmbeddedAsync(fileEnding);
var path = Path.GetTempFileName();
await System.IO.File.WriteAllTextAsync(path, content);
await File.WriteAllTextAsync(path, content, Timeout);
_filesToDelete.Add(path);
return path;
}
Expand Down
11 changes: 9 additions & 2 deletions Source/Bake.Tests/Helpers/TestProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,27 @@ protected TestProject(
}

[SetUp]
public void SetUpTestProject()
public async Task SetUpTestProject()
{
_folder = Folder.New;

if (!string.IsNullOrEmpty(ProjectName))
{
Sha = GitHelper.Create(_folder.Path);

var destination = Path.Join(_folder.Path, ProjectName);

DirectoryCopy(
Path.Combine(
ProjectHelper.GetRoot(),
"TestProjects",
ProjectName),
Path.Join(_folder.Path, ProjectName));
destination);

var nugetConfig = await ReadEmbeddedAsync("nuget-config.xml");
await System.IO.File.WriteAllTextAsync(
Path.Combine(destination, "nuget.config"),
nugetConfig);
}

_previousCurrentDirectory = Directory.GetCurrentDirectory();
Expand Down
41 changes: 41 additions & 0 deletions Source/Bake.Tests/Helpers/TestService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// MIT License
//
// Copyright (c) 2021-2025 Rasmus Mikkelsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using Microsoft.Extensions.DependencyInjection;

namespace Bake.Tests.Helpers
{
public abstract class TestService<T> : TestFor<T>
where T : class
{
protected override T CreateSut()
{
return ServiceProvider.GetRequiredService<T>();
}

protected override IServiceCollection Configure(IServiceCollection serviceCollection)
{
return base.Configure(serviceCollection)
.AddTransient<T>();
}
}
}
Loading
Loading