Disable clang-format, clean up scripts

This commit is contained in:
rubenwardy 2021-01-23 23:48:22 +00:00 committed by sfan5
parent b390bd2ea5
commit ccdaf5de54
3 changed files with 42 additions and 15 deletions

@ -24,20 +24,21 @@ on:
- '.github/workflows/**.yml' - '.github/workflows/**.yml'
jobs: jobs:
clang_format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Install clang-format
run: |
sudo apt-get install clang-format-9 -qyy
- name: Run clang-format # clang_format:
run: | # runs-on: ubuntu-18.04
source ./util/ci/lint.sh # steps:
perform_lint # - uses: actions/checkout@v2
env: # - name: Install clang-format
CLANG_FORMAT: clang-format-9 # run: |
# sudo apt-get install clang-format-9 -qyy
#
# - name: Run clang-format
# run: |
# source ./util/ci/clang-format.sh
# check_format
# env:
# CLANG_FORMAT: clang-format-9
clang_tidy: clang_tidy:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04

@ -1,6 +1,6 @@
#! /bin/bash #! /bin/bash
function perform_lint() {
echo "Performing LINT..." function setup_for_format() {
if [ -z "${CLANG_FORMAT}" ]; then if [ -z "${CLANG_FORMAT}" ]; then
CLANG_FORMAT=clang-format CLANG_FORMAT=clang-format
fi fi
@ -8,6 +8,12 @@ function perform_lint() {
CLANG_FORMAT_WHITELIST="util/ci/clang-format-whitelist.txt" CLANG_FORMAT_WHITELIST="util/ci/clang-format-whitelist.txt"
files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')" files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')"
}
function check_format() {
echo "Checking format..."
setup_for_format
local errorcount=0 local errorcount=0
local fail=0 local fail=0
@ -41,3 +47,18 @@ function perform_lint() {
echo "LINT OK" echo "LINT OK"
} }
function fix_format() {
echo "Fixing format..."
setup_for_format
for f in ${files_to_lint}; do
whitelisted=$(awk '$1 == "'$f'" { print 1 }' "$CLANG_FORMAT_WHITELIST")
if [ -z "${whitelisted}" ]; then
echo "$f"
$CLANG_FORMAT -i "$f"
fi
done
}

5
util/fix_format.sh Executable file

@ -0,0 +1,5 @@
#!/bin/bash -e
. ./util/ci/clang-format.sh
fix_format