Skip to content

Commit 5539181

Browse files
committed
Tests
1 parent 72a9b46 commit 5539181

File tree

9 files changed

+62
-40
lines changed

9 files changed

+62
-40
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Setup Tarantool Test Environment
2+
description: 'Sets up Tarantool and tt'
3+
4+
inputs:
5+
tarantool-version:
6+
description: 'Tarantool version to install'
7+
required: true
8+
only_tt:
9+
description: 'Only install tt'
10+
required: false
11+
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: setup tarantool
16+
uses: tarantool/setup-tarantool@v3
17+
with:
18+
tarantool-version: ${{ inputs.tarantool-version }}
19+
if: ${{ inputs.only_tt != 'true' }}
20+
- name: add tarantool/modules repo
21+
shell: bash
22+
run: |
23+
os=$(. /etc/os-release && echo $ID)
24+
dist=$(. /etc/os-release && echo $VERSION_CODENAME)
25+
curl -L "https://download.tarantool.org/tarantool/modules/gpgkey" | sudo apt-key add -
26+
apt_source_path="/etc/apt/sources.list.d/tarantool.list"
27+
echo "deb https://download.tarantool.org/tarantool/modules/${os}/ ${dist} main" | sudo tee ${apt_source_path}
28+
- name: install tt
29+
shell: bash
30+
run: sudo apt-get update && sudo apt-get install -y tt

.github/actions/setup-test/action.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,9 @@ runs:
1010
using: "composite"
1111
steps:
1212
- name: setup tarantool
13-
uses: tarantool/setup-tarantool@v3
13+
uses: ./.github/actions/setup-tarantool
1414
with:
1515
tarantool-version: ${{ inputs.tarantool-version }}
16-
- name: add tarantool/modules repo
17-
shell: bash
18-
run: |
19-
os=$(. /etc/os-release && echo $ID)
20-
dist=$(. /etc/os-release && echo $VERSION_CODENAME)
21-
curl -L "https://download.tarantool.org/tarantool/modules/gpgkey" | sudo apt-key add -
22-
apt_source_path="/etc/apt/sources.list.d/tarantool.list"
23-
echo "deb https://download.tarantool.org/tarantool/modules/${os}/ ${dist} main" | sudo tee ${apt_source_path}
24-
- name: install tt
25-
shell: bash
26-
run: sudo apt-get update && sudo apt-get install -y tt
2716
- name: install luacov-coveralls 0.2.3
2817
shell: bash
2918
run: tt rocks install --server https://luarocks.org luacov-coveralls 0.2.3

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
12-
- uses: tarantool/setup-tarantool@v3
12+
- uses: ./.github/actions/setup-tarantool
1313
with:
1414
tarantool-version: '2.11'
1515
- name: install tarantool/luacheck and execute it
16-
run: tarantoolctl rocks install luacheck && .rocks/bin/luacheck .
16+
run: tt rocks install luacheck && .rocks/bin/luacheck .

.github/workflows/push-rockspec.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Create and push rockspec for moonlibs/sync
1+
name: Create and push rockspec for moonlibs/kit
22

33
on:
44
workflow_run:
@@ -20,33 +20,35 @@ jobs:
2020
if: ${{ github.event.workflow_run.conclusion == 'success' }} && startsWith(github.ref, 'refs/tags/') }}
2121
steps:
2222
- uses: actions/checkout@v4
23-
- uses: tarantool/setup-tarantool@v3
23+
- uses: ./.github/actions/setup-tarantool
2424
with:
25-
tarantool-version: '2.11.6'
25+
only_tt: 'true'
2626

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

31-
- run: tarantoolctl rocks new_version --tag=${{ env.TAG }} ${{ env.ROCK_NAME }}-dev-1.rockspec ${{ env.TAG }} "git+https://github.com/${{ github.repository }}.git"
32-
- run: tarantoolctl rocks install ${{ env.ROCK_NAME }}-${{ env.TAG }}-1.rockspec
33-
- run: tarantoolctl rocks pack ${{ env.ROCK_NAME }}-${{ env.TAG }}-1.rockspec
34-
# Install native lua with luarocks
35-
- uses: leafo/gh-actions-lua@v11
36-
with:
37-
luaVersion: "luajit-2.1.0-beta3"
38-
- uses: leafo/gh-actions-luarocks@v5
39-
with:
40-
luaRocksVersion: "3.8.0"
31+
- run: tt rocks new_version --tag=${{ env.TAG }} ${{ env.ROCK_NAME }}-dev-1.rockspec ${{ env.TAG }} "git+https://github.com/${{ github.repository }}.git"
32+
- run: tt rocks install ${{ env.ROCK_NAME }}-${{ env.TAG }}-1.rockspec
33+
- run: tt rocks pack ${{ env.ROCK_NAME }}-${{ env.TAG }}-1.rockspec
34+
4135
- uses: unfor19/install-aws-cli-action@v1.0.3
42-
- run: mkdir .build && cp ${{ env.ROCK_NAME }}-dev-1.rockspec ${{ env.ROCK_NAME }}-${{ env.TAG }}-1.rockspec .build/ && cp *.src.rock .build/
36+
- run:
37+
|
38+
mkdir .build
39+
cp ${{ env.ROCK_NAME }}-dev-1.rockspec ${{ env.ROCK_NAME }}-${{ env.TAG }}-1.rockspec \
40+
.build/
41+
cp *.src.rock .build/
4342
- name: rebuild and publish s3 luarocks server
4443
env:
4544
AWS_ACCESS_KEY_ID: ${{ secrets.MOONLIBS_S3_ACCESS_KEY_ID }}
4645
AWS_SECRET_ACCESS_KEY: ${{ secrets.MOONLIBS_S3_SECRET_KEY}}
4746
AWS_EC2_METADATA_DISABLED: true
4847
run: |
49-
cd .build && aws s3 sync s3://moonlibs/ ./ && luarocks-admin make_manifest . && aws s3 sync --acl public-read ./ s3://moonlibs/;
48+
cd .build && \
49+
aws s3 sync s3://moonlibs/ ./ && \
50+
tt rocks admin make_manifest . && \
51+
aws s3 sync --acl public-read ./ s3://moonlibs/;
5052
- uses: "marvinpinto/action-automatic-releases@latest"
5153
with:
5254
repo_token: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/tests.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ jobs:
1616
with:
1717
tarantool-version: ${{matrix.version}}
1818
- name: run tests
19-
env:
20-
LUACOV_ENABLE: true
21-
run: |
22-
make test
19+
run: make test
2320
- name: rename luacov.stats.out
2421
run: mv luacov.stats.out luacov.stats.out-${{matrix.version}}
2522
- uses: actions/upload-artifact@master

.luacov

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ deletestats = false
44
exclude = {
55
"%.rocks/",
66
"builtin/",
7-
"01-base%.test%.lua"
7+
"t/.+%.test",
88
}
99

1010
pathcorrect = {

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.PHONY := all test
22

33
test:
4-
export LUACOV_ENABLE=true
5-
prove t/*.lua
4+
prove -v t/*.lua

kit/3.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ return function(M,I)
1010
return box.info.hostname
1111
end
1212
I._node_keys.name = function()
13-
return box.info.name
13+
local name = box.info.name
14+
if name == nil and rawget(_G, 'config') and config._flat then
15+
name = config.get('sys.instance_name')
16+
end
17+
return name
1418
end
1519
end

t/01-base.test.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/env tarantool
22

3-
if os.getenv("LUACOV_ENABLE") then
4-
print("enabling luacov")
5-
require 'luacov.runner'.init()
3+
local ok, runner = pcall(require, 'luacov.runner')
4+
if ok then
5+
print("Running luacov")
6+
runner.init()
67
end
78

89
local kit = require 'kit'

0 commit comments

Comments
 (0)