From a14e66d94a0aa08b21336b12a9b5bc51cac81b5c Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Wed, 11 Sep 2024 22:49:08 -0500 Subject: [PATCH] Add lua coverage in different job --- .github/workflows/lua-cov.yml | 32 ++++++++++++++++++++++++++++++++ lua/Makefile | 5 +++++ lua/test.lua | 4 +++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/lua-cov.yml diff --git a/.github/workflows/lua-cov.yml b/.github/workflows/lua-cov.yml new file mode 100644 index 00000000..cb7060fb --- /dev/null +++ b/.github/workflows/lua-cov.yml @@ -0,0 +1,32 @@ +name: Lua + +on: + push: + paths: + - 'lua/**' + - '!lua/README.rst' + schedule: + - cron: "0 0 1 * *" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: macos-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: brew install lua@5.4 luarocks + + - run: sudo luarocks install luacov + + - run: lua -v && make lu_test COV=true + + - run: find ./lua -print | sort + + - run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }} -F Lua diff --git a/lua/Makefile b/lua/Makefile index 4f2bf4e1..c800d725 100644 --- a/lua/Makefile +++ b/lua/Makefile @@ -1,5 +1,6 @@ BLUE=\033[0;34m NC=\033[0m # No Color +COV?=false .PHONY: help help: @@ -9,7 +10,11 @@ help: .PHONY: test test: ../LICENSE +ifneq ($(COV),false) + @lua -lluacov test.lua && luacov +else @lua test.lua +endif test_%: @$(MAKE) test $(MFLAGS) diff --git a/lua/test.lua b/lua/test.lua index b6b49a84..89b13468 100644 --- a/lua/test.lua +++ b/lua/test.lua @@ -1,3 +1,5 @@ +local has_luacov = package.loaded['luacov'] ~= nil + function loadlib(...) local libname = select(1, ...) local length = select("#", ...) @@ -59,7 +61,7 @@ local function check_problem(file_name, expected_answer, is_slow, problem_name) ) end - if not is_slow and elapsed_time > 60 then + if not is_slow and not has_luacov and elapsed_time > 60 then error( "Problem " .. problem_name .. " took ~" .. string.format("%.3f", elapsed_time) .. "s, exceeding the expected time limit of 60s."