-
Notifications
You must be signed in to change notification settings - Fork 1
ci: Format code Workflow (MAPCO-6656) #9
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
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1ae4dee
Formate code on save
baruchInsert-tech ad91722
Add format ci job
baruchInsert-tech 4565ceb
rename file path
baruchInsert-tech b46bff5
Add formate test script
baruchInsert-tech e648254
Fail process if format check fails
baruchInsert-tech 79f608f
Fix format job
baruchInsert-tech 5f6e576
Fix indentation issue
baruchInsert-tech 9adbe5f
Print fail reason
baruchInsert-tech c1fb274
print files
baruchInsert-tech baa2308
Print files to console
baruchInsert-tech b895d46
Fix manully
baruchInsert-tech 3714f3e
Change to format only
baruchInsert-tech 3e716c1
Only format
baruchInsert-tech 837566e
Fix action name
baruchInsert-tech fee8f60
Exclude idea files
baruchInsert-tech 77dd4c2
Remove sln and cproj
baruchInsert-tech 21d0394
Remove test script
baruchInsert-tech d53ca4e
Remove needs
baruchInsert-tech 074a722
Add Code styles
baruchInsert-tech 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,81 @@ | ||
| name: Format | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| format_check: | ||
| name: Verify Rider formatting | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: '8.0.x' | ||
|
|
||
| - name: Install JetBrains ReSharper Global Tools (jb) | ||
| run: | | ||
| dotnet tool install --global JetBrains.ReSharper.GlobalTools | ||
| echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH" | ||
|
|
||
| - name: Run Rider cleanup (dry-check via diff) | ||
| run: | | ||
| jb cleanupcode \ | ||
| --profile="Built-in: Reformat Code" \ | ||
| --no-build \ | ||
| --verbosity=WARN \ | ||
| --include="**/*.cs" \ | ||
| --exclude="**/bin/**" \ | ||
| --exclude="**/obj/**" \ | ||
| --exclude="**/.idea/**" \ | ||
| . | ||
|
|
||
| - name: Detect formatting changes (code files only) | ||
| id: diff | ||
| run: | | ||
| LIST_FILE="$RUNNER_TEMP/files_needing_format.txt" | ||
| CHANGED="$(git status --porcelain --untracked-files=no -- '*.cs' '*.csproj' '*.sln' | awk '{print $2}' | sort -u)" | ||
| if [[ -n "$CHANGED" ]]; then | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
| echo "$CHANGED" | tee "$LIST_FILE" | ||
| echo "list_file=$LIST_FILE" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "changed=false" >> "$GITHUB_OUTPUT" | ||
| echo "list_file=" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Summarize unformatted files | ||
| if: steps.diff.outputs.changed == 'true' | ||
| run: | | ||
| { | ||
| echo "### ❌ Formatting check failed" | ||
| echo | ||
| echo "The following code files are not formatted properly:" | ||
| echo | ||
| echo '```' | ||
| cat "${{ steps.diff.outputs.list_file }}" | ||
| echo '```' | ||
| echo | ||
| echo "➡️ Run Rider **Code Cleanup** (Built-in: *Reformat Code*) locally and commit." | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| - name: Annotate files in Checks UI | ||
| if: steps.diff.outputs.changed == 'true' | ||
| run: | | ||
| while IFS= read -r f; do | ||
| echo "::error file=$f,title=Not formatted::Run Rider Code Cleanup (Built-in: Reformat Code) and commit." | ||
| done < "${{ steps.diff.outputs.list_file }}" | ||
|
|
||
| - name: Revert any changes (always clean workspace) | ||
| if: always() | ||
| run: | | ||
| git restore --staged . | ||
| git checkout -- . | ||
| git clean -fd | ||
|
|
||
| - name: Fail job if formatting needed | ||
| if: steps.diff.outputs.changed == 'true' | ||
| run: exit 1 |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.