From bd47605b0ac44614972982bfd6880911474d6608 Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Sun, 8 Sep 2024 23:14:51 -0500 Subject: [PATCH] Attempt lua code coverage, linting --- .codecov.yaml | 4 ++++ .github/workflows/lua-lint.yml | 23 +++++++++++++++++++++++ .github/workflows/lua.yml | 17 ++++++++++++++--- README.rst | 5 ++++- lua/Makefile | 9 ++++++++- 5 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/lua-lint.yml diff --git a/.codecov.yaml b/.codecov.yaml index 70473515..42a87b67 100644 --- a/.codecov.yaml +++ b/.codecov.yaml @@ -29,6 +29,10 @@ component_management: name: JavaScript paths: - javascript/** + - component_id: module_lua + name: Lua + paths: + - lua/** - component_id: module_python name: Python paths: diff --git a/.github/workflows/lua-lint.yml b/.github/workflows/lua-lint.yml new file mode 100644 index 00000000..2f63fcf7 --- /dev/null +++ b/.github/workflows/lua-lint.yml @@ -0,0 +1,23 @@ +name: Lua Lint + +on: + push: + paths: + - 'lua/**' + - '!lua/README.rst' + schedule: + - cron: "0 0 1 * *" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + luacheck: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Luacheck linter + uses: lunarmodules/luacheck@v1 diff --git a/.github/workflows/lua.yml b/.github/workflows/lua.yml index 6fd5b55d..56c8983f 100644 --- a/.github/workflows/lua.yml +++ b/.github/workflows/lua.yml @@ -10,12 +10,11 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: false + cancel-in-progress: true jobs: test: strategy: - fail-fast: false matrix: os: - ubuntu-latest @@ -45,4 +44,16 @@ jobs: brew install lua@${{ matrix.version }} fi - - run: make lu_test + - uses: leafo/gh-actions-luarocks@v4 + with: + withLuaPath: "lua" + + - run: luarocks install luacov + + - run: make lu_test COV=true + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + flags: Lua diff --git a/README.rst b/README.rst index 810f6299..a9380a6f 100644 --- a/README.rst +++ b/README.rst @@ -23,6 +23,8 @@ Olivia's Project Euler Solutions :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/eslint.yml .. |Luai| image:: https://img.shields.io/github/actions/workflow/status/LivInTheLookingGlass/Euler/lua.yml?logo=github&label=Lua%20Tests :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/lua.yml +.. |LuaCheck| image:: https://img.shields.io/github/actions/workflow/status/LivInTheLookingGlass/Euler/lua-lint.yml?logo=github&label=LuaCheck + :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/lua-lint.yml .. |Python| image:: https://img.shields.io/github/actions/workflow/status/LivInTheLookingGlass/Euler/python.yml?logo=github&label=Py%20Tests :target: https://github.com/LivInTheLookingGlass/Euler/actions/workflows/python.yml .. |PythonLint| image:: https://img.shields.io/github/actions/workflow/status/LivInTheLookingGlass/Euler/python-lint.yml?logo=github&label=Linting @@ -91,7 +93,8 @@ Olivia's Project Euler Solutions | | Browser [#]_ | | |CodeQL| |br| | | | | | |ESLint| | +------------+----------------------------+--------+-------------------+ - | Lua | Lua 5+ [#]_ | 7 | |Luai| | + | Lua | Lua 5+ [#]_ | 7 | |Luai| |br| | + | | | | |LuaCheck| | +------------+----------------------------+--------+-------------------+ | Python | CPython 3.6+ |br| | 80 | |Python| |br| | | | Pypy 3.6+ |br| | | |Py-Cov| |br| | diff --git a/lua/Makefile b/lua/Makefile index 013e7b43..6002405d 100644 --- a/lua/Makefile +++ b/lua/Makefile @@ -1,6 +1,13 @@ BLUE=\033[0;34m NC=\033[0m # No Color +COV?=false +ifneq ($(COV),false) +cov_args= -lluacov +else +cov_args= +endif + .PHONY: help help: @echo " $(BLUE)test$(NC) Run through all Lua tests in sequence." @@ -9,7 +16,7 @@ help: .PHONY: test test: ../LICENSE - @lua test.lua + @lua test.lua $(cov_args) test_%: @$(MAKE) test $(MFLAGS)