Skip to content

Commit

Permalink
Add color diff and diff to output. Remove check std:: options all tog…
Browse files Browse the repository at this point in the history
…ether
  • Loading branch information
coleaeason committed Apr 24, 2020
1 parent 52ea66f commit 751824b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ COPY entrypoint.sh /entrypoint.sh
COPY default.cfg /default.cfg

RUN apt-get update
RUN apt-get -y install curl cmake build-essential python3 git
RUN apt-get -y install curl cmake build-essential python3 git colordiff
RUN chmod +x entrypoint.sh
RUN curl -L -o uncrustify-0.70.1.tar.gz https://github.com/uncrustify/uncrustify/archive/uncrustify-0.70.1.tar.gz
RUN tar -xzf uncrustify-0.70.1.tar.gz
Expand Down
17 changes: 0 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,4 @@ jobs:
uses: coleaeason/actions-uncrustify@v1
with:
configPath: 'myConfig.cfg'
```
Checks for usaged of `std::`:
```yml
on: [ pull_request ]
jobs:
cpp_style_check:
runs-on: ubuntu-latest
name: Check C++ Style
steps:
- name: Checkout this commit
uses: actions/checkout@v2
- name: Run style checks
uses: coleaeason/actions-uncrustify@v1
with:
checkSTD: 'true'
```
3 changes: 0 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ inputs:
configPath:
description: 'Alternate configuration file to use'
required: false
checkSTD:
description: 'Whether or not files should be checked for std:: usage'
required: false
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
13 changes: 2 additions & 11 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fi
EXIT_VAL=0

while read -r FILENAME; do
FAILED="false"
TMPFILE="${FILENAME}.tmp"
# Failure is passed to stderr so we need to redirect that to grep so we can pretty print some useful output instead of the deafult
# Success is passed to stdout, so we need to redirect that separately so we can capture either case.

Expand All @@ -43,20 +43,11 @@ while read -r FILENAME; do

if [[ $RETURN_VAL -gt 0 ]]; then
echo -e "${RED}${OUT} failed style checks.${RESET}"
FAILED="true"
uncrustify${CONFIG} -f ${FILENAME} -o ${TMPFILE} && colordiff -u ${FILENAME} ${TMPFILE}
EXIT_VAL=$RETURN_VAL
else
echo -e "${GREEN}${OUT} passed style checks.${RESET}"
fi

if [[ -n "$INPUT_CHECKSTD" ]] && [[ "$INPUT_CHECKSTD" == "true" ]]; then
# Counts occurrences of std:: that aren't in comments and have a leading space (except if it's inside pointer brackets, eg: <std::thing>)
RETURN_VAL=$(sed -n '/^.*\/\/.*/!s/ std:://p; /^.* std::.*\/\//s/ std:://p; /^.*\<.*std::.*\>/s/std:://p;' "${FILENAME}" | wc -l)
if [[ $RETURN_VAL -gt 0 ]] && [[ "$FAILED" != "true" ]]; then
echo -e "${RED}${OUT} failed style checks.${RESET}"
EXIT_VAL=$RETURN_VAL
fi
fi
done < <(git diff --name-status --diff-filter=AM origin/master...${BRANCH_NAME} -- '*.cpp' '*.h' '*.hpp' '*.cxx' | awk '{ print $2 }' )

exit $EXIT_VAL

0 comments on commit 751824b

Please sign in to comment.