|
11 | 11 | name: 'Check Formatting of Changes' |
12 | 12 | runs-on: windows-latest |
13 | 13 | steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + |
14 | 16 | - name: Check Formatting |
15 | 17 | run: | |
16 | | - cmd /c "powershell .\.github\Workflows\CheckClangFormatting.ps1" |
| 18 | + $VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat |
| 19 | + if (!$VSDevCmd) { exit 1 } |
| 20 | + Write-Host "Using VSDevCmd: ${VSDevCmd}" |
| 21 | + & $VSDevCmd; |
| 22 | +
|
| 23 | + & .\find_clang_format.cmd |
| 24 | + if ($LASTEXITCODE -ne 0) { |
| 25 | + exit $LASTEXITCODE |
| 26 | + } |
| 27 | +
|
| 28 | + & git clang-format origin/master --binary "$env:CLANG_FORMAT" --style file -- cppwinrt/*.h cppwinrt/*.cpp fast_fwd/*.h fast_fwd/*.cpp prebuild/*.h prebuild/*.cpp scratch/*.h scratch/*.cpp strings/*.h strings/*.cpp test/*.h test/*.cpp vsix/*.h vsix/*.cpp |
| 29 | +
|
| 30 | + if ($LASTEXITCODE -ne 0) { |
| 31 | + Write-Host ::error ERROR: This branch contains changes that have not been formatted with `'clang-format`' |
| 32 | + Write-Host NOTE: To resolve this issue, you can run `'clang-format`' in the following ways: |
| 33 | + Write-Host * Run ``build_test_all.cmd`` which will run `'clang-format`' on _all_ source files. This script is |
| 34 | + Write-Host simpler to run, however there`'s a chance it may touch additional files you never changed due to you having |
| 35 | + Write-Host a mis-matched version of `'clang-format`'. This may require you to manually revert changes made by |
| 36 | + Write-Host `'clang-format`' to the locations where you made no code changes. |
| 37 | + Write-Host |
| 38 | + Write-Host For more information, please see https://github.com/microsoft/cppwinrt?tab=readme-ov-file#formatting |
| 39 | + Write-Host |
| 40 | + Write-Host NOTE: As an additional note, given that different versions of `'clang-format`' may have different behaviors, this |
| 41 | + Write-Host may be a false positive. If you believe that to be the case ^`(e.g. none of the above resulted in modifications |
| 42 | + Write-Host to the code you have changed^`), please note this in your PR. |
| 43 | + exit 1 |
| 44 | + } |
17 | 45 |
|
18 | 46 | test-msvc-cppwinrt-build: |
19 | 47 | name: '${{ matrix.compiler }}: Build (${{ matrix.arch }}, ${{ matrix.config }})' |
|
0 commit comments