From a4641ff9bcc5c6224982fddc6e2f28d798185bac Mon Sep 17 00:00:00 2001 From: Nikhil B <59918974+heftymouse@users.noreply.github.com> Date: Mon, 3 Apr 2023 21:09:00 +0530 Subject: [PATCH] Feature: Add Xaml Styler GitHub Action (#11379) --- .github/workflows/check-xaml-formatting.yml | 49 +++++++++++++++++++++ nuget.config | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check-xaml-formatting.yml diff --git a/.github/workflows/check-xaml-formatting.yml b/.github/workflows/check-xaml-formatting.yml new file mode 100644 index 000000000000..6f42a343b8bb --- /dev/null +++ b/.github/workflows/check-xaml-formatting.yml @@ -0,0 +1,49 @@ +name: Check XAML Formatting +on: + workflow_dispatch: + push: + branches: + - 'main' + - '**-servicing' + paths: + - '**.xaml' + pull_request: + branches: + - 'main' + - '**-servicing' + paths: + - '**.xaml' + +jobs: + check-formatting: + runs-on: ubuntu-latest + defaults: + run: + shell: pwsh + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: Install Xaml Styler + run: | + dotnet tool install --global XamlStyler.Console + + - name: Check Formatting + id: check-step + run: | + $changedFiles = (git diff --name-only HEAD~1) -split "\n" | Where-Object {$_ -like "*.xaml"} + foreach ($file in $changedFiles) + { + xstyler -p -l None -f $file + if ($LASTEXITCODE -ne 0) + { + echo "::error file=$file::Format check failed" + } + } + continue-on-error: true + + - name: Fail job if necessary + if: steps.check-step.outcome == 'failure' + run: exit 1 + diff --git a/nuget.config b/nuget.config index bc2029e52f36..08506035a9a6 100644 --- a/nuget.config +++ b/nuget.config @@ -2,6 +2,6 @@ - + \ No newline at end of file