diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bbe5919af..4bedaf71a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 diff --git a/Makefile b/Makefile index 8d229bec7..a18ff47f0 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/src/Makefile b/src/Makefile index c375cb5fa..ddaaf38eb 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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))) @@ -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 \ @@ -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