ci: move from dotnet-format tool to .NET SDK command#4918
ci: move from dotnet-format tool to .NET SDK command#4918jamescrosswell merged 14 commits intomainfrom
Conversation
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Features ✨
Fixes 🐛
Dependencies ⬆️Deps
Other
🤖 This preview updates automatically when you update the PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4918 +/- ##
==========================================
+ Coverage 73.86% 73.90% +0.03%
==========================================
Files 496 496
Lines 17951 17951
Branches 3516 3516
==========================================
+ Hits 13259 13266 +7
+ Misses 3833 3824 -9
- Partials 859 861 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The exclusion was added as a workaround because dotnet-format was incorrectly deleting assertions in that file. This issue has since been resolved so the exclusion is no longer necessary. Co-Authored-By: Claude <noreply@anthropic.com>
This reverts commit bba983f.
This reverts commit bbcefcb.
Generate a dotnet format report via --report and upload it as a CI artifact so formatting issues can be inspected without re-running the job locally. Refs #4918 Co-Authored-By: Claude <noreply@anthropic.com>
Refs #4918 Co-Authored-By: Claude <noreply@anthropic.com>
Refs #4918 Co-Authored-By: Claude <noreply@anthropic.com>
Write a .gitignore into the report directory after uploading the artifact so the generated JSON report is not picked up as a git change by the subsequent commit step. Refs #4918 Co-Authored-By: Claude <noreply@anthropic.com>
Avoid unconditionally creating the report directory — only write the .gitignore when dotnet format actually produced the directory. Refs #4918 Co-Authored-By: Claude <noreply@anthropic.com>
| - name: Upload Format Report | ||
| if: ${{ always() }} | ||
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | ||
| with: | ||
| archive: false | ||
| path: ./dotnet-format-report/ | ||
| if-no-files-found: ignore | ||
|
|
There was a problem hiding this comment.
note: see e.g. https://github.com/getsentry/sentry-dotnet/actions/runs/22679547094?pr=4918
I do like the unzipped upload for single files, so that in this case I can view the .json file directly in the browser.
| - name: Exclude Format Report from Git | ||
| run: | | ||
| if [ -d ./dotnet-format-report ]; then | ||
| echo '*' > ./dotnet-format-report/.gitignore | ||
| fi | ||
|
|
There was a problem hiding this comment.
note: so that the Commit Formatted Code step does not consider the generated report as a change
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Upload failure blocks formatted code commit step
- Added
continue-on-error: trueto theUpload Format Reportstep so artifact upload failures no longer block subsequent git exclusion and commit steps.
- Added
Or push these changes by commenting:
@cursor push ba42615ad8
Preview (ba42615ad8)
diff --git a/.github/workflows/format-code.yml b/.github/workflows/format-code.yml
--- a/.github/workflows/format-code.yml
+++ b/.github/workflows/format-code.yml
@@ -39,6 +39,7 @@
- name: Upload Format Report
if: ${{ always() }}
+ continue-on-error: true
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
archive: false| with: | ||
| archive: false | ||
| path: ./dotnet-format-report/ | ||
| if-no-files-found: ignore |
There was a problem hiding this comment.
Upload failure blocks formatted code commit step
Medium Severity
The Upload Format Report step uses if: always() but lacks continue-on-error: true. If this step fails (e.g., network issue, or archive: false rejecting multiple files from the report directory), the GitHub Actions success() check becomes false, preventing both Exclude Format Report from Git and Commit Formatted Code from running. This silently discards any formatting changes that dotnet format applied. Adding continue-on-error: true to the upload step would prevent an informational artifact upload from blocking the core commit functionality.
Additional Locations (1)
There was a problem hiding this comment.
my intention was that CI should fail if anything goes unexpected ... starting out more aggressive ... we can always loosen strictness later



Summary
dotnet-formatglobal tool as it is now included in the .NET SDK--report, similar to build logs and test results--excludeOptions into a single space-separated listRemarks
dotnet-format has been marked deprecated on NuGet.org.
It is included as a CLI command since the the .NET 6.0 SDK.
dotnet format supports a
--reportoption, that this changeset is uploading as a non-zipped artifact (see #4966).Unfortunately, this does not fix the automatic removal of an Assertion (see #4911).
--exclude ./test/Sentry.Tests/AttributeReaderTests.csis still required ... this may be a bug in a Diagnostic-Analyzer ifxUnit.netand it's associated Code-Fix-Provider.This PR also merges all three
--excludeoptions in to a single space-separated list ... see dotnet format.