Skip to content

Commit 233ffb8

Browse files
authored
chore: Add verify code styles workflow. (#10450)
* chore: add lint check workflow * chore: remove writing PR comments * chore: modify code formatting (`dotnet format` cause diffs on ubuntu env)
1 parent fba6416 commit 233ffb8

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

.github/workflows/lint.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: lint
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- ready_for_review
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
name: Lint
15+
runs-on: ubuntu-latest
16+
if: github.event.pull_request.draft == false
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup .NET SDK
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
dotnet-version: |
25+
9.x
26+
27+
- name: Run `dotnet format` command
28+
run: |
29+
dotnet restore
30+
dotnet format --no-restore --verify-no-changes
31+
32+
- name: Report failures as Job Summary
33+
if: ${{ failure() }}
34+
shell: pwsh
35+
run: |
36+
$content = '
37+
## Failed to run the `lint.yml` workflow
38+
To fix workflow errors. Please follow the steps below.
39+
1. Run `dotnet format` command.
40+
2. Commit changes as separated commit.
41+
3. Push changes to source branch of PR.
42+
'
43+
Write-Output $content >> $env:GITHUB_STEP_SUMMARY

src/Docfx.Build.RestApi/ValidateRestApiDocumentMetadata.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ public override void Build(FileModel model, IHostService host)
2929
case DocumentType.Overwrite:
3030
foreach (var item in (List<OverwriteDocumentModel>)model.Content)
3131
{
32-
host.ValidateInputMetadata(
33-
model.OriginalFileAndType.File,
34-
// use RestApiChildItemViewModel because it contains all properties for REST.
35-
item.ConvertTo<RestApiChildItemViewModel>().Metadata.ToImmutableDictionary());
32+
// use RestApiChildItemViewModel because it contains all properties for REST
33+
var metadata = item.ConvertTo<RestApiChildItemViewModel>().Metadata.ToImmutableDictionary();
34+
host.ValidateInputMetadata(model.OriginalFileAndType.File, metadata);
3635
}
3736
break;
3837
default:

0 commit comments

Comments
 (0)