Skip to content

Commit

Permalink
Add shellcheck linter
Browse files Browse the repository at this point in the history
  • Loading branch information
sgizler committed Sep 25, 2024
1 parent 4dbe76b commit 900c1c4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test-and-lint:
image: "verilator/verilator:v5.016"
tags: ['ace-x86_64']
script:
- apt-get -qqy update && apt-get -qqy --no-install-recommends install cmake build-essential git ca-certificates python3 clang-format-14 mold ninja-build
- apt-get -qqy update && apt-get -qqy --no-install-recommends install cmake build-essential git ca-certificates python3 clang-format-14 mold ninja-build shellcheck
- cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -G Ninja -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=mold" -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=mold"
- cmake --build build -j"$(nproc)"
- PATH="$PWD/build:$PWD/scripts:$PATH" && make -j"$(nproc)" -O -k --no-print-directory -f check.mk
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install deps
run: apt-get -qqy update && apt-get -qqy --no-install-recommends install cmake build-essential git ca-certificates python3 clang-format-14
run: apt-get -qqy update && apt-get -qqy --no-install-recommends install cmake build-essential git ca-certificates python3 clang-format-14 shellcheck
- name: Build
run: |
cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
Expand Down
19 changes: 18 additions & 1 deletion check.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ test_and_lint_dont_abort_after_err:
.PHONY: test_and_lint
test_and_lint: test lint

.PHONY: autofix
autofix: autofmt shellcheck_autofix

.PHONY: autofmt
autofmt:
clang-format-14 -i source/*.cpp source/*.hpp
Expand All @@ -16,11 +19,25 @@ test:
@$(MAKE) -C tests

.PHONY: lint
lint: fmt_check
lint: fmt_check shellcheck

.PHONY: fmt_check
fmt_check:
for i in source/*.cpp source/*.hpp; do \
diff "$$i" <(clang-format-14 "$$i") --label "original $$i" --label "formatted $$i" --color=always -u; \
done
@echo # blank line for consistency


SCRIPTS=scripts/* tests/*.sh tests/run_test \
examples/caliptra_vcd/sv-bugpoint-check.sh \
examples/caliptra_verilation_err/sv-bugpoint-check.sh

.PHONY: shellcheck
shellcheck:
shellcheck $(SCRIPTS) --color

.PHONY: shellcheck
shellcheck_autofix:
shellcheck $(SCRIPTS) -f diff --color || exit 0
shellcheck $(SCRIPTS) -f diff | git apply

0 comments on commit 900c1c4

Please sign in to comment.