Skip to content

Commit c6a5a23

Browse files
committed
It helps if the repo is checked out before referencing scripts in it
1 parent 3e70b40 commit c6a5a23

File tree

2 files changed

+29
-33
lines changed

2 files changed

+29
-33
lines changed

.github/workflows/CheckClangFormatting.ps1

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,37 @@ jobs:
1111
name: 'Check Formatting of Changes'
1212
runs-on: windows-latest
1313
steps:
14+
- uses: actions/checkout@v4
15+
1416
- name: Check Formatting
1517
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+
}
1745
1846
test-msvc-cppwinrt-build:
1947
name: '${{ matrix.compiler }}: Build (${{ matrix.arch }}, ${{ matrix.config }})'

0 commit comments

Comments
 (0)