Skip to content

Commit

Permalink
Add Lua static analysis and format check to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart committed Jul 11, 2023
1 parent 15ce423 commit 6693541
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,18 @@ jobs:
- name: Install Ubuntu dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y libreadline-dev libboost-context-dev libboost-coroutine-dev libboost-filesystem-dev libssl-dev libc-ares-dev zlib1g-dev ca-certificates patchelf automake cmake clang-tidy-14 clang-format-14 lua5.4 liblua5.4-dev lua-socket libb64-dev libcrypto++-dev nlohmann-json3-dev
sudo apt-get install -y libreadline-dev libboost-context-dev libboost-coroutine-dev libboost-filesystem-dev libssl-dev libc-ares-dev zlib1g-dev ca-certificates patchelf automake cmake clang-tidy-14 clang-format-14 lua5.4 liblua5.4-dev luarocks lua-socket libb64-dev libcrypto++-dev nlohmann-json3-dev
- name: Install lua test dependencies
run: |
sudo luarocks install --lua-version=5.4 luacheck
- name: Install StyLua
run: |
sudo apt-get install -y wget unzip
wget https://github.com/JohnnyMorganz/StyLua/releases/download/v0.17.1/stylua-linux-x86_64.zip -O /tmp/stylua-linux-x86_64.zip
echo "c44231ca27bdcc3801682efd8b4460efb94f6c22 /tmp/stylua-linux-x86_64.zip" | sha1sum -c
sudo unzip /tmp/stylua-linux-x86_64.zip stylua -d /usr/bin
- name: Download cache of third-party build
run: aws s3 sync s3://cartesi-ci/${GITHUB_REPOSITORY}/cache/build-${BUILD_CACHE_VERSION} ./build && test -f ./build/`uname`_`uname -m`/lib/libcryptopp.so.7
Expand All @@ -303,9 +314,15 @@ jobs:
- name: Setup update-alternatives for clang-format
run: sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-14 120

- name: Check format
- name: Check format (C++)
run: make check-format

- name: Check format (Lua)
run: make check-format-lua

- name: Check Lua
run: make check-lua

- name: Setup update-alternatives for clang-tidy
run: sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-14 120

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ $(COREPROTO):
$(info gprc-interfaces submodule not initialized!)
@exit 1
grpc: | $(COREPROTO)
hash luacartesi grpc test test-all lint coverage check-format format:
hash luacartesi grpc test test-all lint coverage check-format check-format-lua check-lua format format-lua:
@eval $$($(MAKE) -s --no-print-directory env); $(MAKE) -C $(SRCDIR) $@
riscv-arch-tests:
@eval $$($(MAKE) -s --no-print-directory env); $(MAKE) -C third-party/riscv-arch-tests
Expand Down
14 changes: 13 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ CLANG_FORMAT_UARCH_FILES:=$(filter-out %uarch-printf%,$(strip $(CLANG_FORMAT_UAR
CLANG_FORMAT_FILES:=$(wildcard *.cpp) $(wildcard *.c) $(wildcard *.h) $(wildcard *.hpp) $(CLANG_FORMAT_UARCH_FILES)
CLANG_FORMAT_FILES:=$(filter-out %.pb.h,$(strip $(CLANG_FORMAT_FILES)))

STYLUA=stylua
STYLUA_FLAGS=--indent-type Spaces --collapse-simple-statement Always

EMPTY:=
SPACE:=$(EMPTY) $(EMPTY)
CLANG_TIDY_HEADER_FILTER=$(PWD)/($(subst $(SPACE),|,$(LINTER_HEADERS)))
Expand Down Expand Up @@ -294,7 +297,7 @@ endif

all: luacartesi grpc hash c-api jsonrpc-remote-cartesi-machine

.PHONY: all generate use clean test lint format check-format luacartesi grpc hash docker c-api compile_flags.txt
.PHONY: all generate use clean test lint format format-lua check-format check-format-lua luacartesi grpc hash docker c-api compile_flags.txt

CARTESI_OBJS:= \
pma-driver.o \
Expand Down Expand Up @@ -445,6 +448,15 @@ format:
check-format:
@$(CLANG_FORMAT) -Werror --dry-run $(CLANG_FORMAT_FILES)

format-lua:
@$(STYLUA) $(STYLUA_FLAGS) .

check-format-lua:
@$(STYLUA) $(STYLUA_FLAGS) --check .

check-lua:
luacheck .

fs.ext2: fs/*
genext2fs -f -i 512 -b 8192 -d fs fs.ext2
truncate -s %4096 fs.ext2
Expand Down

0 comments on commit 6693541

Please sign in to comment.