Skip to content

Commit

Permalink
chore: Add verify code styles workflow. (#10450)
Browse files Browse the repository at this point in the history
* chore: add lint check workflow

* chore: remove writing PR comments

* chore: modify code formatting (`dotnet format` cause diffs on ubuntu env)
  • Loading branch information
filzrev authored Dec 14, 2024
1 parent fba6416 commit 233ffb8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: lint

on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
workflow_dispatch:

jobs:
build:
name: Lint
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
9.x
- name: Run `dotnet format` command
run: |
dotnet restore
dotnet format --no-restore --verify-no-changes
- name: Report failures as Job Summary
if: ${{ failure() }}
shell: pwsh
run: |
$content = '
## Failed to run the `lint.yml` workflow
To fix workflow errors. Please follow the steps below.
1. Run `dotnet format` command.
2. Commit changes as separated commit.
3. Push changes to source branch of PR.
'
Write-Output $content >> $env:GITHUB_STEP_SUMMARY
7 changes: 3 additions & 4 deletions src/Docfx.Build.RestApi/ValidateRestApiDocumentMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ public override void Build(FileModel model, IHostService host)
case DocumentType.Overwrite:
foreach (var item in (List<OverwriteDocumentModel>)model.Content)
{
host.ValidateInputMetadata(
model.OriginalFileAndType.File,
// use RestApiChildItemViewModel because it contains all properties for REST.
item.ConvertTo<RestApiChildItemViewModel>().Metadata.ToImmutableDictionary());
// use RestApiChildItemViewModel because it contains all properties for REST
var metadata = item.ConvertTo<RestApiChildItemViewModel>().Metadata.ToImmutableDictionary();
host.ValidateInputMetadata(model.OriginalFileAndType.File, metadata);
}
break;
default:
Expand Down

0 comments on commit 233ffb8

Please sign in to comment.