Skip to content

Commit 7f70f9c

Browse files
committed
Add checks for zombie sourcecode problems
This adds checks for zombie sourcecode problems, i.e. problems we have tried to eliminate but which might be or have been resurrected. The example check is for the problematic #include "ac_cfg.h" with double quotes instead of <> which were identified as a problem in #1706 and then fixed.
1 parent 9e9825c commit 7f70f9c

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "Sourcecode Checks"
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- 'onlinedocs'
7+
pull_request:
8+
branches-ignore:
9+
- 'onlinedocs'
10+
11+
env:
12+
13+
jobs:
14+
15+
sourcecode-checks:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
20+
- uses: actions/checkout@v4
21+
22+
- name: Install prerequisites
23+
run: >-
24+
25+
- name: "Run sourcecode-checks script"
26+
run: ./tools/sourcecode-checks

tools/check-sourcecode

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
# check-sourcecode -- check the avrdude source code for zombie mistakes
3+
# Copyright (C) 2024 Hans Ulrich Niedermann <[email protected]>
4+
# SPDX-License-Identifier: GPL-2.0-or-later
5+
6+
7+
set -e
8+
9+
prog="$(basename "$0")"
10+
cd "$(dirname "$0")"
11+
cd ..
12+
test -s README.md
13+
test -s COPYING
14+
test -s build.sh
15+
test -d .git/refs/heads
16+
17+
18+
declare -a checks=()
19+
fail=0
20+
succ=0
21+
22+
23+
checks+=(check_ac_cfg)
24+
check_ac_cfg() {
25+
if git grep -E '#include\s+"ac_cfg\.h"'
26+
then
27+
echo "Error: Found #include \"ac_cfg.h\" with double quotes \"\". Should be <>."
28+
echo " See https://github.com/avrdudes/avrdude/issues/1706 for details."
29+
return 1
30+
fi
31+
}
32+
33+
34+
for check in "${checks[@]}"
35+
do
36+
if "$check"; then
37+
succ=$(( "$succ" + 1 ))
38+
status="SUCC"
39+
else
40+
fail=$(( "$fail" + 1 ))
41+
status="FAIL"
42+
fi
43+
echo "$status $check"
44+
done
45+
total=$(( "$succ" + "$fail" ))
46+
47+
48+
echo "$prog: Summary: $fail checks failed, $succ checks succeeded. $total checks in total."
49+
exit 0

0 commit comments

Comments
 (0)