Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Disable clang-format, clean up scripts
  • Loading branch information
rubenwardy authored and sfan5 committed Mar 1, 2021
1 parent b390bd2 commit ccdaf5d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 15 deletions.
27 changes: 14 additions & 13 deletions .github/workflows/cpp_lint.yml
Expand Up @@ -24,20 +24,21 @@ on:
- '.github/workflows/**.yml'

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
run: |
source ./util/ci/lint.sh
perform_lint
env:
CLANG_FORMAT: clang-format-9
# 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
# run: |
# source ./util/ci/clang-format.sh
# check_format
# env:
# CLANG_FORMAT: clang-format-9

clang_tidy:
runs-on: ubuntu-18.04
Expand Down
25 changes: 23 additions & 2 deletions util/ci/lint.sh → util/ci/clang-format.sh
@@ -1,13 +1,19 @@
#! /bin/bash
function perform_lint() {
echo "Performing LINT..."

function setup_for_format() {
if [ -z "${CLANG_FORMAT}" ]; then
CLANG_FORMAT=clang-format
fi
echo "LINT: Using binary $CLANG_FORMAT"
CLANG_FORMAT_WHITELIST="util/ci/clang-format-whitelist.txt"

files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')"
}

function check_format() {
echo "Checking format..."

setup_for_format

local errorcount=0
local fail=0
Expand Down Expand Up @@ -41,3 +47,18 @@ function perform_lint() {
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 changes: 5 additions & 0 deletions util/fix_format.sh
@@ -0,0 +1,5 @@
#!/bin/bash -e

. ./util/ci/clang-format.sh

fix_format

0 comments on commit ccdaf5d

Please sign in to comment.