├── debian ├── compat ├── docs ├── source │ └── format ├── tarantool-luakit.install ├── .gitignore ├── rules ├── changelog ├── control └── copyright ├── AUTHORS ├── Jenkinsfile ├── .gitignore ├── test └── luakit.test.lua ├── luakit └── init.lua ├── rpm └── tarantool-luakit.spec ├── LICENSE ├── luakit-scm-1.rockspec ├── .travis.yml └── README.md /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/docs: -------------------------------------------------------------------------------- 1 | README.md 2 | AUTHORS 3 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Roman Tsisyk 2 | -------------------------------------------------------------------------------- /debian/tarantool-luakit.install: -------------------------------------------------------------------------------- 1 | luakit/init.lua usr/share/tarantool/luakit/ 2 | -------------------------------------------------------------------------------- /debian/.gitignore: -------------------------------------------------------------------------------- 1 | tarantool-luakit/ 2 | files 3 | stamp-* 4 | *.substvars 5 | *.log 6 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | %: 4 | dh $@ 5 | 6 | override_dh_auto_test: 7 | prove -v ./test/luakit.test.lua 8 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | stage('Build'){ 2 | packpack = new org.tarantool.packpack() 3 | node { 4 | checkout scm 5 | packpack.prepareSources() 6 | } 7 | packpack.packpackBuildMatrix('result') 8 | } 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | CMakeFiles/ 2 | obj-*/ 3 | CMakeCache.txt 4 | Makefile 5 | cmake_*.cmake 6 | install_manifest.txt 7 | *.a 8 | *.cbp 9 | *.d 10 | *.dylib 11 | *.gcno 12 | *.gcda 13 | *.user 14 | *.o 15 | *.reject 16 | *.so 17 | *.snap* 18 | *.xlog* 19 | *~ 20 | .gdb_history 21 | ./build 22 | /build 23 | VERSION 24 | CTestTestfile.cmake 25 | Testing 26 | CTestTestfile.cmake 27 | -------------------------------------------------------------------------------- /test/luakit.test.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env tarantool 2 | 3 | local kit = require('luakit') 4 | local tap = require('tap') 5 | 6 | local test = tap.test('luakit tests') 7 | test:plan(1) 8 | 9 | test:test('luakit', function(test) 10 | test:plan(1) 11 | test:is(kit.test(1), 11, "Lua function in init.lua") 12 | end) 13 | 14 | os.exit(test:check() == true and 0 or -1) 15 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | tarantool-luakit (2.0.0-1) unstable; urgency=medium 2 | 3 | * Split into luakit and ckit 4 | 5 | -- Roman Tsisyk Tue, 21 Feb 2017 19:02:52 +0300 6 | 7 | tarantool-modulekit (1.0.1-1) unstable; urgency=medium 8 | 9 | * Fix tarantool-dev and libmsgpuck-dev dependencies 10 | * Set correct Architecture 11 | * Update Standards-Version 12 | 13 | -- Roman Tsisyk Wed, 17 Feb 2016 10:19:12 +0300 14 | 15 | tarantool-modulekit (1.0.0-1) unstable; urgency=low 16 | 17 | * Initial release 18 | 19 | -- Roman Tsisyk Wed, 16 Sep 2015 11:30:00 +0300 20 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: tarantool-luakit 2 | Priority: optional 3 | Section: database 4 | Maintainer: Roman Tsisyk 5 | Build-Depends: debhelper (>= 9), tarantool (>= 1.6.8.0) 6 | Standards-Version: 3.9.8 7 | Homepage: https://github.com/tarantool/luakit 8 | Vcs-Git: git://github.com/tarantool/luakit.git 9 | Vcs-Browser: https://github.com/tarantool/luakit 10 | 11 | Package: tarantool-luakit 12 | Architecture: all 13 | Depends: tarantool (>= 1.6.8.0), ${shlibs:Depends}, ${misc:Depends} 14 | Pre-Depends: ${misc:Pre-Depends} 15 | Description: Lua module template for Tarantool 16 | This package provides a Lua module template for Tarantool. 17 | -------------------------------------------------------------------------------- /luakit/init.lua: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | --- Example of a Lua module for Tarantool 3 | -------------------------------------------------------------------------------- 4 | 5 | -- 6 | -- Dependencies 7 | -- 8 | 9 | local log = require('log') -- some other Tarantool module 10 | 11 | -- 12 | -- Constants 13 | -- 14 | 15 | -- local variables are only visible from this file 16 | local SOME_CONSTANT = 10 17 | 18 | -- 19 | -- Internal functions 20 | -- 21 | 22 | -- Some internal function 23 | local function test(x) 24 | if x == nil then 25 | error("Usage: test(x: integer)") 26 | end 27 | log.info("test() called with x=%s", x) 28 | return x + SOME_CONSTANT 29 | end 30 | 31 | -- 32 | -- Exported functions 33 | -- 34 | 35 | -- result returned from require('luakit') 36 | return { 37 | test = test; 38 | } 39 | -- vim: ts=4 sts=4 sw=4 et -------------------------------------------------------------------------------- /rpm/tarantool-luakit.spec: -------------------------------------------------------------------------------- 1 | Name: tarantool-luakit 2 | Version: 2.0.0 3 | Release: 1%{?dist} 4 | Summary: Lua module template for Tarantool 5 | Group: Applications/Databases 6 | License: BSD 7 | URL: https://github.com/tarantool/modulekit 8 | Source0: luakit-%{version}.tar.gz 9 | BuildArch: noarch 10 | BuildRequires: tarantool-devel >= 1.6.8.0 11 | Requires: tarantool >= 1.6.8.0 12 | 13 | %description 14 | This package provides a Lua module template for Tarantool. 15 | 16 | %prep 17 | %setup -q -n luakit-%{version} 18 | 19 | %check 20 | ./test/luakit.test.lua 21 | 22 | %install 23 | # Create /usr/share/tarantool/luakit 24 | mkdir -p %{buildroot}%{_datadir}/tarantool/luakit 25 | # Copy init.lua to /usr/share/tarantool/luakit/init.lua 26 | cp -p luakit/*.lua %{buildroot}%{_datadir}/tarantool/luakit 27 | 28 | %files 29 | %dir %{_datadir}/tarantool/luakit 30 | %{_datadir}/tarantool/luakit/ 31 | %doc README.md 32 | %{!?_licensedir:%global license %doc} 33 | %license LICENSE AUTHORS 34 | 35 | %changelog 36 | * Tue Feb 21 2017 Roman Tsisyk 2.0.0-1 37 | - Split package into luakit and ckit. 38 | 39 | * Wed Feb 17 2016 Roman Tsisyk 1.0.1-1 40 | - Fix to comply Fedora Package Guidelines 41 | 42 | * Wed Sep 16 2015 Roman Tsisyk 1.0.0-1 43 | - Initial version of the RPM spec 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2010-2017 Tarantool AUTHORS: please see AUTHORS file. 2 | 3 | Redistribution and use in source and binary forms, with or 4 | without modification, are permitted provided that the following 5 | conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above 8 | copyright notice, this list of conditions and the 9 | following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following 13 | disclaimer in the documentation and/or other materials 14 | provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY AUTHORS AND CONTRIBUTORS ``AS IS'' AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 20 | AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 27 | THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | SUCH DAMAGE. 29 | 30 | -------------------------------------------------------------------------------- /luakit-scm-1.rockspec: -------------------------------------------------------------------------------- 1 | -- name of the package to be published 2 | package = 'luakit' 3 | 4 | -- version of the package; it's mandatory, but we don't use it in Tarantool; 5 | -- instead, provide below a specific branch in the package's repository at 6 | -- GitHub and set version to some stub value, e.g. 'scm-1' 7 | version = 'scm-1' 8 | 9 | -- url and branch of the package's repository at GitHub 10 | source = { 11 | url = 'git+https://github.com/tarantool/modulekit.git'; 12 | branch = 'luakit'; 13 | } 14 | 15 | -- general information about the package; 16 | -- for a Tarantool package, we require three fields (summary, homepage, license) 17 | -- and more package information is always welcome 18 | description = { 19 | summary = "Lua module template for Tarantool"; 20 | detailed = [[ 21 | A ready-to-use Lua module template. 22 | Clone and modify it to create new modules. 23 | ]]; 24 | homepage = 'https://github.com/tarantool/modulekit.git'; 25 | maintainer = "Roman Tsisyk "; 26 | license = 'BSD2'; 27 | } 28 | 29 | -- Lua version and other packages on which this one depends; 30 | -- Tarantool currently supports strictly Lua 5.1 31 | dependencies = { 32 | 'lua == 5.1'; 33 | } 34 | 35 | -- build options and paths for the package; 36 | -- this package distributes modules in pure Lua, so the build type = 'builtin'; 37 | -- also, specify here paths to all Lua modules within the package 38 | -- (this package contains just one Lua module named 'luakit') 39 | build = { 40 | type = 'builtin'; 41 | modules = { 42 | ['luakit'] = 'luakit/init.lua'; 43 | } 44 | } 45 | -- vim: syntax=lua ts=4 sts=4 sw=4 et 46 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Debianized-By: Roman Tsisyk 3 | Upstream-Name: tarantool-modulekit 4 | Upstream-Contact: roman@tarantool.org 5 | Source: https://github.com/tarantool/modulekit 6 | 7 | Files: * 8 | Copyright: 2015-2017 by Roman Tsisyk 9 | License: BSD-2-Clause 10 | Redistribution and use in source and binary forms, with or 11 | without modification, are permitted provided that the following 12 | conditions are met: 13 | . 14 | 1. Redistributions of source code must retain the above 15 | copyright notice, this list of conditions and the 16 | following disclaimer. 17 | . 18 | 2. Redistributions in binary form must reproduce the above 19 | copyright notice, this list of conditions and the following 20 | disclaimer in the documentation and/or other materials 21 | provided with the distribution. 22 | . 23 | THIS SOFTWARE IS PROVIDED BY AUTHORS AND CONTRIBUTORS ``AS IS'' AND 24 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 25 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 27 | AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 31 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 32 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 34 | THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 | SUCH DAMAGE. 36 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: C 3 | services: 4 | - docker 5 | 6 | cache: 7 | directories: 8 | - $HOME/.cache 9 | 10 | git: 11 | depth: 100500 12 | 13 | env: 14 | global: 15 | - PRODUCT=tarantool-luakit 16 | matrix: 17 | - OS=el DIST=6 18 | - OS=el DIST=7 19 | - OS=fedora DIST=24 20 | - OS=fedora DIST=25 21 | - OS=ubuntu DIST=precise 22 | - OS=ubuntu DIST=trusty 23 | - OS=ubuntu DIST=xenial 24 | - OS=ubuntu DIST=yakkety 25 | - OS=debian DIST=wheezy 26 | - OS=debian DIST=jessie 27 | - OS=debian DIST=stretch 28 | 29 | #matrix: 30 | # allow_failures: 31 | # - env: OS=el DIST=6 32 | # - env: OS=el DIST=7 33 | # - env: OS=fedora DIST=24 34 | # - env: OS=fedora DIST=25 35 | # - env: OS=ubuntu DIST=precise 36 | # - env: OS=ubuntu DIST=trusty 37 | # - env: OS=ubuntu DIST=xenial 38 | # - env: OS=ubuntu DIST=yakkety 39 | # - env: OS=debian DIST=wheezy 40 | # - env: OS=debian DIST=jessie 41 | # - env: OS=debian DIST=stretch 42 | 43 | script: 44 | - git describe --long 45 | - git clone https://github.com/packpack/packpack.git packpack 46 | - packpack/packpack 47 | 48 | before_deploy: 49 | - ls -l build/ 50 | 51 | deploy: 52 | # Deploy packages to PackageCloud 53 | - provider: packagecloud 54 | username: tarantool 55 | repository: "1_6" 56 | token: ${PACKAGECLOUD_TOKEN} 57 | dist: ${OS}/${DIST} 58 | package_glob: build/*.{deb,rpm,dsc} 59 | skip_cleanup: true 60 | on: 61 | branch: master 62 | condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}" 63 | - provider: packagecloud 64 | username: tarantool 65 | repository: "1_7" 66 | token: ${PACKAGECLOUD_TOKEN} 67 | dist: ${OS}/${DIST} 68 | package_glob: build/*.{deb,rpm,dsc} 69 | skip_cleanup: true 70 | on: 71 | branch: master 72 | condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}" 73 | - provider: packagecloud 74 | username: tarantool 75 | repository: "1_8" 76 | token: ${PACKAGECLOUD_TOKEN} 77 | dist: ${OS}/${DIST} 78 | package_glob: build/*.{deb,rpm,dsc} 79 | skip_cleanup: true 80 | on: 81 | branch: master 82 | condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}" 83 | 84 | notifications: 85 | email: 86 | recipients: 87 | - build@tarantool.org 88 | on_success: change 89 | on_failure: always 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | # Lua module template for Tarantool 1.6+ 9 | 10 | Use this template to create and publish a [Tarantool][] module written in pure 11 | Lua. 12 | 13 | **Note:** If you write a Tarantool module in C, see the [ckit][Ckit] branch of 14 | this repository. 15 | 16 | ## Table of contents 17 | * [Kit content](#kit-content) 18 | * [Prerequisites](#prerequisites) 19 | * [Examples](#examples) 20 | * [See also](#see-also) 21 | 22 | ## Kit content 23 | 24 | * `./README.md` - this file 25 | * `./luakit/init.lua` - the Lua module itself, loaded with `require('luakit')` 26 | * `./luakit-scm-1.rockspec` - a specification for the 27 | [tarantool/rocks][TarantoolRocks] repository 28 | * `./test/luakit.test.lua` - tests for the module 29 | * `./rpm/` - files to build an RPM package 30 | * `./debian/` - files to build a DEB package 31 | 32 | ## Prerequisites 33 | 34 | Tarantool 1.6.8+ with header files (`tarantool` and `tarantool-dev` packages) 35 | 36 | ## Usage 37 | 38 | 1. Clone this repository. 39 | 40 | ```bash 41 | git clone https://github.com/tarantool/modulekit.git 42 | ``` 43 | 44 | The default branch is `luakit`, which is what you need for a module in pure 45 | Lua. 46 | 47 | 2. Rename all files to use your favorite name. 48 | 49 | For example, `mymodule`: 50 | 51 | ```bash 52 | grep -R luakit . 53 | mv luakit/ mymodule/ 54 | mv test/luakit.test.lua test/mymodule.test.lua 55 | ... 56 | ``` 57 | 58 | 3. Implement your code in `./mymodule/`. 59 | 60 | You will have one or more Lua modules that export their functions for 61 | API calls. 62 | 63 | As an example, see the Lua module [luakit/init.lua][LuaModule] from the 64 | `luakit` package. Here we have one internal function (`test()`), and we 65 | export it as `test` for API calls. 66 | 67 | As a result, after we publish the `luakit` package in step 7, Tarantool 68 | users will be able to load the package and call the function `test()` with 69 | `require('luakit').test(arg)`. 70 | 71 | **Note:** The basics of [creating a Lua module][CreateLuaModule] for 72 | Tarantool are explained in the Tarantool manual. 73 | 74 | 4. Add tests to `./test/mymodule.test.lua`: 75 | 76 | ```bash 77 | prove -v ./test/luakit.test.lua or ./test/luakit.test.lua 78 | ``` 79 | 80 | 5. Update copyright and README files. 81 | 82 | 6. Push all files except `rpm/`, `debian/` and `mymodule-scm-1.rockspec`. 83 | 84 | 7. Update and check the rockspec. 85 | 86 | A `.rockspec` file wraps a module into a package. This is what you can 87 | publish. If you are new to Lua rocks, see general information on rockspec 88 | [format][RockSpecFormat] and [creation][RockSpecCreation]. 89 | 90 | Your rockspec must comply with [these requirements][Requirements] 91 | and allow to build and install your package locally: 92 | 93 | ```bash 94 | luarocks install --local mymodule-scm-1.rockspec 95 | ``` 96 | 97 | See an annotated rockspec example in [luakit-scm-1.rockspec][LuaRockSpec]. 98 | 99 | 8. Push your rockspec and make a pull request to the 100 | [tarantool/rocks][TarantoolRocks] repository. 101 | 102 | The Tarantool team will review the request and decide on including your 103 | package in [Tarantool rocks list][TarantoolRocksList] and 104 | [official Tarantool images for Docker][TarantoolDocker]. 105 | 106 | 9. [Optional] Check DEB packaging and push `debian/` to GitHub. 107 | 108 | ```bash 109 | dpkg-buildpackage -D -b -us -uc 110 | ls -l ../*.deb 111 | ``` 112 | 113 | 10. [Optional] Check RPM packaging and push `rpm/` to GitHub. 114 | 115 | ```bash 116 | tar cvzf ~/rpmbuild/SOURCES/tarantool-mymodule-1.0.0.tar.gz 117 | rpmbuild -b rpm/tarantool-mymodule.spec 118 | ``` 119 | 120 | Enjoy! Thank you for contributing to Tarantool. 121 | 122 | ## Examples 123 | 124 | * [Lua module example](http://github.com/tarantool/queue) 125 | * [One more Lua module example](http://github.com/tarantool/gperftools) 126 | 127 | ## See also 128 | 129 | * [Tarantool/Lua API Reference][TarantoolLuaReference] 130 | * [Modulekit for Tarantool modules in C][Ckit] 131 | 132 | [Tarantool]: http://github.com/tarantool/tarantool 133 | [Download]: http://tarantool.org/download.html 134 | [Requirements]: http://github.com/tarantool/rocks#contributing 135 | [RockSpecFormat]: http://github.com/keplerproject/luarocks/wiki/Rockspec-format 136 | [RockSpecCreation]: http://github.com/luarocks/luarocks/wiki/Creating-a-rock 137 | [LuaCReference]: http://pgl.yoyo.org/luai/i/_ 138 | [TarantoolLuaReference]: http://tarantool.org/doc/reference/index.html 139 | [TarantoolCReference]: http://tarantool.org/doc/reference/capi.html 140 | [TarantoolRocks]: http://github.com/tarantool/rocks 141 | [TarantoolRocksList]: http://tarantool.org/en/download/rocks.html 142 | [TarantoolDocker]: http://github.com/tarantool/docker 143 | [Luakit]: http://github.com/tarantool/modulekit/tree/luakit 144 | [Ckit]: http://github.com/tarantool/modulekit/tree/ckit 145 | [LuaModule]: http://github.com/tarantool/modulekit/blob/luakit/luakit/init.lua 146 | [CModule]: http://github.com/tarantool/modulekit/blob/ckit/ckit/lib.c 147 | [LuaCModule]: http://github.com/tarantool/modulekit/blob/ckit/ckit/init.lua 148 | [LuaRockSpec]: http://github.com/tarantool/modulekit/blob/luakit/luakit-scm-1.rockspec 149 | [CRockSpec]: http://github.com/tarantool/modulekit/blob/ckit/ckit-scm-1.rockspec 150 | [CreateLuaModule]: http://tarantool.org/en/doc/book/app_server/creating_app.html#modules-rocks-and-applications 151 | --------------------------------------------------------------------------------