-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aac8330
commit 1db8ab0
Showing
7 changed files
with
90 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using Nuke.Common.CI; | ||
using Nuke.Common.CI.GitHubActions; | ||
using Nuke.Common.Execution; | ||
|
||
namespace Rocket.Surgery.Nuke.GithubActions; | ||
|
||
/// <summary> | ||
/// An attribute to help adding the lint workflow | ||
/// </summary> | ||
[PublicAPI] | ||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] | ||
public class GitHubActionsLintAttribute : GitHubActionsStepsAttribute | ||
{ | ||
/// <summary> | ||
/// The default constructor | ||
/// </summary> | ||
/// <param name="name"></param> | ||
/// <param name="image"></param> | ||
/// <param name="images"></param> | ||
public GitHubActionsLintAttribute( | ||
string name, | ||
GitHubActionsImage image, | ||
params GitHubActionsImage[] images | ||
) : base(name, image, images) | ||
{ | ||
InvokedTargets = new[] { nameof(ICanLintStagedFiles.LintStaged) }; | ||
} | ||
|
||
/// <summary> | ||
/// The default constructor | ||
/// </summary> | ||
/// <param name="name"></param> | ||
/// <param name="image"></param> | ||
/// <param name="images"></param> | ||
public GitHubActionsLintAttribute( | ||
string name, | ||
string image, | ||
params string[] images | ||
) : base(name, image, images) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override ConfigurationEntity GetConfiguration(IReadOnlyCollection<ExecutableTarget> relevantTargets) | ||
{ | ||
var config = base.GetConfiguration(relevantTargets); | ||
if (config is not RocketSurgeonGitHubActionsConfiguration configuration) | ||
{ | ||
return config; | ||
} | ||
|
||
var buildJob = | ||
configuration | ||
.Jobs.OfType<RocketSurgeonsGithubActionsJob>() | ||
.First(z => z.Name.Equals("Build", StringComparison.OrdinalIgnoreCase)); | ||
|
||
configuration.Permissions.Contents = GitHubActionsPermission.Write; | ||
|
||
buildJob | ||
.ConfigureStep<CheckoutStep>( | ||
step => | ||
{ | ||
step.Repository = "${{ github.event.pull_request.head.repo.full_name }}"; | ||
step.Ref = "${{ github.event.pull_request.head.ref }}"; | ||
} | ||
) | ||
.AddStep( | ||
new UsingStep("Add & Commit") | ||
{ | ||
Uses = "EndBug/add-and-commit@v9", | ||
With = { ["message"] = "Automatically linting code", } | ||
} | ||
); | ||
|
||
buildJob.Name = "lint"; | ||
|
||
return configuration; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
#nullable enable | ||
Rocket.Surgery.Nuke.ICanLintStagedFiles.LintStaged.get -> Nuke.Common.Target! | ||
#nullable enable |