-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add CI github action to build and test project #5
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
Changes from all commits
0806572
e6652c4
a88d4d6
9835c3b
304053b
333a12b
b177ca4
2922a75
22fac15
8a05924
7cff968
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,34 @@ | ||||||||||||||
| # This workflow will build a .NET project | ||||||||||||||
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | ||||||||||||||
|
|
||||||||||||||
| name: .NET | ||||||||||||||
|
|
||||||||||||||
| on: | ||||||||||||||
| push: | ||||||||||||||
| branches: [ "main" ] | ||||||||||||||
| pull_request: | ||||||||||||||
| branches: [ "main" ] | ||||||||||||||
|
|
||||||||||||||
| jobs: | ||||||||||||||
| build: | ||||||||||||||
|
|
||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||
|
|
||||||||||||||
| steps: | ||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||
| - name: Setup .NET | ||||||||||||||
| uses: actions/setup-dotnet@v4 | ||||||||||||||
|
Comment on lines
+18
to
+20
|
||||||||||||||
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@3f14f4970e29fbfe43b8a0123c2f7bd0d1c7db2f # v4.0.0 |
Copilot
AI
Apr 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider enabling NuGet caching via actions/setup-dotnet (e.g., its built-in cache option) to speed up CI runs and reduce restore time on repeated builds.
| dotnet-version: 9.0.x | |
| dotnet-version: 9.0.x | |
| cache: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,46 @@ | ||
| using System; | ||
| using System.Text.RegularExpressions; | ||
| using System.Text.RegularExpressions; | ||
|
|
||
| namespace SlugGeneratorLibrary | ||
| { | ||
| public static class SlugGenerator | ||
| { | ||
| public static string Generate(string text) | ||
| public static string CustomGenerate(string text, char separator) | ||
| { | ||
| if (text is null) | ||
| throw new ArgumentNullException(nameof(text)); | ||
| text = text.Trim() | ||
| .ToLowerInvariant(); | ||
| text = Regex.Replace(text, @"[+()^*%#@!/\\.,|`~]+", string.Empty); | ||
| text = Regex.Replace(text, @"[\s_-]+", "-"); | ||
| ArgumentNullException.ThrowIfNull(text); | ||
| text = Regex.Replace(text.Trim() | ||
| .ToLowerInvariant(), | ||
| @"[+()^*%#@!/\\.,|`~]+", string.Empty); | ||
| text = Regex.Replace(text.Trim(), @"[\s_-]+", separator.ToString()); | ||
| return text; | ||
| } | ||
|
|
||
| public static string GenerateHyphens(string text) | ||
| { | ||
| return CustomGenerate(text, '-'); | ||
| } | ||
|
|
||
| public static string GenerateUnderscores(string text) | ||
| { | ||
| return CustomGenerate(text, '_'); | ||
| } | ||
|
|
||
| public static string GenerateUnique(string text) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(text); | ||
| // append text with a GUID-based suffix to greatly reduce collision risk | ||
| string uniqueText = text; | ||
| string slugifiedText = GenerateHyphens(uniqueText); | ||
| slugifiedText += '-' + Guid.NewGuid().ToString("N"); | ||
| return slugifiedText; | ||
| } | ||
| } | ||
|
|
||
| public static class StringExtensions | ||
| { | ||
| /// <summary>Convert string to slug separated by hyphens.</summary> | ||
| public static string ToSlug(this string text) | ||
| { | ||
| return SlugGenerator.GenerateHyphens(text); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow does not set explicit
permissionsforGITHUB_TOKEN. To reduce risk when running onpull_requestevents (including from forks), consider adding least-privilege permissions (e.g.,contents: read) at the workflow or job level.