mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-18 00:27:02 +08:00
ci: use Docker instead of directly installing clang-format
This commit is contained in:
22
.github/workflows/format-check.yml
vendored
22
.github/workflows/format-check.yml
vendored
@@ -2,26 +2,14 @@
|
|||||||
# .github/workflows/format-check.yml
|
# .github/workflows/format-check.yml
|
||||||
name: Code Format Check
|
name: Code Format Check
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
push:
|
|
||||||
branches: [ "main", "master" ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ "main", "master" ]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
clang-format:
|
formatting:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container: silkeh/clang:21 # 修改为存在的版本
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
- name: Run clang-format
|
||||||
- name: Install clang-format
|
|
||||||
run: |
|
run: |
|
||||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
find src -name '*.cpp' -o -name '*.h' -print0 | xargs -0 clang-format --dry-run --Werror
|
||||||
sudo add-apt-repository "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-18 main"
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y clang-format-18
|
|
||||||
sudo ln -sf /usr/bin/clang-format-18 /usr/bin/clang-format
|
|
||||||
|
|
||||||
- name: Check C++ code formatting
|
|
||||||
run: |
|
|
||||||
find src include -name "*.cpp" -o -name "*.hpp" | xargs clang-format --dry-run --Werror
|
|
||||||
Reference in New Issue
Block a user