-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The CI pipeline can automate the validation for Linux kernel module builds along with coding style checks.
- Loading branch information
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
function build_mod() | ||
{ | ||
make all || exit 1 | ||
} | ||
|
||
function run_tests() | ||
{ | ||
make check || exit 2 | ||
} | ||
|
||
build_mod | ||
run_tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
SOURCES=$(find $(git rev-parse --show-toplevel) | egrep "\.(cpp|cc|c|h)\$") | ||
|
||
CLANG_FORMAT=$(which clang-format-12) | ||
if [ $? -ne 0 ]; then | ||
CLANG_FORMAT=$(which clang-format) | ||
if [ $? -ne 0 ]; then | ||
echo "[!] clang-format not installed. Unable to check source file format policy." >&2 | ||
exit 1 | ||
fi | ||
fi | ||
|
||
set -x | ||
|
||
for file in ${SOURCES}; | ||
do | ||
$CLANG_FORMAT ${file} > expected-format | ||
diff -u -p --label="${file}" --label="expected coding style" ${file} expected-format | ||
done | ||
exit $($CLANG_FORMAT --output-replacements-xml ${SOURCES} | egrep -c "</replacement>") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e -u -o pipefail | ||
|
||
ret=0 | ||
show=0 | ||
# Reference: https://medium.com/@alexey.inkin/how-to-force-newline-at-end-of-files-and-why-you-should-do-it-fdf76d1d090e | ||
while IFS= read -rd '' f; do | ||
if file --mime-encoding "$f" | grep -qv binary; then | ||
tail -c1 < "$f" | read -r _ || show=1 | ||
if [ $show -eq 1 ]; then | ||
echo "Warning: No newline at end of file $f" | ||
ret=1 | ||
show=0 | ||
fi | ||
fi | ||
done < <(git ls-files -z src tests/arch-test-target) | ||
|
||
exit $ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: main | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
validate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout code | ||
uses: actions/checkout@v4 | ||
- name: validate coding style and functionality | ||
run: | | ||
sudo apt-get install -q -y clang-format-12 | ||
.ci/check-newline.sh | ||
.ci/check-format.sh | ||
.ci/build-n-run.sh | ||
shell: bash |