Skip to content

Commit

Permalink
kit v3 (with tarantool 3.0.1 support)
Browse files Browse the repository at this point in the history
  • Loading branch information
ochaton authored Apr 2, 2024
1 parent 60477a3 commit 8f78818
Show file tree
Hide file tree
Showing 12 changed files with 284 additions and 33 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Linting with luacheck

on:
- push
- pull_request

jobs:
run-luacheck-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: tarantool/setup-tarantool@v3
with:
tarantool-version: '2.11.2'
- name: install tarantool/luacheck and execute it
run: tarantoolctl rocks install luacheck && .rocks/bin/luacheck .
58 changes: 58 additions & 0 deletions .github/workflows/push-rockspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Create and push rockspec for moonlibs/sync

on:
workflow_dispatch:
workflows:
- "Linting with luacheck"
- "Testing with unit tests"
types:
- completed
push:
tags:
- '*'

env:
ROCK_NAME: kit

jobs:
pack-and-push-tagged-rockspec:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }} && startsWith(github.ref, 'refs/tags/') }}
steps:
- uses: actions/checkout@v4
- uses: tarantool/setup-tarantool@v2
with:
tarantool-version: '2.10.4'

# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
- name: Set env
run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- run: tarantoolctl rocks new_version --tag=${{ env.TAG }} rockspecs/${{ env.ROCK_NAME }}-dev-1.rockspec ${{ env.TAG }} "git+https://github.com/${{ github.repository }}.git"
- run: tarantoolctl rocks install ${{ env.ROCK_NAME }}-${{ env.TAG }}-1.rockspec
- run: tarantoolctl rocks pack ${{ env.ROCK_NAME }}-${{ env.TAG }}-1.rockspec
# Install native lua with luarocks
- uses: leafo/gh-actions-lua@v9
with:
luaVersion: "luajit-2.1.0-beta3"
- uses: leafo/gh-actions-luarocks@v4
with:
luarocksVersion: "3.8.0"
- uses: unfor19/[email protected]
- run: mkdir .build && cp rockspecs/${{ env.ROCK_NAME }}-dev-1.rockspec ${{ env.ROCK_NAME }}-${{ env.TAG }}-1.rockspec .build/ && cp *.src.rock .build/
- name: rebuild and publish s3 luarocks server
env:
AWS_ACCESS_KEY_ID: ${{ secrets.MOONLIBS_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.MOONLIBS_S3_SECRET_KEY}}
AWS_EC2_METADATA_DISABLED: true
run: |
cd .build && aws s3 sync s3://moonlibs/ ./ && luarocks-admin make_manifest . && aws s3 sync --acl public-read ./ s3://moonlibs/;
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
README.md
${{env.ROCK_NAME}}-dev-1.rockspec
${{env.ROCK_NAME}}-${{env.TAG}}-1.rockspec
${{env.ROCK_NAME}}-${{env.TAG}}-1.src.rock
74 changes: 74 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Testing with unit tests

on:
- push
- pull_request

jobs:
run-unit-tests:
runs-on: ubuntu-22.04
strategy:
matrix:
version: ["1.10.15", "2.10.7", "2.11.2", "3.0.1"]
steps:
- uses: actions/checkout@v4
- uses: tarantool/setup-tarantool@v3
with:
tarantool-version: '2.10.4'
- name: install luacov-console
run: tarantoolctl rocks install luacov-console
- name: install luacov-coveralls
run: tarantoolctl rocks install --server=http://luarocks.org luacov-coveralls
- uses: tarantool/setup-tarantool@v3
with:
tarantool-version: ${{matrix.version}}
- name: setup perl
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: 5.18.4
- name: show perl version
run: |
perl -v
- name: install TAP::Harness
run: |
cpanm -v
cpanm --notest TAP::Harness
- name: run tests
env:
LUACOV_ENABLE: true
run: |
make test
- name: rename luacov.stats.out
run: mv luacov.stats.out luacov.stats.out-${{matrix.version}}
- uses: actions/upload-artifact@master
with:
name: luacov.stats.out-${{matrix.version}}
path: luacov.stats.out-${{matrix.version}}

run-coverage-report:
runs-on: ubuntu-latest
needs: ["run-unit-tests"]
steps:
- uses: actions/checkout@v4
- uses: tarantool/setup-tarantool@v3
with:
tarantool-version: '2.10.7'
- name: install luacov-coveralls 0.2.3
run: tarantoolctl rocks install --server=https://luarocks.org luacov-coveralls 0.2.3
- name: install luacov-console 1.2.0
run: tarantoolctl rocks --server http://moonlibs.github.io/rocks install luacov-console 1.2.0
- name: Download run artifacts
uses: actions/download-artifact@v4
with:
pattern: luacov.stats.out-*
merge-multiple: true
- name: debug
run: ls -la .
- name: merge luacov.stats.out
run: cat luacov.stats.out-* | >luacov.stats.out tarantool -e 'm={} for k in io.lines() do local vs=io.read():split(" ") vs[#vs]=nil local r = m[k] if r then for i, v in pairs(vs) do r[i]=r[i]+v end else m[k]=vs end end; for k, v in pairs(m) do print(k) print(table.concat(v, " ")) end'
- name: prepare coverage report
run: .rocks/bin/luacov-console . && .rocks/bin/luacov-console -s
- name: publish coveralls report
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: .rocks/bin/luacov-coveralls -v
38 changes: 38 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
std="tarantool"

max_line_length=140
include_files = {"kit/", "kit.lua"}

globals = { "kit" }

read_globals = {
"_TARANTOOL",
"config",
"package.reload",
"kit",
}

files["kit/1/5/*.lua"] = {
read_globals = {
"box.fiber",
"box.time",
"box.time64",
"box.ipc",
"box.errno",
}
}

globals = { "table" }

ignore = {
"121", -- setting read-only global variable
"211", -- unused variable
"212", -- unused argument
"213", -- unused loop variable
"411", -- redefinition of the variable
"421", -- shadowing definition of variable
"431", -- shadwing upvalue
"432", -- shadowing upvalue argument
"542", -- empty if branch
"611", -- contains only whitespaces
}
21 changes: 21 additions & 0 deletions .luacov
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
runreport = false
deletestats = false

exclude = {
"%.rocks/",
"builtin/",
"01-base%.test%.lua"
}

pathcorrect = {
{ "^/source/kit/", "" },
}

coveralls = {
root = "/",
debug = true,
pathcorrect = {
{ "^/home/runner/work/kit/kit/", "" },
{ "^/source/kit", "" },
},
}
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.PHONY := all test

test:
export LUACOV_ENABLE=true
prove t/*.lua
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Currently supported versions
* 1.7
* 1.9
* 1.10
* 2.x
* 3.0.x

## `_G`lobal

Expand Down Expand Up @@ -75,11 +77,9 @@ end
* `table.clear`

* `box.NULL`
- for every version, including 1.5 and accessible without box.cfg
* for every version, including 1.5 and accessible without box.cfg

* `kit.schema_version`


* module `fiber`
* module `fiber.channel`

* module `fiber.channel`
26 changes: 0 additions & 26 deletions gen-mod.pl

This file was deleted.

34 changes: 34 additions & 0 deletions kit-dev-1.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package = "kit"
version = "dev-1"
source = {
url = "git+https://github.com/moonlibs/kit.git",
branch = "master"
}
description = {
summary = "Compatibility kit for Tarantool",
homepage = "https://github.com/moonlibs/kit.git",
license = "BSD"
}
dependencies = {
"lua >= 5.1"
}
build = {
type = "builtin",
modules = {
kit = "kit.lua",
["kit.1"] = "kit/1.lua",
["kit.1.10"] = "kit/1/10.lua",
["kit.1.5"] = "kit/1/5/init.lua",
["kit.1.5.errno"] = "kit/1/5/errno.lua",
["kit.1.5.fiber"] = "kit/1/5/fiber.lua",
["kit.1.5.socket"] = "kit/1/5/socket.lua",
["kit.1.6"] = "kit/1/6.lua",
["kit.1.6.0"] = "kit/1/6/0.lua",
["kit.1.6+"] = "kit/1/6+.lua",
["kit.1.7"] = "kit/1/7.lua",
["kit.1.9"] = "kit/1/9.lua",
["kit.2"] = "kit/2.lua",
["kit.3"] = "kit/3.lua",
["kit.loc"] = "kit/loc.lua"
}
}
2 changes: 0 additions & 2 deletions kit/3.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
return function(M,I)
require 'kit.1'(M,I)
require 'kit.1.10'(M,I)
require 'kit.2'(M,I)
end
2 changes: 1 addition & 1 deletion kit/loc.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local _VERSION = '2'
local _VERSION = '3'

if rawget(_G,'kit') then
if kit._VERSION == _VERSION then
Expand Down
33 changes: 33 additions & 0 deletions t/01-base.test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env tarantool

if os.getenv("LUACOV_ENABLE") then
print("enabling luacov")
require 'luacov.runner'.init()
end

local kit = require 'kit'
box.cfg{}

local tap = require 'tap'
local t = tap.test("base")

t:is(kit.node.ro, box.info.ro, "kit.node.ro")
t:is(kit.node.lsn, box.info.lsn, "kit.node.lsn")
t:is(kit.node.rw, not box.info.ro, "kit.node.rw")
t:is(kit.node.uuid, box.info.uuid, "kit.node.uuid")
t:is(kit.node.id, box.info.id, "kit.node.id")

t:isstring(kit.node.hostname, "kit.node.hostname is string")

t:ok(kit.wait_lsn(kit.node.id, kit.node.lsn, 0), "wait_lsn(lsn, 0)")
t:ok(kit.wait_lsn(kit.node.id, kit.node.lsn, 0), "wait_lsn(lsn, 0)")

t:is(kit.wait_lsn(kit.node.id, kit.node.lsn+1, 0), false, "wait_lsn(lsn+1, 0)")

t:plan(t.total)

if t.failed > 0 then
os.exit(1)
else
os.exit(0)
end

0 comments on commit 8f78818

Please sign in to comment.