-
-
Notifications
You must be signed in to change notification settings - Fork 206
43 lines (37 loc) · 1.56 KB
/
format-code.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
name: format code
on:
pull_request:
paths:
- 'src/**'
- 'test/**'
- 'samples/**'
- '.github/workflows/format-code.yml'
jobs:
format-code:
name: Format Code
# Run on 'macos' because Linux is missing the `ios` workload: https://github.com/dotnet/runtime/issues/85505
# Pin macos to get the version of XCode that we need: https://github.com/actions/runner-images/issues/10703
runs-on: macos-15
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Environment
uses: ./.github/actions/environment
- name: Restore .NET Dependencies
# We should be able to get rid of the restore here, if we install the correct workloads in actions/environment
run: |
dotnet workload restore
dotnet restore Sentry.sln --nologo
- name: Install dotnet format
run: dotnet tool install -g dotnet-format
- name: Format Code
# We're excluding `./**/*OptionsSetup.cs` from the format because the tool struggles with
# source generators
run: dotnet format Sentry.sln --no-restore --exclude ./modules --exclude ./**/*OptionsSetup.cs
# 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.
# GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs.
- name: Commit Formatted Code
run: ./scripts/commit-formatted-code.sh $GITHUB_HEAD_REF