Skip to content

Commit

Permalink
Add lua coverage in different job
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Sep 12, 2024
1 parent 791df57 commit a14e66d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .github/workflows/lua-cov.yml
Original file line number Diff line number Diff line change
@@ -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 [email protected] 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
5 changes: 5 additions & 0 deletions lua/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
BLUE=\033[0;34m
NC=\033[0m # No Color
COV?=false

.PHONY: help
help:
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion lua/test.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local has_luacov = package.loaded['luacov'] ~= nil

function loadlib(...)
local libname = select(1, ...)
local length = select("#", ...)
Expand Down Expand Up @@ -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."
Expand Down

0 comments on commit a14e66d

Please sign in to comment.