-
-
Notifications
You must be signed in to change notification settings - Fork 96
feat: implement locale-specific build workflow #3197
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
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,52 @@ | ||
| name: .NET | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: ["main"] | ||
|
|
||
| jobs: | ||
| modularpipeline: | ||
| strategy: | ||
| matrix: | ||
| locale: [fr-FR, pl-PL, de-DE] | ||
| fail-fast: true | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup .NET 8 | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: 8.0.x | ||
|
|
||
| - name: Setup .NET 9 | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: 9.0.x | ||
|
|
||
| - name: Setup .NET 10 | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: 10.0.x | ||
|
|
||
| - name: Generate and set locale for subsequent steps | ||
| run: | | ||
| # Convert hyphen (fr-FR) to underscore (fr_FR) which is the correct locale name on Ubuntu | ||
| LOCALE=${{ matrix.locale }} | ||
| LOCALE=${LOCALE/-/_} | ||
|
|
||
| sudo apt-get update | ||
| sudo apt-get install -y locales | ||
| sudo locale-gen "${LOCALE}.UTF-8" | ||
| sudo update-locale LANG="${LOCALE}.UTF-8" | ||
|
|
||
| # Export for subsequent GitHub Actions steps | ||
| echo "LANG=${LOCALE}.UTF-8" >> $GITHUB_ENV | ||
| echo "LC_ALL=${LOCALE}.UTF-8" >> $GITHUB_ENV | ||
|
|
||
| - name: Build | ||
| run: dotnet build -c Release | ||
| working-directory: TUnit.TestProject | ||
This file contains hidden or 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 hidden or 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 hidden or 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,38 @@ | ||
| using System.Globalization; | ||
|
|
||
| namespace TUnit.Core.Helpers; | ||
|
|
||
| /// <summary> | ||
| /// Helper methods for parsing decimal values with culture fallback support | ||
| /// </summary> | ||
| public static class DecimalParsingHelper | ||
| { | ||
| /// <summary> | ||
| /// Tries to parse a decimal value from a string, first using the current culture, | ||
| /// then falling back to the invariant culture if that fails. | ||
| /// This is useful for handling decimal values in attributes that might be written | ||
| /// with different decimal separators (e.g., "123.456" vs "123,456"). | ||
| /// </summary> | ||
| public static decimal ParseDecimalWithCultureFallback(string value) | ||
| { | ||
| // First, try parsing with the current culture | ||
| if (decimal.TryParse(value, NumberStyles.Any, CultureInfo.CurrentCulture, out var result)) | ||
| { | ||
| return result; | ||
| } | ||
|
|
||
| // If that fails, try with the invariant culture | ||
| if (decimal.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result)) | ||
| { | ||
| return result; | ||
| } | ||
|
|
||
| // If both fail, throw an exception with helpful details | ||
| throw new FormatException( | ||
| $"Could not parse '{value}' as a decimal value. " + | ||
| $"Tried both CurrentCulture ({CultureInfo.CurrentCulture.Name}) " + | ||
| $"and InvariantCulture. " + | ||
| $"Valid decimal formats include: 123.456 (invariant) or locale-specific format." | ||
| ); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI about 2 months ago
To fix the problem and follow least-privilege guidelines, explicitly set the minimal permissions for the workflow or the
modularpipelinejob. Since there is only one job, and it does not need write permissions, settingeither at the workflow root (applies to all jobs), or within the job (applies just to that job) will resolve the issue and satisfy CodeQL. For clarity and maintainability, put this at the root, after
name: .NET, so it applies globally and is easily discoverable by future maintainers. No other changes required.