Skip to content

Commit fcf9232

Browse files
committed
ci: install clang-format from apt llvm
It's easy to upgrade clang-format with one parameter, most of C++ developers use Unix box, so we should use the Unix for style check.
1 parent cfa7f01 commit fcf9232

File tree

2 files changed

+13
-23
lines changed

2 files changed

+13
-23
lines changed

.github/workflows/commit-ci.yml

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,15 @@ on:
1111

1212
jobs:
1313
lint:
14-
runs-on: windows-latest
14+
runs-on: ubuntu-latest
1515
steps:
1616
- name: Checkout last commit
1717
uses: actions/checkout@v4
18-
- name: Install clang-format@18
19-
shell: pwsh
18+
19+
- name: Install clang-format-18
2020
run: |
21-
$version = ""
22-
if (Get-Command "clang-format" -ErrorAction SilentlyContinue){
23-
$version = clang-format --version
24-
$pat = ".*\s+(\d+\.\d+\.\d+)"
25-
if ($version -match $pat) {
26-
$version = $matches[1]
27-
}
28-
}
29-
if ($version -ne "") {
30-
Write-Host "clang-format version:$version"
31-
if ([version]$version -eq [version]"18.1.8") {
32-
Write-Host "clang-format OK"
33-
} else {
34-
Write-Host "clang-format version does not meet"
35-
choco install llvm --version=18.1.8 --force
36-
}
37-
} else {
38-
Write-Host "clang-format not installed"
39-
choco install llvm --version=18.1.8
40-
}
21+
./action-install-clang-format.sh 18
22+
4123
- name: Code style lint
4224
run: make clang-format-lint
4325

action-install-clang-format.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
# https://apt.llvm.org/
4+
sudo apt install -y wget
5+
wget https://apt.llvm.org/llvm.sh
6+
chmod +x llvm.sh
7+
sudo ./llvm.sh $1
8+
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-$1 100

0 commit comments

Comments
 (0)