Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: check-codestyle
on:
pull_request:

jobs:
check-codestyle:
strategy:
fail-fast: false
runs-on: ubuntu-latest
name: check codestyle
steps:
- uses: actions/checkout@v2
- name: Check core codestyle
run: source ./codestyle.sh

23 changes: 23 additions & 0 deletions codestyle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -e

echo "Codestyle check script:"
echo

declare -A singleLineRegexChecks=(
["[[:blank:]]$"]="Remove whitespace at the end of the lines above"
["\t"]="Replace tabs with 4 spaces in the lines above"
)

for check in ${!singleLineRegexChecks[@]}; do
echo " Checking RegEx: '${check}'"

if grep -P -r -I -n ${check} exercises/ | grep .cpp; then
echo
echo "${singleLineRegexChecks[$check]}"
exit 1
fi
done

echo
echo "Everything looks good"