-
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.
Merge pull request #1 from RocketSurgeonsGuild/feature/readme
Added support for generating parts of the readme to keep them in sync
- Loading branch information
Showing
24 changed files
with
777 additions
and
22 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
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,11 +1,65 @@ | ||
# Rocket Surgeons Guild Nuke | ||
# Rocket Surgery - Nuke | ||
|
||
| Build | Test | Release | | ||
|---|---|---| | ||
| | | ||
| [![Nuke Pipelines Build Status](https://img.shields.io/vso/build/RocketSurgeonsGuild/Libraries/RSG.Nuke.svg?logo=visualstudiocode&style=flat-square)](https://rocketsurgeonsguild.visualstudio.com/Libraries/_build?definitionId=3) | | | ||
| | | ![MyGet Pre Release](https://img.shields.io/myget/rocket-surgeons-guild/vpre/Nuke.svg?logo=nuget&style=flat-square&label=myget) | | ||
Every good Rocket Surgeon needs multiple choices of build systems to pick from them for their best work. This is an integration for the `Nuke` build system with some defaults for all Rocket Surgeon Repositories (or if you follow the same structure, you can use it too!) | ||
|
||
[![Nuke Pipelines Build History](https://buildstats.info/azurepipelines/chart/RocketSurgeonsGuild/Libraries/3)](https://rocketsurgeonsguild.visualstudio.com/Libraries/_build?definitionId=3) | ||
<!-- badges --> | ||
[![github-release-badge]][github-release] | ||
[![github-license-badge]][github-license] | ||
[![codecov-badge]][codecov] | ||
[![codacy-badge]][codacy] | ||
<!-- badges --> | ||
|
||
## More info to come... | ||
<!-- history badges --> | ||
| Azure Pipelines | AppVeyor | | ||
| --------------- | -------- | | ||
| [![azurepipelines-badge]][azurepipelines] | [![appveyor-badge]][appveyor] | | ||
| [![azurepipelines-history-badge]][azurepipelines-history] | [![appveyor-history-badge]][appveyor-history] | | ||
<!-- history badges --> | ||
|
||
<!-- nuget packages --> | ||
| Package | NuGet | MyGet | | ||
| ------- | ----- | ----- | | ||
| Rocket.Surgery.Nuke | [![nuget-version-6plqb7nwtdoa-badge]![nuget-downloads-6plqb7nwtdoa-badge]][nuget-6plqb7nwtdoa] | [![myget-version-6plqb7nwtdoa-badge]![myget-downloads-6plqb7nwtdoa-badge]][myget-6plqb7nwtdoa] | | ||
<!-- nuget packages --> | ||
|
||
<!-- generated references --> | ||
[github-release]: https://github.com/RocketSurgeonsGuild/Nuke/releases/latest | ||
[github-release-badge]: https://img.shields.io/github/release/RocketSurgeonsGuild/Nuke.svg?logo=github&style=flat "Latest Release" | ||
[github-license]: https://github.com/RocketSurgeonsGuild/Nuke/blob/master/LICENSE | ||
[github-license-badge]: https://img.shields.io/github/license/RocketSurgeonsGuild/Nuke.svg?style=flat "License" | ||
[codecov]: https://codecov.io/gh/RocketSurgeonsGuild/Nuke | ||
[codecov-badge]: https://img.shields.io/codecov/c/github/RocketSurgeonsGuild/Nuke.svg?color=E03997&label=codecov&logo=codecov&logoColor=E03997&style=flat "Code Coverage" | ||
[codacy]: https://www.codacy.com/app/RocketSurgeonsGuild/Nuke | ||
[codacy-badge]: https://api.codacy.com/project/badge/Grade/d31c561959b34f35ae2d99979bfb239a "Codacy" | ||
[azurepipelines]: https://rocketsurgeonsguild.visualstudio.com/Libraries/_build/latest?definitionId=31&branchName=master | ||
[azurepipelines-badge]: https://img.shields.io/azure-devops/build/rocketsurgeonsguild/Libraries/31.svg?color=98C6FF&label=azure%20pipelines&logo=azuredevops&logoColor=98C6FF&style=flat "Azure Pipelines Status" | ||
[azurepipelines-history]: https://rocketsurgeonsguild.visualstudio.com/Libraries/_build?definitionId=31&branchName=master | ||
[azurepipelines-history-badge]: https://buildstats.info/azurepipelines/chart/rocketsurgeonsguild/Libraries/31?includeBuildsFromPullRequest=false "Azure Pipelines History" | ||
[appveyor]: https://ci.appveyor.com/project/RocketSurgeonsGuild/Nuke | ||
[appveyor-badge]: https://img.shields.io/appveyor/ci/RocketSurgeonsGuild/Nuke.svg?color=00b3e0&label=appveyor&logo=appveyor&logoColor=00b3e0&style=flat "AppVeyor Status" | ||
[appveyor-history]: https://ci.appveyor.com/project/RocketSurgeonsGuild/Nuke/history | ||
[appveyor-history-badge]: https://buildstats.info/appveyor/chart/RocketSurgeonsGuild/Nuke?includeBuildsFromPullRequest=false "AppVeyor History" | ||
[nuget-6plqb7nwtdoa]: https://www.nuget.org/packages/Rocket.Surgery.Nuke/ | ||
[nuget-version-6plqb7nwtdoa-badge]: https://img.shields.io/nuget/v/Rocket.Surgery.Nuke.svg?color=004880&logo=nuget&style=flat-square "NuGet Version" | ||
[nuget-downloads-6plqb7nwtdoa-badge]: https://img.shields.io/nuget/dt/Rocket.Surgery.Nuke.svg?color=004880&logo=nuget&style=flat-square "NuGet Downloads" | ||
[myget-6plqb7nwtdoa]: https://www.myget.org/feed/rocket-surgeons-guild/package/nuget/Rocket.Surgery.Nuke | ||
[myget-version-6plqb7nwtdoa-badge]: https://img.shields.io/myget/rocket-surgeons-guild/vpre/Rocket.Surgery.Nuke.svg?label=myget&color=004880&logo=nuget&style=flat-square "MyGet Pre-Release Version" | ||
[myget-downloads-6plqb7nwtdoa-badge]: https://img.shields.io/myget/rocket-surgeons-guild/dt/Rocket.Surgery.Nuke.svg?color=004880&logo=nuget&style=flat-square "MyGet Downloads" | ||
<!-- generated references --> | ||
|
||
<!-- nuke-data | ||
github: | ||
owner: RocketSurgeonsGuild | ||
repository: Nuke | ||
azurepipelines: | ||
account: rocketsurgeonsguild | ||
teamproject: Libraries | ||
builddefinition: 31 | ||
appveyor: | ||
account: RocketSurgeonsGuild | ||
build: Nuke | ||
myget: | ||
account: rocket-surgeons-guild | ||
codacy: | ||
project: d31c561959b34f35ae2d99979bfb239a | ||
--> |
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,31 @@ | ||
using System.Collections.Generic; | ||
using System.Dynamic; | ||
|
||
namespace Rocket.Surgery.Nuke.Readme | ||
{ | ||
class AppVeyorHistory : IHistorySection | ||
{ | ||
public string Name { get; } = "AppVeyor"; | ||
|
||
public string ConfigKey { get; } = "appveyor"; | ||
|
||
public (string badge, string history) Process(IDictionary<object, object> config, IMarkdownReferences references, | ||
RocketBoosterBuild build) | ||
{ | ||
var url = references.AddReference("appveyor", $"https://ci.appveyor.com/project/{config["account"]}/{config["build"]}"); | ||
var badge = references.AddReference( | ||
"appveyor-badge", | ||
$"https://img.shields.io/appveyor/ci/{config["account"]}/{config["build"]}.svg?color=00b3e0&label=appveyor&logo=appveyor&logoColor=00b3e0&style=flat", | ||
"AppVeyor Status" | ||
); | ||
var historyUrl = references.AddReference("appveyor-history", $"https://ci.appveyor.com/project/{config["account"]}/{config["build"]}/history"); | ||
var historyBadge = references.AddReference( | ||
"appveyor-history-badge", | ||
$"https://buildstats.info/appveyor/chart/{config["account"]}/{config["build"]}?includeBuildsFromPullRequest=false", | ||
"AppVeyor History" | ||
); | ||
|
||
return ($"[!{badge}]{url}", $"[!{historyBadge}]{historyUrl}"); | ||
} | ||
} | ||
} |
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,31 @@ | ||
using System.Collections.Generic; | ||
using System.Dynamic; | ||
|
||
namespace Rocket.Surgery.Nuke.Readme | ||
{ | ||
class AzurePipelinesHistory : IHistorySection | ||
{ | ||
public string Name { get; } = "Azure Pipelines"; | ||
|
||
public string ConfigKey { get; } = "azurepipelines"; | ||
|
||
public (string badge, string history) Process(IDictionary<object, object> config, IMarkdownReferences references, | ||
RocketBoosterBuild build) | ||
{ | ||
var url = references.AddReference("azurepipelines", $"https://{config["account"]}.visualstudio.com/{config["teamproject"]}/_build/latest?definitionId={config["builddefinition"]}&branchName=master"); | ||
var badge = references.AddReference( | ||
"azurepipelines-badge", | ||
$"https://img.shields.io/azure-devops/build/{config["account"]}/{config["teamproject"]}/{config["builddefinition"]}.svg?color=98C6FF&label=azure%20pipelines&logo=azuredevops&logoColor=98C6FF&style=flat", | ||
"Azure Pipelines Status" | ||
); | ||
var historyUrl = references.AddReference("azurepipelines-history", $"https://{config["account"]}.visualstudio.com/{config["teamproject"]}/_build?definitionId={config["builddefinition"]}&branchName=master"); | ||
var historyBadge = references.AddReference( | ||
"azurepipelines-history-badge", | ||
$"https://buildstats.info/azurepipelines/chart/{config["account"]}/{config["teamproject"]}/{config["builddefinition"]}?includeBuildsFromPullRequest=false", | ||
"Azure Pipelines History" | ||
); | ||
|
||
return ($"[!{badge}]{url}", $"[!{historyBadge}]{historyUrl}"); | ||
} | ||
} | ||
} |
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,55 @@ | ||
using System.Collections.Generic; | ||
using System.Dynamic; | ||
using System.Text; | ||
using Nuke.Common.Utilities.Collections; | ||
|
||
namespace Rocket.Surgery.Nuke.Readme | ||
{ | ||
/// <summary> | ||
/// A container for badges that you want to show on the readme | ||
/// </summary> | ||
public class Badges : IReadmeSection | ||
{ | ||
private readonly List<IBadgeSection> _sections = new List<IBadgeSection>(); | ||
|
||
/// <summary> | ||
/// Adds a new Badge section | ||
/// </summary> | ||
/// <param name="section"></param> | ||
/// <returns></returns> | ||
public Badges Add(IBadgeSection section) | ||
{ | ||
_sections.Add(section); | ||
return this; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public string Name => "badges"; | ||
|
||
/// <inheritdoc /> | ||
public string ConfigKey => string.Empty; | ||
|
||
/// <inheritdoc /> | ||
public string Process(IDictionary<string, object> config, IMarkdownReferences references, RocketBoosterBuild build) | ||
{ | ||
var sb = new StringBuilder(); | ||
foreach (var section in _sections) | ||
{ | ||
var subConfig = string.IsNullOrEmpty(section.ConfigKey) ? config.ToDictionary(x => (object)x.Key, x => x.Value) : config.TryGetValue(section.ConfigKey, out var o) ? o as IDictionary<object, object> : null; | ||
// Assume if not configured, it will never be able to be rendered | ||
if (subConfig is null) | ||
{ | ||
continue; | ||
} | ||
var result = section.Process(subConfig, references, build); | ||
if (string.IsNullOrWhiteSpace(result)) | ||
{ | ||
continue; | ||
} | ||
sb.AppendLine(result); | ||
} | ||
|
||
return sb.ToString(); | ||
} | ||
} | ||
} |
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,26 @@ | ||
using System.Collections.Generic; | ||
using System.Dynamic; | ||
|
||
namespace Rocket.Surgery.Nuke.Readme | ||
{ | ||
class CodacySection : IBadgeSection | ||
{ | ||
public string Name => "Codacy"; | ||
|
||
public string ConfigKey => string.Empty; | ||
|
||
public string Process(IDictionary<object, object> config, IMarkdownReferences references, RocketBoosterBuild build) | ||
{ | ||
if (!(config.TryGetValue("github", out var githubObj) && config.TryGetValue("codacy", out var codacyObj))) | ||
{ | ||
return string.Empty; | ||
} | ||
|
||
var github = (IDictionary<object, object>)githubObj; | ||
var codacy = (IDictionary<object, object>)codacyObj; | ||
var url = references.AddReference("codacy", $"https://www.codacy.com/app/{github["owner"]}/{github["repository"]}"); | ||
var badge = references.AddReference("codacy-badge", $"https://api.codacy.com/project/badge/Grade/{codacy["project"]}", "Codacy"); | ||
return $"[!{badge}]{url}"; | ||
} | ||
} | ||
} |
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,19 @@ | ||
using System.Collections.Generic; | ||
using System.Dynamic; | ||
|
||
namespace Rocket.Surgery.Nuke.Readme | ||
{ | ||
class CodecovSection : IBadgeSection | ||
{ | ||
public string Name => "Codecov"; | ||
|
||
public string ConfigKey => "github"; | ||
|
||
public string Process(IDictionary<object, object> config, IMarkdownReferences references, RocketBoosterBuild build) | ||
{ | ||
var url = references.AddReference("codecov", $"https://codecov.io/gh/{config["owner"]}/{config["repository"]}"); | ||
var badge = references.AddReference("codecov-badge", $"https://img.shields.io/codecov/c/github/{config["owner"]}/{config["repository"]}.svg?color=E03997&label=codecov&logo=codecov&logoColor=E03997&style=flat", "Code Coverage"); | ||
return $"[!{badge}]{url}"; | ||
} | ||
} | ||
} |
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,19 @@ | ||
using System.Collections.Generic; | ||
using System.Dynamic; | ||
|
||
namespace Rocket.Surgery.Nuke.Readme | ||
{ | ||
class GithubLicenseSection : IBadgeSection | ||
{ | ||
public string Name => "Github Release"; | ||
|
||
public string ConfigKey => "github"; | ||
|
||
public string Process(IDictionary<object, object> config, IMarkdownReferences references, RocketBoosterBuild build) | ||
{ | ||
var url = references.AddReference("github-license", $"https://github.com/{config["owner"]}/{config["repository"]}/blob/master/LICENSE"); | ||
var badge = references.AddReference("github-license-badge", $"https://img.shields.io/github/license/{config["owner"]}/{config["repository"]}.svg?style=flat", "License"); | ||
return $"[!{badge}]{url}"; | ||
} | ||
} | ||
} |
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,19 @@ | ||
using System.Collections.Generic; | ||
using System.Dynamic; | ||
|
||
namespace Rocket.Surgery.Nuke.Readme | ||
{ | ||
class GithubReleaseSection : IBadgeSection | ||
{ | ||
public string Name => "Github Release"; | ||
|
||
public string ConfigKey => "github"; | ||
|
||
public string Process(IDictionary<object, object> config, IMarkdownReferences references, RocketBoosterBuild build) | ||
{ | ||
var url = references.AddReference("github-release", $"https://github.com/{config["owner"]}/{config["repository"]}/releases/latest"); | ||
var badge = references.AddReference("github-release-badge", $"https://img.shields.io/github/release/{config["owner"]}/{config["repository"]}.svg?logo=github&style=flat", "Latest Release"); | ||
return $"[!{badge}]{url}"; | ||
} | ||
} | ||
} |
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,57 @@ | ||
using System.Collections.Generic; | ||
using System.Dynamic; | ||
using System.Linq; | ||
using System.Text; | ||
using JetBrains.Annotations; | ||
|
||
namespace Rocket.Surgery.Nuke.Readme | ||
{ | ||
/// <summary> | ||
/// A container for build histories that you want to show on the readme | ||
/// </summary> | ||
[PublicAPI] | ||
public class Histories : IReadmeSection | ||
{ | ||
private readonly List<IHistorySection> _sections = new List<IHistorySection>(); | ||
|
||
/// <summary> | ||
/// Adds a new history section | ||
/// </summary> | ||
/// <param name="section"></param> | ||
/// <returns></returns> | ||
public Histories Add(IHistorySection section) | ||
{ | ||
_sections.Add(section); | ||
return this; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public string Name => "history badges"; | ||
|
||
/// <inheritdoc /> | ||
public string ConfigKey => string.Empty; | ||
|
||
/// <inheritdoc /> | ||
public string Process(IDictionary<string, object> config, IMarkdownReferences references, RocketBoosterBuild build) | ||
{ | ||
var results = new List<(string name, string badge, string history)>(); | ||
foreach (var section in _sections) | ||
{ | ||
var subConfig = string.IsNullOrEmpty(section.ConfigKey) ? config.ToDictionary(x => (object)x.Key, x => x.Value) : config.TryGetValue(section.ConfigKey, out var o) ? o as IDictionary<object, object> : null; | ||
// Assume if not configured, it will never be able to be rendered | ||
if (subConfig is null) | ||
{ | ||
continue; | ||
} | ||
var (badge, history) = section.Process(subConfig, references, build); | ||
results.Add((section.Name, badge, history)); | ||
} | ||
var sb = new StringBuilder(); | ||
sb.AppendLine($"| {string.Join(" | ", results.Select(z => z.name))} |"); | ||
sb.AppendLine($"| {string.Join(" | ", results.Select(z => string.Join("", Enumerable.Range(0, z.name.Length).Select(x => "-"))))} |"); | ||
sb.AppendLine($"| {string.Join(" | ", results.Select(z => z.badge))} |"); | ||
sb.AppendLine($"| {string.Join(" | ", results.Select(z => z.history))} |"); | ||
return sb.ToString(); | ||
} | ||
} | ||
} |
Oops, something went wrong.