mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-04 11:55:51 +00:00
61 lines
2.3 KiB
YAML
61 lines
2.3 KiB
YAML
name: clang-format
|
|
|
|
on: [push, pull_request]
|
|
|
|
jobs:
|
|
check:
|
|
runs-on: ubuntu-18.04
|
|
env:
|
|
CLANG_VERSION: 10
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Install clang-format
|
|
run: |
|
|
sudo tee /etc/apt/sources.list.d/llvm.list >/dev/null <<EOF
|
|
deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-${CLANG_VERSION} main
|
|
deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-${CLANG_VERSION} main
|
|
EOF
|
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add
|
|
sudo apt-get update
|
|
sudo apt-get install clang-format-${CLANG_VERSION}
|
|
- name: Format src
|
|
run: find src -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -print0 | xargs -0 clang-format-${CLANG_VERSION} -i
|
|
- name: Format unittests
|
|
run: find unittests -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -print0 | xargs -0 clang-format-${CLANG_VERSION} -i
|
|
- name: Check for differences
|
|
id: assert
|
|
run: |
|
|
set -o pipefail
|
|
git diff --exit-code | tee "clang-format.patch"
|
|
- name: Upload patch
|
|
if: failure() && steps.assert.outcome == 'failure'
|
|
uses: actions/upload-artifact@v2
|
|
continue-on-error: true
|
|
with:
|
|
name: clang-format.patch
|
|
if-no-files-found: ignore
|
|
path: clang-format.patch
|
|
- name: What happened?
|
|
if: failure() && steps.assert.outcome == 'failure'
|
|
env:
|
|
PREAMBLE: |
|
|
If you are reading this, you are looking at a failed Github Actions
|
|
job. That means you pushed one or more files that did not conform
|
|
to the formatting specified in .clang-format. That may be because
|
|
you neglected to run 'git clang-format' or 'clang-format' before
|
|
committing, or that your version of clang-format has an
|
|
incompatibility with the one on this
|
|
machine, which is:
|
|
SUGGESTION: |
|
|
|
|
To fix it, you can do one of two things:
|
|
1. Download and apply the patch generated as an artifact of this
|
|
job to your repo, commit, and push.
|
|
2. Run 'git-clang-format --extensions c,cpp,h,cxx,ipp develop'
|
|
in your repo, commit, and push.
|
|
run: |
|
|
echo "${PREAMBLE}"
|
|
clang-format-${CLANG_VERSION} --version
|
|
echo "${SUGGESTION}"
|
|
exit 1
|