Skip to content

Commit c390589

Browse files
committed
use github actions instead of travis ci
1 parent 460b13f commit c390589

File tree

6 files changed

+87
-85
lines changed

6 files changed

+87
-85
lines changed

.github/workflows/test.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: test
2+
3+
on: [push]
4+
5+
jobs:
6+
test:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
os: [ubuntu-latest, macos-latest]
11+
luaVersion: ["5.1", "5.2", "5.3", "5.4", "luajit"]
12+
13+
runs-on: ${{ matrix.os }}
14+
15+
steps:
16+
- uses: actions/checkout@master
17+
18+
- uses: leafo/gh-actions-lua@master
19+
with:
20+
luaVersion: ${{ matrix.luaVersion }}
21+
22+
- uses: leafo/gh-actions-luarocks@master
23+
24+
- name: setup
25+
run: |
26+
luarocks install lua-llthreads2
27+
luarocks --server=https://luarocks.org/dev install mtmsg
28+
luarocks make rockspecs/mtstates-scm-0.rockspec
29+
30+
- name: test
31+
run: |
32+
set -e
33+
lua -v
34+
cd tests
35+
lua test01.lua
36+
lua test02.lua
37+
lua test03.lua
38+
lua test04.lua
39+
cd ../examples
40+
lua example01.lua
41+
lua example02.lua
42+
lua example03.lua
43+
lua example04.lua
44+
lua example05.lua
45+
lua example06.lua
46+

.travis.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# mtstates
22
[![Licence](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENSE)
3-
[![Build Status](https://travis-ci.org/osch/lua-mtstates.svg?branch=master)](https://travis-ci.org/osch/lua-mtstates)
3+
[![build status](https://github.com/osch/lua-mtstates/workflows/test/badge.svg)](https://github.com/osch/lua-mtstates/actions/workflows/test.yml)
44
[![Build status](https://ci.appveyor.com/api/projects/status/v8t6rsf45dwt60pl/branch/master?svg=true)](https://ci.appveyor.com/project/osch/lua-mtstates/branch/master)
55
[![Install](https://img.shields.io/badge/Install-LuaRocks-brightgreen.svg)](https://luarocks.org/modules/osch/mtstates)
66

appveyor.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ environment:
1212
- LUA: "lua 5.1"
1313
- LUA: "lua 5.2"
1414
- LUA: "lua 5.3"
15+
- LUA: "lua 5.4"
1516

1617
platform:
1718
- x64
@@ -46,25 +47,26 @@ before_build:
4647
build_script:
4748
- echo "Making..."
4849
- luarocks install lua-llthreads2
49-
- luarocks install mtmsg
50+
- luarocks --server=https://luarocks.org/dev install mtmsg
5051
- luarocks make rockspecs/mtstates-scm-0.rockspec
5152

5253
before_test:
5354
# test deps
5455

5556
test_script:
5657
- echo "Testing..."
58+
- cd %APPVEYOR_BUILD_FOLDER%\tests
59+
- lua test01.lua
60+
- lua test02.lua
61+
- lua test03.lua
62+
- lua test04.lua
5763
- cd %APPVEYOR_BUILD_FOLDER%\examples
5864
- lua example01.lua
5965
- lua example02.lua
6066
- lua example03.lua
6167
- lua example04.lua
6268
- lua example05.lua
63-
- cd %APPVEYOR_BUILD_FOLDER%\tests
64-
- lua test01.lua
65-
- lua test02.lua
66-
- lua test03.lua
67-
- lua test04.lua
69+
- lua example06.lua
6870

6971
after_test:
7072
# deploy

tests/test01.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
local load = loadstring and loadstring or load
22
local dump = string.dump
3+
4+
print("test01 started")
5+
print("Lua Version", _VERSION, jit and " (jit)" or "")
6+
37
local mtstates = require("mtstates")
48
local mts = mtstates
5-
print("test01 started")
9+
610
print("mtstates._VERSION", mts._VERSION)
711
print("mtstates._INFO", mts._INFO)
12+
813
local function line()
914
return debug.getinfo(2).currentline
1015
end

tests/test02.lua

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ local function pcall(f, ...)
1212
return xpcall(f, msgh, ...)
1313
end
1414

15+
function RUN()
1516
PRINT("==================================================================================")
1617
do
1718
local threadIn = mtmsg.newbuffer()
@@ -277,17 +278,19 @@ do
277278
threadIn:id(), threadOut:id(), s:id())
278279
thread:start()
279280

281+
local eps = 0.2
282+
280283
local startTime = mtmsg.time()
281284
assert(s:call("sleep", 1) == nil)
282285
local diffTime = mtmsg.time() - startTime
283-
print(diffTime)
284-
assert(math.abs(diffTime - 1) < 0.1)
286+
PRINT(diffTime)
287+
assert(math.abs(diffTime - 1) < eps)
285288

286289
local startTime = mtmsg.time()
287290
assert(s:call("sleep", 0.5) == nil)
288291
local diffTime = mtmsg.time() - startTime
289-
print(diffTime)
290-
assert(math.abs(diffTime - 0.5) < 0.1)
292+
PRINT(diffTime)
293+
assert(math.abs(diffTime - 0.5) < eps)
291294

292295

293296
threadIn:addmsg("sleepa", 1)
@@ -296,38 +299,38 @@ do
296299
local ok, rslt = s:tcall(0.5, "add", 3)
297300
print(ok, rslt)
298301
local diffTime = mtmsg.time() - startTime
299-
print(diffTime)
302+
PRINT(diffTime)
300303
assert(not ok and rslt == nil)
301-
assert(math.abs(diffTime - 0.5) < 0.1)
304+
assert(math.abs(diffTime - 0.5) < eps)
302305

303306
threadIn:addmsg("sleepa", 1)
304307
assert(stateOut:nextmsg() == "started")
305308
local startTime = mtmsg.time()
306309
local ok, rslt = s:tcall(1.5, "add", 4)
307310
print(ok, rslt)
308311
local diffTime = mtmsg.time() - startTime
309-
print(diffTime)
312+
PRINT(diffTime)
310313
assert(ok and rslt == 104)
311-
assert(math.abs(diffTime - 1) < 0.1)
314+
assert(math.abs(diffTime - 1) < eps)
312315

313316
threadIn:addmsg("sleepa", 0.5)
314317
assert(stateOut:nextmsg() == "started")
315318
local startTime = mtmsg.time()
316319
local rslt = s:call("add", 5)
317-
print(rslt)
320+
PRINT(rslt)
318321
local diffTime = mtmsg.time() - startTime
319-
print(diffTime)
322+
PRINT(diffTime)
320323
assert(rslt == 105)
321-
assert(math.abs(diffTime - 0.5) < 0.1)
324+
assert(math.abs(diffTime - 0.5) < eps)
322325

323326
threadIn:addmsg("sleepa", 10)
324327
assert(stateOut:nextmsg() == "started")
325328
local startTime = mtmsg.time()
326329
mtmsg.abort(true)
327330
local ok, err = thread:join()
328331
local diffTime = mtmsg.time() - startTime
329-
print(diffTime)
330-
assert(math.abs(diffTime) < 0.1)
332+
PRINT(diffTime)
333+
assert(math.abs(diffTime) < eps)
331334
print("-------------------------------------")
332335
PRINT("-- Expected error:")
333336
print(err)
@@ -338,3 +341,13 @@ do
338341
end
339342
PRINT("==================================================================================")
340343
print("OK.")
344+
end -- function RUN
345+
346+
local ok, err = pcall(function()
347+
RUN()
348+
end)
349+
350+
if not ok then
351+
print(err)
352+
os.exit(1) -- doesn't wait for running threads
353+
end

0 commit comments

Comments
 (0)