From d9f2df58ee661ae979f46709b87749e6a086f3da Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 29 Mar 2021 15:29:31 -0400 Subject: [PATCH 1/3] chore: Format on CI --- .github/workflows/main.yaml | 12 ++++++++++++ format.sh | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/main.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..3076dbf --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,12 @@ +# CI workflow +name: sledge +on: [push, pull_request] + +# job control +jobs: + format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Clang Format + run: ./format.sh -d diff --git a/format.sh b/format.sh index 8c6a804..b901144 100755 --- a/format.sh +++ b/format.sh @@ -25,9 +25,34 @@ if ((major < required_major)) || ((minor < required_minor)) || ((patch < require exit 1 fi -# Match all *.c and *.h files in ./runtime -# Excluding those in the jsmn or http-parser submodules -# And format them with clang-format -find ./runtime -type f -path "./*.[ch]" | - grep --invert-match -E "./runtime/thirdparty/*|./runtime/tests/gocr/*|./runtime/tests/TinyEKF/*|./runtime/tests/CMSIS_5_NN/*|./runtime/tests/sod/*|**/thirdparty/*" | - xargs clang-format -i +help() { + echo "Usage: $0 [OPTION]..." + echo "Formats source code in the repository, applying formatting in place by default" + echo "" + echo "-h, --help Print Help" + echo "-d, --dry-run Dry run formatters, returning 0 when code passes, 1 otherwise" + echo "" + echo "Exit status:" + echo "0 if code required no formatting" + echo "non-zero exit status otherwise" +} + +dry_run() { + find runtime \ + \( -path "runtime/thirdparty" -o -path "runtime/tests/gocr" -o -path "runtime/tests/TinyEKF" -o -path "runtime/tests/CMSIS_5_NN" -o -path "runtime/tests/sod" -o -path "runtime/tests/**/thirdparty" \) -prune -false -o \ + -type f \( -iname \*.h -o -iname \*.c -o -iname \*.s \) -print | + xargs clang-format -Werror -n -ferror-limit=0 +} + +format() { + find runtime \ + \( -path "runtime/thirdparty" -o -path "runtime/tests/gocr" -o -path "runtime/tests/TinyEKF" -o -path "runtime/tests/CMSIS_5_NN" -o -path "runtime/tests/sod" -o -path "runtime/tests/**/thirdparty" \) -prune -false -o \ + -type f \( -iname \*.h -o -iname \*.c -o -iname \*.s \) -print | + xargs clang-format -i +} + +case $1 in + "-h" | "--help") help ;; + "-d" | "--dry-run") dry_run ;; + "") format ;; +esac From c290d30d951066a59a4548999b072f03b874d816 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 29 Mar 2021 15:31:02 -0400 Subject: [PATCH 2/3] chore: Test break CI --- runtime/src/env.c | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/src/env.c b/runtime/src/env.c index b275b14..9194472 100644 --- a/runtime/src/env.c +++ b/runtime/src/env.c @@ -10,6 +10,7 @@ extern int32_t inner_syscall_handler(int32_t n, int32_t a, int32_t b, int32_t c, int32_t env_syscall_handler(int32_t n, int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, int32_t f) { + int32_t i = inner_syscall_handler(n, a, b, c, d, e, f); return i; From d9a5a8565fb23f17962de5dbda29e3ef85f447d3 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 29 Mar 2021 15:31:50 -0400 Subject: [PATCH 3/3] chore: test fix ci --- runtime/src/env.c | 1 - 1 file changed, 1 deletion(-) diff --git a/runtime/src/env.c b/runtime/src/env.c index 9194472..b275b14 100644 --- a/runtime/src/env.c +++ b/runtime/src/env.c @@ -10,7 +10,6 @@ extern int32_t inner_syscall_handler(int32_t n, int32_t a, int32_t b, int32_t c, int32_t env_syscall_handler(int32_t n, int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, int32_t f) { - int32_t i = inner_syscall_handler(n, a, b, c, d, e, f); return i;