Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the default versions for the github actions to the latest #1023

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions src/Nuke/GithubActions/CheckoutStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/// <param name="name"></param>
public CheckoutStep(string name) : base(name)
{
Uses = "actions/checkout@v2";
Uses = "actions/checkout@v4";

Check warning on line 14 in src/Nuke/GithubActions/CheckoutStep.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/CheckoutStep.cs#L14

Added line #L14 was not covered by tests
}

/// <summary>
Expand Down Expand Up @@ -121,9 +121,9 @@
/// <inheritdoc />
public override void Write(CustomFileWriter writer)
{
#pragma warning disable CA1308
#pragma warning disable CA1308
WithProperties(x => x.Underscore().Hyphenate().ToLowerInvariant());
#pragma warning restore CA1308
#pragma warning restore CA1308
base.Write(writer);
}
}
}
8 changes: 4 additions & 4 deletions src/Nuke/GithubActions/DownloadArtifactSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/// <param name="name"></param>
public DownloadArtifactSet(string name) : base(name)
{
Uses = "actions/download-artifact@v1";
Uses = "actions/download-artifact@v3";

Check warning on line 14 in src/Nuke/GithubActions/DownloadArtifactSet.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/DownloadArtifactSet.cs#L14

Added line #L14 was not covered by tests
}

/// <summary>
Expand All @@ -27,9 +27,9 @@
/// <inheritdoc />
public override void Write(CustomFileWriter writer)
{
#pragma warning disable CA1308
#pragma warning disable CA1308
WithProperties(x => x.Underscore().Camelize().ToLowerInvariant());
#pragma warning restore CA1308
#pragma warning restore CA1308
base.Write(writer);
}

Expand All @@ -38,4 +38,4 @@
{
return $"🚀 {name}";
}
}
}
143 changes: 73 additions & 70 deletions src/Nuke/GithubActions/GithubActionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,58 +20,39 @@
/// <returns></returns>
public static RocketSurgeonGitHubActionsConfiguration AddNugetPublish(this RocketSurgeonGitHubActionsConfiguration configuration)
{
configuration.DetailedTriggers.OfType<RocketSurgeonGitHubActionsWorkflowTrigger>().ForEach(
trigger =>
{
trigger.Secrets.Add(new GitHubActionsSecret("RSG_NUGET_API_KEY"));
trigger.Secrets.Add(new GitHubActionsSecret("RSG_AZURE_DEVOPS"));
}
);
configuration
.DetailedTriggers.OfType<RocketSurgeonGitHubActionsWorkflowTrigger>()
.ForEach(
trigger =>
{
trigger.Secrets.Add(new("RSG_NUGET_API_KEY"));
trigger.Secrets.Add(new("RSG_AZURE_DEVOPS"));
}
);

Check warning on line 31 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L23-L31

Added lines #L23 - L31 were not covered by tests
configuration.Jobs.Add(
new RocketSurgeonsGithubWorkflowJob("Publish")
{
Needs = { "Build" },
Needs = { "Build", },

Check warning on line 35 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L35

Added line #L35 was not covered by tests
Uses = "RocketSurgeonsGuild/actions/.github/workflows/publish-nuget.yml@v0.3.0",
Secrets = new Dictionary<string, string>
{
["RSG_NUGET_API_KEY"] = "${{ secrets.RSG_NUGET_API_KEY }}",
["RSG_AZURE_DEVOPS"] = "${{ secrets.RSG_AZURE_DEVOPS }}",
}
Secrets = new()
{
["RSG_NUGET_API_KEY"] = "${{ secrets.RSG_NUGET_API_KEY }}",
["RSG_AZURE_DEVOPS"] = "${{ secrets.RSG_AZURE_DEVOPS }}",
},

Check warning on line 41 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L37-L41

Added lines #L37 - L41 were not covered by tests
}
);
return configuration;
}

private static readonly string[] _pathsIgnore =
{
".codecov.yml",
".editorconfig",
".gitattributes",
".gitignore",
".gitmodules",
".lintstagedrc.js",
".prettierignore",
".prettierrc",
"LICENSE",
"nukeeper.settings.json",
"omnisharp.json",
"package-lock.json",
"package.json",
"Readme.md",
".github/dependabot.yml",
".github/labels.yml",
".github/release.yml",
".github/renovate.json",
};

/// <summary>
/// Adds a new step to the current configuration
/// </summary>
/// <param name="configuration"></param>
/// <param name="job"></param>
/// <returns></returns>
public static RocketSurgeonGitHubActionsConfiguration AddJob(
this RocketSurgeonGitHubActionsConfiguration configuration, RocketSurgeonsGithubActionsJobBase job
this RocketSurgeonGitHubActionsConfiguration configuration,
RocketSurgeonsGithubActionsJobBase job
)
{
configuration.Jobs.Add(job);
Expand Down Expand Up @@ -171,15 +152,15 @@
job.InsertAfterCheckOut(
new UsingStep("NuGet Cache")
{
Uses = "actions/cache@v2",
Uses = "actions/cache@v3",

Check warning on line 155 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L155

Added line #L155 was not covered by tests
With =
{
["path"] = "${{ github.workspace }}/.nuget/packages",
// keep in mind using central package versioning here
["key"] = "${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}-${{ hashFiles('**/Directory.Packages.support.props') }}",
["restore-keys"] = @"|
${{ runner.os }}-nuget-"
}
${{ runner.os }}-nuget-",
},

Check warning on line 163 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L162-L163

Added lines #L162 - L163 were not covered by tests
}
);
return job;
Expand All @@ -192,7 +173,7 @@
/// <returns></returns>
public static RocketSurgeonsGithubActionsJob ConfigureForGitVersion(this RocketSurgeonsGithubActionsJob job)
{
job.InsertAfterCheckOut(new RunStep("Fetch all history for all tags and branches") { Run = "git fetch --prune" });
job.InsertAfterCheckOut(new RunStep("Fetch all history for all tags and branches") { Run = "git fetch --prune", });

Check warning on line 176 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L176

Added line #L176 was not covered by tests
return job;
}

Expand All @@ -213,7 +194,7 @@
{
Name = "nuget",
Path = "artifacts/nuget/",
If = "always()"
If = "always()",

Check warning on line 197 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L197

Added line #L197 was not covered by tests
}
);
job.InternalData[typeof(IHaveNuGetPackages)] = true;
Expand Down Expand Up @@ -251,7 +232,7 @@
{
Name = "coverage",
Path = "coverage/",
If = "always()"
If = "always()",

Check warning on line 235 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L235

Added line #L235 was not covered by tests
}
);

Expand All @@ -261,10 +242,10 @@
job,
new UsingStep("Publish Coverage")
{
Uses = "codecov/codecov-action@v1",
Uses = "codecov/codecov-action@v3",

Check warning on line 245 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L245

Added line #L245 was not covered by tests
If =
"(github.event_name != 'pull_request' && github.event_name != 'pull_request_target') || ((github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.pull_request.user.login != 'renovate[bot]' && github.event.pull_request.user.login != 'dependabot[bot]')",
With = new() { ["name"] = "actions-${{ matrix.os }}" }
With = new() { ["name"] = "actions-${{ matrix.os }}", },

Check warning on line 248 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L248

Added line #L248 was not covered by tests
}
);
}
Expand All @@ -278,7 +259,7 @@
{
Name = "logs",
Path = "artifacts/logs/",
If = "always()"
If = "always()",

Check warning on line 262 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L262

Added line #L262 was not covered by tests
}
);
}
Expand All @@ -291,7 +272,7 @@
{
Name = "test data",
Path = "artifacts/test/",
If = "always()"
If = "always()",

Check warning on line 275 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L275

Added line #L275 was not covered by tests
}
);
}
Expand Down Expand Up @@ -345,31 +326,10 @@
public static RocketSurgeonsGithubActionsJob UseDotNetSdk(this RocketSurgeonsGithubActionsJob job, string version, string? exactVersion = null)
{
exactVersion ??= version + ".x";
job.InsertAfterCheckOut(new SetupDotNetStep($"Use .NET Core {version} SDK") { DotNetVersion = exactVersion });
job.InsertAfterCheckOut(new SetupDotNetStep($"Use .NET Core {version} SDK") { DotNetVersion = exactVersion, });

Check warning on line 329 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L329

Added line #L329 was not covered by tests
return job;
}

private static readonly ConcurrentDictionary<ITargetDefinition, List<GitHubActionsOutput>> outputPaths = new();

// ReSharper disable once NullableWarningSuppressionIsUsed
private static readonly PropertyInfo DefinitionProperty =
typeof(ExecutableTarget).GetProperty("Definition", BindingFlags.Instance | BindingFlags.NonPublic)!;


internal static List<GitHubActionsOutput> GetGithubActionsOutput(ExecutableTarget target)
{
// ReSharper disable once NullableWarningSuppressionIsUsed
var def = (ITargetDefinition)DefinitionProperty.GetValue(target)!;
if (outputPaths.TryGetValue(def, out var paths))
{
return paths;
}

paths = new();
outputPaths[def] = paths;
return paths;
}

/// <summary>
/// Set an output for github actions
/// </summary>
Expand Down Expand Up @@ -399,7 +359,50 @@
outputPaths[target] = paths;
}

paths.Add(new GitHubActionsOutput(outputName, description));
paths.Add(new(outputName, description));

Check warning on line 362 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L362

Added line #L362 was not covered by tests
return target;
}
}


internal static List<GitHubActionsOutput> GetGithubActionsOutput(ExecutableTarget target)
{

Check warning on line 368 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L368

Added line #L368 was not covered by tests
// ReSharper disable once NullableWarningSuppressionIsUsed
var def = (ITargetDefinition)DefinitionProperty.GetValue(target)!;

Check warning on line 370 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L370

Added line #L370 was not covered by tests
if (outputPaths.TryGetValue(def, out var paths))
{
return paths;

Check warning on line 373 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L372-L373

Added lines #L372 - L373 were not covered by tests
}

paths = new();
outputPaths[def] = paths;
return paths;
}

Check warning on line 379 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L376-L379

Added lines #L376 - L379 were not covered by tests

private static readonly string[] _pathsIgnore =
{
".codecov.yml",
".editorconfig",
".gitattributes",
".gitignore",
".gitmodules",
".lintstagedrc.js",
".prettierignore",
".prettierrc",
"LICENSE",
"nukeeper.settings.json",
"omnisharp.json",
"package-lock.json",
"package.json",
"Readme.md",
".github/dependabot.yml",
".github/labels.yml",
".github/release.yml",
".github/renovate.json",
};

Check warning on line 401 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L381-L401

Added lines #L381 - L401 were not covered by tests

private static readonly ConcurrentDictionary<ITargetDefinition, List<GitHubActionsOutput>> outputPaths = new();

Check warning on line 403 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L403

Added line #L403 was not covered by tests

// ReSharper disable once NullableWarningSuppressionIsUsed
private static readonly PropertyInfo DefinitionProperty =
typeof(ExecutableTarget).GetProperty("Definition", BindingFlags.Instance | BindingFlags.NonPublic)!;

Check warning on line 407 in src/Nuke/GithubActions/GithubActionsExtensions.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/GithubActionsExtensions.cs#L406-L407

Added lines #L406 - L407 were not covered by tests
}
4 changes: 2 additions & 2 deletions src/Nuke/GithubActions/SetupDotNetStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public SetupDotNetStep(string name) : base(name)
{
// temporary to deal with sxs issue roll back once https://github.com/actions/setup-dotnet/pull/71 is merged
Uses = "actions/setup-dotnet@v1";
Uses = "actions/setup-dotnet@v3";

Check warning on line 17 in src/Nuke/GithubActions/SetupDotNetStep.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/SetupDotNetStep.cs#L17

Added line #L17 was not covered by tests
}

/// <summary>SDK version to use. Example: 2.2.104</summary>
Expand Down Expand Up @@ -76,4 +76,4 @@

base.Write(writer);
}
}
}
8 changes: 4 additions & 4 deletions src/Nuke/GithubActions/UploadArtifactStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/// <param name="name"></param>
public UploadArtifactStep(string name) : base(name)
{
Uses = "actions/upload-artifact@v2";
Uses = "actions/upload-artifact@v3";

Check warning on line 14 in src/Nuke/GithubActions/UploadArtifactStep.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/GithubActions/UploadArtifactStep.cs#L14

Added line #L14 was not covered by tests
}

/// <summary>
Expand All @@ -27,9 +27,9 @@
/// <inheritdoc />
public override void Write(CustomFileWriter writer)
{
#pragma warning disable CA1308
#pragma warning disable CA1308
WithProperties(x => x.Underscore().Camelize().ToLowerInvariant());
#pragma warning restore CA1308
#pragma warning restore CA1308
base.Write(writer);
}

Expand All @@ -38,4 +38,4 @@
{
return $"🏺 {name}";
}
}
}
59 changes: 28 additions & 31 deletions src/Nuke/ICanRegenerateBuildConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,32 @@
/// <summary>
/// Regenerate the build configurations
/// </summary>
public Target RegenerateBuildConfigurations => t =>
t
.TryDependentFor<ICanLintStagedFiles>(static z => z.LintStaged)
.TryTriggeredBy<ICanLint>(static z => z.Lint)
// We run during LintStaged, no need to run again during the lint that lint-staged kicks off.
.OnlyWhenDynamic(() => !EnvironmentInfo.HasVariable("RSG_NUKE_LINT_STAGED"))
.Unlisted()
.Executes(
() =>
{
var allHosts = GetType()
.GetCustomAttributes<ConfigurationAttributeBase>()
.OfType<IConfigurationGenerator>();
public Target RegenerateBuildConfigurations =>
t => t
.TryDependentFor<ICanLintStagedFiles>(static z => z.LintStaged)
.TryTriggeredBy<ICanLint>(static z => z.Lint)
// We run during LintStaged, no need to run again during the lint that lint-staged kicks off.
.OnlyWhenDynamic(() => !EnvironmentInfo.HasVariable("RSG_NUKE_LINT_STAGED"))
.Unlisted()
.Executes(
() =>
{
var allHosts = GetType()
.GetCustomAttributes<ConfigurationAttributeBase>()
.OfType<IConfigurationGenerator>();

Check warning on line 28 in src/Nuke/ICanRegenerateBuildConfiguration.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/ICanRegenerateBuildConfiguration.cs#L17-L28

Added lines #L17 - L28 were not covered by tests

allHosts
// ReSharper disable once NullableWarningSuppressionIsUsed
.Select(
z =>
$"""{Assembly.GetEntryAssembly()!.Location} --{BuildServerConfigurationGeneration.ConfigurationParameterName} {z.Id} --host {z.HostName}"""
)
.ForEach(
command => DotNetTasks.DotNet(
command,
environmentVariables: EnvironmentInfo.Variables.AddIfMissing(
"NUKE_INTERNAL_INTERCEPTOR",
"1"
)
)
);
}
);
}
allHosts
.Select(
z =>
// ReSharper disable once NullableWarningSuppressionIsUsed
$"""{Assembly.GetEntryAssembly()!.Location} --{BuildServerConfigurationGeneration.ConfigurationParameterName} {z.Id} --host {z.HostName}"""
)
.ForEach(
command => DotNetTasks.DotNet(
command,
environmentVariables: EnvironmentInfo.Variables.AddIfMissing("NUKE_INTERNAL_INTERCEPTOR", "1")
)
);
}
);

Check warning on line 43 in src/Nuke/ICanRegenerateBuildConfiguration.cs

View check run for this annotation

Codecov / codecov/patch

src/Nuke/ICanRegenerateBuildConfiguration.cs#L30-L43

Added lines #L30 - L43 were not covered by tests
}
Loading