-
Notifications
You must be signed in to change notification settings - Fork 35
47 lines (39 loc) · 1.39 KB
/
clang-format.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: Clang-Format Workflow
on:
push:
branches: '**'
pull_request:
env:
LLVM_VERSION: 15
jobs:
format:
name: Check the formatting
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Pin to a specific version
run: |
$latestChocoVersion = (Get-LatestChocoPackageVersion -TargetVersion $env:LLVM_VERSION -PackageName "llvm")
Choco-Install -PackageName llvm -ArgumentList '--allow-downgrade', '--version', $latestChocoVersion
- name: Run clang-format
env:
RED4EXT_COMMIT_BEFORE: ${{ github.event.pull_request.base.sha || github.event.before }}
RED4EXT_COMMIT_AFTER: ${{ github.sha }}
run: |
$output = (git `
-c core.autocrlf=false `
-c core.eol=lf `
-c color.ui=always `
clang-format `
--style file `
--diff $env:RED4EXT_COMMIT_BEFORE $env:RED4EXT_COMMIT_AFTER
)?.Trim()
Write-Output $output
# A temporary fix for https://github.com/llvm/llvm-project/issues/56736.
# TODO: Once LLVM 16 is released, reduce this to only the "git ... clang-format ..." command.
if ($LASTEXITCODE -eq 1 -and !$output) {
exit 0
}