Skip to content

Commit

Permalink
test: adds tests and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ochaton committed Jul 23, 2024
1 parent 6ae38de commit 0d11e9e
Show file tree
Hide file tree
Showing 12 changed files with 939 additions and 146 deletions.
1 change: 0 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Linting with luacheck

on:
- push
- pull_request

jobs:
run-luacheck-linter:
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/push-rockspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Create and push rockspec for moonlibs/xqueue

on:
push:
tags:
- '*'

env:
ROCK_NAME: xqueue

jobs:
pack-and-push-tagged-rockspec:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@master
- uses: tarantool/setup-tarantool@v3
with:
tarantool-version: '2.6'

# 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/xqueue-scm-5.rockspec ${{ env.TAG }} "git+https://github.com/${{ github.repository }}.git"
- run: tarantoolctl rocks --server https://moonlibs.github.io/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 ${{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
39 changes: 34 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ name: Testing with unit tests

on:
- push
- pull_request

jobs:
run-unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
version: ["1.10.15", "2.10.6", "2.11.0", "2.11.2"]
steps:
- uses: actions/checkout@v4
- uses: tarantool/setup-tarantool@v3
with:
tarantool-version: '2.10.4'
tarantool-version: '${{matrix.version}}'
- name: install luacov-console
run: tarantoolctl rocks install luacov-console
- name: install luacov-coveralls
run: tarantoolctl rocks install --server=http://luarocks.org luacov-coveralls
- name: install luatest
run: tarantoolctl rocks install luatest
- name: run tests
Expand All @@ -25,7 +25,36 @@ jobs:
.rocks/bin/luatest --coverage -b -c -v test/
- name: print luacov-console report
run: .rocks/bin/luacov-console "$(pwd)" && .rocks/bin/luacov-console -s
- 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@master
- 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
run: .rocks/bin/luacov-coveralls -v
5 changes: 5 additions & 0 deletions .luacov
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ exclude = {
"example",
}

-- path renaming
modules = {
['.xqueue'] = io.popen('pwd'):read('*line') .. '/xqueue.lua',
}

runreport = true
deletestats = false

Expand Down
Loading

0 comments on commit 0d11e9e

Please sign in to comment.