Skip to content

Commit

Permalink
- implemented Nox.yaml
Browse files Browse the repository at this point in the history
- changed net version in Dockerfile
  • Loading branch information
jan-schutte committed Feb 6, 2024
1 parent 1c0b101 commit 03bf448
Show file tree
Hide file tree
Showing 24 changed files with 77 additions and 93 deletions.
4 changes: 2 additions & 2 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

RUN apt-get -y update
RUN apt-get install -y libsecret-1-0

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src

COPY ["./Nox.Cli.Server/Nox.Cli.Server.csproj", "Nox.Cli.Server/"]
Expand Down
3 changes: 2 additions & 1 deletion src/Nox.Cli.Abstractions/Caching/INoxCliCacheManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Nox.Cli.Abstractions.Configuration;
using Nox.Cli.Configuration;

namespace Nox.Cli.Abstractions.Caching;

Expand All @@ -11,7 +12,7 @@ public interface INoxCliCacheManager

IManifestConfiguration? Manifest { get; }

List<IWorkflowConfiguration>? Workflows { get; }
List<WorkflowConfiguration>? Workflows { get; }

List<string> BuildLog { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Nox.Cli.Configuration;

public class ActionConfiguration: IActionConfiguration
public class ActionConfiguration
{
public string Id { get; set; } = string.Empty;
public string? If { get; set; } = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Nox.Cli.Configuration;

public class CliConfiguration: ICliConfiguration
public class CliConfiguration
{
public string Branch { get; set; } = string.Empty;
public string Command { get; set; } = string.Empty;
Expand Down
14 changes: 0 additions & 14 deletions src/Nox.Cli.Abstractions/Configuration/IActionConfiguration.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/Nox.Cli.Abstractions/Configuration/ICliConfiguration.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/Nox.Cli.Abstractions/Configuration/IJobConfiguration.cs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Nox.Cli.Configuration;

public class JobConfiguration: IJobConfiguration
public class JobConfiguration
{
public string Id { get; set; } = string.Empty;

Expand All @@ -13,5 +13,5 @@ public class JobConfiguration: IJobConfiguration
public string? ForEach { get; set; }

public NoxJobDisplayMessage? Display { get; set; }
public List<IActionConfiguration> Steps { get; set; } = new();
public List<ActionConfiguration> Steps { get; set; } = new();
}
13 changes: 13 additions & 0 deletions src/Nox.Cli.Abstractions/Configuration/WorkflowConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Nox.Cli.Abstractions.Configuration;
using Nox.Yaml;

namespace Nox.Cli.Configuration;

public class WorkflowConfiguration: YamlConfigNode<WorkflowConfiguration>
{
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public CliConfiguration Cli { get; set; } = null!;
public List<JobConfiguration> Jobs { get; set; } = new();
}

3 changes: 2 additions & 1 deletion src/Nox.Cli.Abstractions/INoxWorkflowExecutor.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using Nox.Cli.Abstractions.Configuration;
using Nox.Cli.Configuration;
using Spectre.Console.Cli;

namespace Nox.Cli.Abstractions;

public interface INoxWorkflowExecutor
{
Task<bool> Execute(IWorkflowConfiguration workflow, IRemainingArguments arguments);
Task<bool> Execute(WorkflowConfiguration workflow, IRemainingArguments arguments);
}
4 changes: 2 additions & 2 deletions src/Nox.Cli.Abstractions/Nox.Cli.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Nox.Secrets.Abstractions" Version="7.0.185" />
<PackageReference Include="Nox.Secrets.Abstractions" Version="7.0.187" />
<PackageReference Include="Spectre.Console.Cli" Version="0.48.0" />
<PackageReference Include="Nox.Solution" Version="7.0.185" />
<PackageReference Include="Nox.Solution" Version="7.0.187" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/Nox.Cli.Caching/Nox.Cli.Caching.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Nox.Secrets.Azure" Version="7.0.185" />
<PackageReference Include="Nox.Secrets.Azure" Version="7.0.187" />
<PackageReference Include="Nox.Yaml" Version="7.0.187" />
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="Spectre.Console" Version="0.48.0" />
<PackageReference Include="YamlDotNet" Version="15.1.1" />
</ItemGroup>

</Project>
36 changes: 22 additions & 14 deletions src/Nox.Cli.Caching/NoxCliCacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Nox.Cli.Abstractions.Helpers;
using Nox.Cli.Configuration;
using Nox.Cli.Helpers;
using Nox.Yaml;
using RestSharp;
using Spectre.Console;
using YamlDotNet.Serialization;
Expand All @@ -31,7 +32,7 @@ public class NoxCliCacheManager: INoxCliCacheManager
private Uri? _workflowUri;
private List<string> _buildLog;
private IManifestConfiguration? _manifest;
private List<IWorkflowConfiguration>? _workflows;
private List<WorkflowConfiguration>? _workflows;
private IPersistedTokenCache? _tokenCache;
private IDeserializer _deserializer;
private string? _tenantId;
Expand Down Expand Up @@ -96,7 +97,7 @@ public IManifestConfiguration? Manifest
get => _manifest;
}

public List<IWorkflowConfiguration>? Workflows
public List<WorkflowConfiguration>? Workflows
{
get => _workflows;
}
Expand Down Expand Up @@ -349,10 +350,13 @@ internal void GetOnlineWorkflowsAndManifest(IDictionary<string, string> yamlFile
File.Delete(Path.Combine(_workflowCachePath, orphanEntry));
}

foreach (var entry in yamlFiles)
{
yamlFiles[entry.Key] = YamlHelper.ResolveYamlReferences(Path.Combine(_workflowCachePath, entry.Key));
}



// foreach (var entry in yamlFiles)
// {
// yamlFiles[entry.Key] = YamlHelper.ResolveYamlReferences(Path.Combine(_workflowCachePath, entry.Key));
// }

_cache!.WorkflowInfo = onlineFiles;
if (hasRefreshed) RaiseBuildEvent($"[bold yellow]Workflow cache successfully updated from remote.[/]");
Expand Down Expand Up @@ -403,9 +407,9 @@ private IDeserializer BuildDeserializer()
return new DeserializerBuilder()
.WithNamingConvention(HyphenatedNamingConvention.Instance)
.IgnoreUnmatchedProperties()
.WithTypeMapping<IActionConfiguration, ActionConfiguration>()
.WithTypeMapping<ICliConfiguration, CliConfiguration>()
.WithTypeMapping<IJobConfiguration, JobConfiguration>()
//.WithTypeMapping<IActionConfiguration, ActionConfiguration>()
//.WithTypeMapping<ICliConfiguration, CliConfiguration>()
//.WithTypeMapping<IJobConfiguration, JobConfiguration>()
.WithTypeMapping<ICliCommandConfiguration, CliCommandConfiguration>()
.WithTypeMapping<ILocalTaskExecutorConfiguration, LocalTaskExecutorConfiguration>()
.WithTypeMapping<ISecretsConfiguration, SecretsConfiguration>()
Expand All @@ -426,16 +430,20 @@ internal void ResolveManifest(Dictionary<string, string> yamlFiles)

internal void ResolveWorkflows(Dictionary<string, string> yamlFiles)
{
_workflows = new List<IWorkflowConfiguration>();
foreach (var yaml in yamlFiles.Where(kv => kv.Key.EndsWith(FileExtension.WorkflowDefinition.TrimStart('*'))))
_workflows = new List<WorkflowConfiguration>();
var workflowFiles = yamlFiles.Where(f => f.Key.EndsWith("workflow.nox.yaml", StringComparison.OrdinalIgnoreCase));
foreach (var workflowFile in workflowFiles)
{
var reader = new YamlConfigurationReader<WorkflowConfiguration>()
.WithFile(Path.Combine(_workflowCachePath, workflowFile.Key));
try
{
_workflows.Add(_deserializer.Deserialize<WorkflowConfiguration>(yaml.Value));
var workflow = reader.Read();
_workflows.Add(workflow);
}
catch (Exception ex)
catch(Exception ex)
{
throw new NoxCliException($"Unable to deserialize workflow {yaml.Key}. {ex.Message}");
throw new NoxCliException($"Unable to parse workflow file {workflowFile.Key}", ex);
}
}
}
Expand Down
12 changes: 0 additions & 12 deletions src/Nox.Cli.Configuration/WorkflowConfiguration.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Nox.Cli.Server/Nox.Cli.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="Elastic.Apm.NetCoreAll" Version="1.25.3" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.1" />
<PackageReference Include="Microsoft.Identity.Web" Version="2.16.1" />
<PackageReference Include="Microsoft.Identity.Web" Version="2.17.0" />
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.0" />
Expand Down
5 changes: 3 additions & 2 deletions src/Nox.Cli.Variables/ClientVariableProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Nox.Cli.Abstractions;
using Nox.Cli.Abstractions.Caching;
using Nox.Cli.Abstractions.Configuration;
using Nox.Cli.Configuration;
using Nox.Cli.Variables.Secrets;
using Nox.Solution;
using YamlDotNet.Serialization;
Expand All @@ -22,7 +23,7 @@ public class ClientVariableProvider: IClientVariableProvider


public ClientVariableProvider(
IWorkflowConfiguration workflow,
WorkflowConfiguration workflow,
IOrgSecretResolver orgSecretResolver,
NoxSolution? projectConfig = null,
ILocalTaskExecutorConfiguration? lteConfig = null,
Expand Down Expand Up @@ -187,7 +188,7 @@ public void ResolveJobVariables(INoxJob job)
}
}

private void Initialize(IWorkflowConfiguration workflow)
private void Initialize(WorkflowConfiguration workflow)
{
var serializer = new SerializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
Expand Down
2 changes: 1 addition & 1 deletion src/Nox.Cli.Variables/Nox.Cli.Variables.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Abstractions" Version="8.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Nox.Types" Version="7.0.185" />
<PackageReference Include="Nox.Types" Version="7.0.187" />
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="YamlDotNet" Version="15.1.1" />
<PackageReference Include="Azure.Identity" Version="1.10.4" />
Expand Down
9 changes: 9 additions & 0 deletions src/Nox.Cli.WorkflowBuilder/Nox.Cli.WorkflowBuilder.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
6 changes: 6 additions & 0 deletions src/Nox.Cli.WorkflowBuilder/WorkflowConfigurationReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Nox.Cli.WorkflowBuilder;

public class WorkflowConfigurationReader
{

}
7 changes: 4 additions & 3 deletions src/Nox.Cli/Actions/NoxWorkflowContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Diagnostics;
using Nox.Cli.Abstractions.Caching;
using Nox.Cli.Abstractions.Exceptions;
using Nox.Cli.Configuration;
using Nox.Cli.Variables.Secrets;
using Nox.Secrets.Abstractions;
using Nox.Solution;
Expand All @@ -15,7 +16,7 @@ namespace Nox.Cli.Actions;

public class NoxWorkflowContext : INoxWorkflowContext
{
private readonly IWorkflowConfiguration _workflow;
private readonly WorkflowConfiguration _workflow;
private readonly NoxJobDictionary _jobs;
private IDictionary<string, INoxAction> _steps;
private readonly IClientVariableProvider _varProvider;
Expand All @@ -39,7 +40,7 @@ public class NoxWorkflowContext : INoxWorkflowContext
public INoxAction? CurrentAction => _currentAction;

public NoxWorkflowContext(
IWorkflowConfiguration workflow,
WorkflowConfiguration workflow,
NoxSolution projectConfig,
IOrgSecretResolver orgSecretResolver,
INoxCliCacheManager cacheManager,
Expand Down Expand Up @@ -260,7 +261,7 @@ public INoxJob ParseJob(string jobId, int sequence)
return newJob;
}

private Dictionary<string, INoxAction> ParseSteps(IJobConfiguration jobConfiguration, bool ignoreDuplicateSteps = false)
private Dictionary<string, INoxAction> ParseSteps(JobConfiguration jobConfiguration, bool ignoreDuplicateSteps = false)
{
var sequence = 1;
var steps = new Dictionary<string, INoxAction>(StringComparer.OrdinalIgnoreCase);
Expand Down
3 changes: 2 additions & 1 deletion src/Nox.Cli/Actions/NoxWorkflowExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Nox.Cli.Abstractions.Caching;
using Nox.Cli.Abstractions.Configuration;
using Nox.Cli.Abstractions.Exceptions;
using Nox.Cli.Configuration;
using Nox.Cli.ServerIntegration;
using Nox.Cli.Variables;
using Nox.Cli.Variables.Secrets;
Expand Down Expand Up @@ -43,7 +44,7 @@ public NoxWorkflowExecutor(
_noxSecretsResolver = noxSecretsResolver;
}

public async Task<bool> Execute(IWorkflowConfiguration workflow, IRemainingArguments arguments)
public async Task<bool> Execute(WorkflowConfiguration workflow, IRemainingArguments arguments)
{
var workflowDescription = $"[seagreen1]Executing workflow: {workflow.Name.EscapeMarkup()}[/]";
_console.WriteLine();
Expand Down
2 changes: 1 addition & 1 deletion src/Nox.Cli/Nox.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Graph" Version="5.41.0" />
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="16.205.1" />
<PackageReference Include="Nox.Secrets" Version="7.0.185" />
<PackageReference Include="Nox.Secrets" Version="7.0.187" />
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="Spectre.Console" Version="0.48.0" />
<PackageReference Include="Spectre.Console.Cli" Version="0.48.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/Nox.Cli/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"Nox.Cli": {
"commandName": "Project",
"commandLineArgs": "sync helm-chart",
"commandLineArgs": "sync vc",
"workingDirectory": "/home/jan/demo/CliDemo",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand Down

0 comments on commit 03bf448

Please sign in to comment.