Skip to content

Commit 577b9ea

Browse files
authored
Implements per tube statistics (#19)
Major: adds per-tube statistics into xqueue Minors: - feat: allows background fibers of xqueue survive rw-ro switch - test: tests for common usage of xqueue with coverage - ci: github actions for lint, test, build, pack and release
1 parent dddd83e commit 577b9ea

18 files changed

Lines changed: 1650 additions & 185 deletions

.github/workflows/lint.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Linting with luacheck
2+
3+
on:
4+
- push
5+
6+
jobs:
7+
run-luacheck-linter:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: tarantool/setup-tarantool@v3
12+
with:
13+
tarantool-version: '2.10.4'
14+
15+
- name: install tarantool/luacheck and execute it
16+
run: tarantoolctl rocks install luacheck && .rocks/bin/luacheck .
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Create and push rockspec for moonlibs/xqueue
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
env:
9+
ROCK_NAME: xqueue
10+
11+
jobs:
12+
pack-and-push-tagged-rockspec:
13+
runs-on: ubuntu-latest
14+
if: startsWith(github.ref, 'refs/tags')
15+
steps:
16+
- uses: actions/checkout@master
17+
- uses: tarantool/setup-tarantool@v3
18+
with:
19+
tarantool-version: '2.6'
20+
21+
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
22+
- name: Set env
23+
run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
24+
25+
- run: tarantoolctl rocks new_version --tag=${{ env.TAG }} rockspecs/xqueue-scm-5.rockspec ${{ env.TAG }} "git+https://github.com/${{ github.repository }}.git"
26+
- run: tarantoolctl rocks --server https://moonlibs.github.io/rocks install ${{ env.ROCK_NAME }}-${{ env.TAG }}-1.rockspec
27+
- run: tarantoolctl rocks pack ${{ env.ROCK_NAME }}-${{ env.TAG }}-1.rockspec
28+
# Install native lua with luarocks
29+
- uses: leafo/gh-actions-lua@v9
30+
with:
31+
luaVersion: "luajit-2.1.0-beta3"
32+
- uses: leafo/gh-actions-luarocks@v4
33+
with:
34+
luarocksVersion: "3.8.0"
35+
- uses: unfor19/install-aws-cli-action@v1.0.3
36+
- run: mkdir .build && cp ${{env.ROCK_NAME}}-dev-1.rockspec ${{env.ROCK_NAME}}-${{env.TAG}}-1.rockspec .build/ && cp *.src.rock .build/
37+
- name: rebuild and publish s3 luarocks server
38+
env:
39+
AWS_ACCESS_KEY_ID: ${{ secrets.MOONLIBS_S3_ACCESS_KEY_ID }}
40+
AWS_SECRET_ACCESS_KEY: ${{ secrets.MOONLIBS_S3_SECRET_KEY}}
41+
AWS_EC2_METADATA_DISABLED: true
42+
run: |
43+
cd .build && aws s3 sync s3://moonlibs/ ./ && luarocks-admin make_manifest . && aws s3 sync --acl public-read ./ s3://moonlibs/;
44+
- uses: "marvinpinto/action-automatic-releases@latest"
45+
with:
46+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
47+
prerelease: false
48+
files: |
49+
README.md
50+
${{env.ROCK_NAME}}-dev-1.rockspec
51+
${{env.ROCK_NAME}}-${{env.TAG}}-1.rockspec
52+
${{env.ROCK_NAME}}-${{env.TAG}}-1.src.rock

.github/workflows/test.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Testing with unit tests
2+
3+
on:
4+
- push
5+
6+
jobs:
7+
run-unit-tests:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
version: ["1.10.15", "2.10.6", "2.11.0", "2.11.2"]
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: tarantool/setup-tarantool@v3
15+
with:
16+
tarantool-version: '${{matrix.version}}'
17+
- name: install luacov-console
18+
run: tarantoolctl rocks install luacov-console
19+
- name: install luatest
20+
run: tarantoolctl rocks install luatest
21+
- name: run tests
22+
env:
23+
LUACOV_ENABLE: true
24+
run: |
25+
.rocks/bin/luatest --coverage -b -c -v test/
26+
- name: print luacov-console report
27+
run: .rocks/bin/luacov-console "$(pwd)" && .rocks/bin/luacov-console -s
28+
- name: rename luacov.stats.out
29+
run: mv luacov.stats.out luacov.stats.out-${{matrix.version}}
30+
- uses: actions/upload-artifact@master
31+
with:
32+
name: luacov.stats.out-${{matrix.version}}
33+
path: luacov.stats.out-${{matrix.version}}
34+
run-coverage-report:
35+
runs-on: ubuntu-latest
36+
needs: ["run-unit-tests"]
37+
steps:
38+
- uses: actions/checkout@master
39+
- uses: tarantool/setup-tarantool@v3
40+
with:
41+
tarantool-version: '2.10.7'
42+
- name: install luacov-coveralls 0.2.3
43+
run: tarantoolctl rocks install --server=https://luarocks.org luacov-coveralls 0.2.3
44+
- name: install luacov-console 1.2.0
45+
run: tarantoolctl rocks --server http://moonlibs.github.io/rocks install luacov-console 1.2.0
46+
- name: Download run artifacts
47+
uses: actions/download-artifact@v4
48+
with:
49+
pattern: luacov.stats.out-*
50+
merge-multiple: true
51+
- name: debug
52+
run: ls -la .
53+
- name: merge luacov.stats.out
54+
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'
55+
- name: prepare coverage report
56+
run: .rocks/bin/luacov-console . && .rocks/bin/luacov-console -s
57+
- name: publish coveralls report
58+
env:
59+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
60+
run: .rocks/bin/luacov-coveralls -v

.luacheckrc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
std = "luajit"
1+
std = "tarantool"
22
codes = true
33
globals = {
4-
-- Tarantool variable:
5-
"box",
4+
-- Tarantool variables:
65
"table.deepcopy",
76
"dostring",
87

98
-- package reload:
109
"package.reload",
1110
}
1211

12+
include_files = {
13+
"xqueue.lua"
14+
}
15+
16+
max_line_length = 140
17+
1318
ignore = {
14-
"211",
15-
"212",
16-
"431",
17-
"432",
18-
"542",
19-
"611",
20-
-- "631",
19+
"431", -- shadowing upvalue self
20+
"432", -- shadowing upvalue argument
21+
"542", -- empty if branch
2122
}

.luacov

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
deletestats = false
2+
runreport = false
3+
4+
exclude = {
5+
"test/",
6+
"%.rocks/",
7+
"builtin/",
8+
"example",
9+
}
10+
11+
-- path renaming
12+
modules = {
13+
['.xqueue'] = io.popen('pwd'):read('*line') .. '/xqueue.lua',
14+
}
15+
16+
runreport = true
17+
deletestats = false
18+
19+
coveralls = {
20+
root = "/",
21+
debug = true,
22+
pathcorrect = {
23+
{ "^/home/runner/work/xqueue/xqueue/", "" },
24+
},
25+
}

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"Lua.runtime.version": "LuaJIT"
2+
"Lua.runtime.version": "LuaJIT",
3+
"Lua.workspace.checkThirdParty": false
34
}

0 commit comments

Comments
 (0)