Files
rocm-systems/.github/workflows/formatting.yml
T
Jonathan R. Madsen 6c93674f92 cmake-format + miscellaneous tweaks (#13)
* cmake-format + miscellaneous tweaks
* Formatted cmake in examples and tests
* Updated linux-ci.yml artifacts naming
* Updated clang-format
* Fixed submodule branches
2021-09-20 11:12:06 -05:00

63 行
2.2 KiB
YAML

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: formatting
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
cmake-format:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3-pip
python3 -m pip install cmake-format
- name: cmake-format
run: |
set +e
cmake-format -i $(find . -type f | egrep 'CMakeLists.txt|\.cmake$')
if [ $(git diff | wc -l) -gt 0 ]; then
echo -e "\nError! CMake code not formatted. Run cmake-format...\n"
echo -e "\nFiles:\n"
git diff --name-only
echo -e "\nFull diff:\n"
git diff
exit 1
fi
clang-format:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
DISTRIB_CODENAME=$(cat /etc/lsb-release | grep DISTRIB_CODENAME | awk -F '=' '{print $NF}')
sudo apt-get update
sudo apt-get install -y software-properties-common wget curl
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
echo "deb http://apt.llvm.org/${DISTRIB_CODENAME}/ llvm-toolchain-${DISTRIB_CODENAME}-11 main" | sudo tee -a /etc/apt/sources.list.d/llvm-toolchain.list
echo "deb-src http://apt.llvm.org/${DISTRIB_CODENAME}/ llvm-toolchain-${DISTRIB_CODENAME}-11 main" | sudo tee -a /etc/apt/sources.list.d/llvm-toolchain.list
sudo apt-get update
sudo apt-get install -y clang-format-11
- name: clang-format
run: |
set +e
FILES=$(find include src examples -type f | egrep '\.hpp$|\.cpp$|\.cpp\.in$')
FORMAT_OUT=$(clang-format-11 -output-replacements-xml ${FILES})
RET=$(echo ${FORMAT_OUT} | grep -c '<replacement ')
if [ "${RET}" -ne 0 ]; then
echo -e "\nError! Code not formatted. Detected ${RET} lines\n"
clang-format-11 -i ${FILES}
git diff
exit ${RET}
fi