Skip to content

Commit 7572cbf

Browse files
authored
ci: add codestyle check (#196)
1 parent 09e2268 commit 7572cbf

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

.github/workflows/codestyle.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: check-codestyle
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
check-codestyle:
7+
strategy:
8+
fail-fast: false
9+
runs-on: ubuntu-latest
10+
name: check codestyle
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Check core codestyle
14+
run: source ./codestyle.sh
15+

codestyle.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Codestyle check script:"
5+
echo
6+
7+
declare -A singleLineRegexChecks=(
8+
["[[:blank:]]$"]="Remove whitespace at the end of the lines above"
9+
["\t"]="Replace tabs with 4 spaces in the lines above"
10+
)
11+
12+
for check in ${!singleLineRegexChecks[@]}; do
13+
echo " Checking RegEx: '${check}'"
14+
15+
if grep -P -r -I -n ${check} exercises/ | grep .cpp; then
16+
echo
17+
echo "${singleLineRegexChecks[$check]}"
18+
exit 1
19+
fi
20+
done
21+
22+
echo
23+
echo "Everything looks good"

0 commit comments

Comments
 (0)