Files
dependabot[bot] 244f30c8b9 Bump actions/cache from 5 to 6 (#6786)
Bumps [actions/cache](https://github.com/actions/cache) from 5 to 6.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-25 10:18:33 +08:00

102 lines
3.8 KiB
YAML

name: code-format
on: [push, pull_request]
concurrency:
group: code-format-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
code-format:
runs-on: ubuntu-latest
container: ubuntu:20.04
steps:
- name: astyle
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get update -y
apt-get install -y astyle git
- uses: actions/checkout@v7
- name: cache-clang-format
id: cache-clang-format
uses: actions/cache@v6
with:
path: clang-format-install
key: clang-format-install-5
- name: clang-format
if: steps.cache-clang-format.outputs.cache-hit != 'true'
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get update -y
apt-get install -y build-essential wget curl cmake unzip zip python3-pip
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/llvm-project-10.0.1.tar.xz
tar -xf llvm-project-10.0.1.tar.xz
cd llvm-project-10.0.1
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_TARGETS_TO_BUILD="" -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_DOCS=OFF ../llvm/
make -j4 clang-format
mkdir $GITHUB_WORKSPACE/clang-format-install
cp -r bin/clang-format $GITHUB_WORKSPACE/clang-format-install
cd ../../
rm -rf llvm-project-10.0.1
rm llvm-project-10.0.1.tar.xz
- name: cache-clang-format-21
id: cache-clang-format-21
uses: actions/cache@v6
with:
path: clang-format-21-install
key: clang-format-21-install
- name: clang-format-21
if: steps.cache-clang-format-21.outputs.cache-hit != 'true'
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get update -y
apt-get install -y build-essential wget curl cmake unzip zip python3-pip
pip install cmake
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.8/llvm-project-21.1.8.src.tar.xz
tar -xf llvm-project-21.1.8.src.tar.xz
cd llvm-project-21.1.8.src
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_TARGETS_TO_BUILD="" -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_DOCS=OFF ../llvm/
make -j4 clang-format
mkdir $GITHUB_WORKSPACE/clang-format-21-install
cp -r bin/clang-format $GITHUB_WORKSPACE/clang-format-21-install
cd ../../
rm -rf llvm-project-21.1.8.src
rm llvm-project-21.1.8.src.tar.xz
- name: code-format
run: |
mv $GITHUB_WORKSPACE/clang-format-install/clang-format /usr/local/bin/clang-format
rm -rf $GITHUB_WORKSPACE/clang-format-install
sh codeformat.sh
- name: code-format-glsl
run: |
mv $GITHUB_WORKSPACE/clang-format-21-install/clang-format /usr/local/bin/clang-format-21
rm -rf $GITHUB_WORKSPACE/clang-format-21-install
cd src/layer/vulkan/shader
find . -type f -name '*.comp' | xargs -i clang-format-21 -i -assume-filename=main.cpp {}
- name: configure-git-safe-directory
run: git config --global --add safe.directory /__w/ncnn/ncnn
- uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: apply code-format changes
- name: restore-clang-format-cache
run: |
mkdir $GITHUB_WORKSPACE/clang-format-install
cp -r /usr/local/bin/clang-format $GITHUB_WORKSPACE/clang-format-install
mkdir $GITHUB_WORKSPACE/clang-format-21-install
cp -r /usr/local/bin/clang-format-21 $GITHUB_WORKSPACE/clang-format-21-install/clang-format