Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions .github/workflows/format-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,28 @@ jobs:
dotnet workload restore
dotnet restore Sentry.slnx --nologo

- name: Install dotnet format
run: dotnet tool install -g dotnet-format

- name: Format Code
# We exclude `./**/*OptionsSetup.cs` from the format because the tool struggles with
# source generators.
#
# We exclude `test/Sentry.Tests/AttributeReaderTests.cs` because dotnet-format tries to
# delete assertions in there.
# - see https://github.com/getsentry/sentry-dotnet/pull/4911#discussion_r2795717887
run: dotnet format Sentry.slnx --no-restore --exclude ./modules --exclude ./**/*OptionsSetup.cs --exclude ./test/Sentry.Tests/AttributeReaderTests.cs
run: dotnet format Sentry.slnx --no-restore --report ./dotnet-format-report --exclude ./modules ./**/*OptionsSetup.cs ./test/Sentry.Tests/AttributeReaderTests.cs

- 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my intention was that CI should fail if anything goes unexpected ... starting out more aggressive ... we can always loosen strictness later


Comment on lines +40 to +47
Copy link
Copy Markdown
Member Author

@Flash0ver Flash0ver Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +48 to 53
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: so that the Commit Formatted Code step does not consider the generated report as a change

# actions/checkout fetches only a single commit in a detached HEAD state. Therefore
# we need to pass the current branch, otherwise we can't commit the changes.
Expand Down
Loading